好的,所以我要制作一个Bukkit插件,该插件应该检测到鹅卵石生成器,请记住,我不想阻止玩家制作鹅卵石生成器,我只想从事件中获取块,所以我可以那个鹅卵石的其他东西。
到目前为止,我已经尝试过:
BlockFromToEvent(找不到鹅卵石,仅找到STATIONARY_LAVA到AIR)
BlockFormEvent(仅在地面上发现积雪)
我想做的事:
我想检测水+熔岩组合产生的鹅卵石块
我想获取他们的位置/位置/坐标
您能否至少请向我指出正确的方向?我已经拔头发已经快三个小时了。
感谢大家的帮助!
编辑:下图中的解决方案,如果需要,将重新输入!
最佳答案
Good answer from FireBlast709 at Bukkit Forums
这将取消任何鹅卵石的产生。基本上,如果您想操纵鹅卵石,则可以将取消线(指示)更改为所需的内容。
@EventHandler
public void onFromTo(BlockFromToEvent event){
Material type = event.getBlock().getType();
if (type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA){
Block b = event.getToBlock();
if (b.getType() == Material.AIR){
if (generatesCobble(type, b)){
/* DO WHATEVER YOU NEED WITH THE COBBLE */
event.setCancelled(true);
}
}
}
}
private final BlockFace[] faces = new BlockFace[]{
BlockFace.SELF,
BlockFace.UP,
BlockFace.DOWN,
BlockFace.NORTH,
BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.WEST
};
public boolean generatesCobble(Material type, Block b){
Material mirrorID1 = (type == Material.WATER || type == Material.STATIONARY_WATER ? Material.LAVA : Material.WATER);
Material mirrorID2 = (type == Material.WATER || type == Material.STATIONARY_WATER ? Material.STATIONARY_LAVA : Material.STATIONARY_WATER);
for (BlockFace face : faces){
Block r = b.getRelative(face, 1);
if (r.getType() == mirrorID1 || r.getType() == mirrorID2){
return true;
}
}
return false;
}
关于java - 我如何检测Bukkit生成的鹅卵石?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44096564/