Search in sources :

Example 1 with EntityNethermite

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);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EntityNethermite(nex.entity.monster.EntityNethermite) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 EntityNethermite (nex.entity.monster.EntityNethermite)1