Search in sources :

Example 1 with EntityKingCreeper

use of com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper in project takumicraft by TNTModders.

the class BlockTakumiAltar method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    boolean flg = super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
    Entity entity = null;
    if (worldIn.getBlockState(pos.down()).getBlock() == TakumiBlockCore.CREEPER_BOMB) {
        entity = new EntityKingCreeper(worldIn);
    } else if (worldIn.getBlockState(pos.up()).getBlock() == Blocks.CAKE) {
        entity = new EntityAnnivCreeper(worldIn);
    } else {
        List<ITakumiEntity> entities = new ArrayList<>();
        TakumiEntityCore.getEntityList().forEach(iTakumiEntity -> {
            if (iTakumiEntity.takumiRank() == EnumTakumiRank.HIGH) {
                entities.add(iTakumiEntity);
            }
        });
        if (!entities.isEmpty()) {
            entities.removeIf(iTakumiEntity -> iTakumiEntity instanceof EntityAnnivCreeper);
            try {
                entity = (Entity) entities.get(worldIn.rand.nextInt(entities.size())).getClass().getConstructor(World.class).newInstance(worldIn);
            } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
    if (entity != null) {
        entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
        worldIn.setBlockToAir(pos);
        if (worldIn.getBlockState(pos.down()).getBlockHardness(worldIn, pos.down()) > 0) {
            worldIn.setBlockToAir(pos.down());
        }
        if (!worldIn.isRemote) {
            worldIn.createExplosion(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 3f, true);
            if (worldIn.spawnEntity(entity)) {
                return true;
            }
        }
    }
    return flg;
}
Also used : EntityAnnivCreeper(com.tntmodders.takumi.entity.mobs.EntityAnnivCreeper) MapColor(net.minecraft.block.material.MapColor) Entity(net.minecraft.entity.Entity) TakumiBlockCore(com.tntmodders.takumi.core.TakumiBlockCore) TakumiEntityCore(com.tntmodders.takumi.core.TakumiEntityCore) Blocks(net.minecraft.init.Blocks) World(net.minecraft.world.World) EnumHand(net.minecraft.util.EnumHand) EnumTakumiRank(com.tntmodders.takumi.entity.ITakumiEntity.EnumTakumiRank) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) TakumiCraftCore(com.tntmodders.takumi.TakumiCraftCore) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArrayList(java.util.ArrayList) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Block(net.minecraft.block.Block) Material(net.minecraft.block.material.Material) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityKingCreeper(com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper) Entity(net.minecraft.entity.Entity) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityAnnivCreeper(com.tntmodders.takumi.entity.mobs.EntityAnnivCreeper) ArrayList(java.util.ArrayList) List(java.util.List) EntityKingCreeper(com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper)

Aggregations

TakumiCraftCore (com.tntmodders.takumi.TakumiCraftCore)1 TakumiBlockCore (com.tntmodders.takumi.core.TakumiBlockCore)1 TakumiEntityCore (com.tntmodders.takumi.core.TakumiEntityCore)1 ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)1 EnumTakumiRank (com.tntmodders.takumi.entity.ITakumiEntity.EnumTakumiRank)1 EntityAnnivCreeper (com.tntmodders.takumi.entity.mobs.EntityAnnivCreeper)1 EntityKingCreeper (com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Block (net.minecraft.block.Block)1 MapColor (net.minecraft.block.material.MapColor)1 Material (net.minecraft.block.material.Material)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Blocks (net.minecraft.init.Blocks)1 EnumFacing (net.minecraft.util.EnumFacing)1 EnumHand (net.minecraft.util.EnumHand)1 BlockPos (net.minecraft.util.math.BlockPos)1