2016-04-03 68 views
0

如何我將跟蹤由創建彈丸/實體:Bukkit - 軌道彈

Egg egg = (Egg) ((ProjectileSource) player).launchProjectile(Egg.class); 

,並找出哪些阻礙卵子已經登陸?

我也想從這些雞蛋中禁用雞卵產卵。

回答

1

爲了得到雞蛋着陸的地方,它似乎很complex。如果是罰款,你只得到了塊彈丸是,你可以使用這個:

@EventHandler 
public void onProjectileHit(ProjectileHitEvent e) { 
    if (e.getEntity().getType() == EntityType.EGG) { 
     Block block = e.getEntity().getLocation().getBlock(); 
    } 
} 

從雞蛋產卵雞預防是平凡:

@EventHandler 
public void onCreatureSpawn(CreatureSpawnEvent e) { 
    if (e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) { 
     e.setCancelled(true); 
    } 
}