use of nex.entity.monster.EntityNethermite in project NetherEx by LogicTechCorp.
the class EventHandler method onBlockBreak.
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
if (!(event.getPlayer() instanceof FakePlayer)) {
EntityPlayer player = event.getPlayer();
if (state.getBlock() == Blocks.MAGMA) {
if (ConfigHandler.block.magma.turnIntoLava) {
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) == 0) {
world.setBlockState(pos, Blocks.LAVA.getDefaultState(), 3);
player.getHeldItemMainhand().damageItem(1, player);
event.setCanceled(true);
}
}
}
if (player.dimension == -1) {
boolean canSpawn = Arrays.asList(ConfigHandler.entity.nethermite.whitelist).contains(state.getBlock().getRegistryName().toString());
if (canSpawn && world.rand.nextInt(ConfigHandler.entity.nethermite.chanceOfSpawning) == 0) {
EntityNethermite nethermite = new EntityNethermite(world);
nethermite.setPosition((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D);
world.spawnEntity(nethermite);
}
}
}
}
Aggregations