Search in sources :

Example 1 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity 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)

Example 2 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class GuiTakumiBook method getEntity.

private EntityLivingBase getEntity(ITakumiEntity entity, boolean flg) {
    if (entity instanceof EntityGiantCreeper) {
        return new EntityZombieCreeper(((Entity) entity).world);
    }
    if (entity instanceof EntitySilentCreeper && !flg) {
        return new EntityCreeper(((Entity) entity).world);
    }
    if (entity instanceof EntitySlimeCreeper) {
        ((EntitySlimeCreeper) entity).setSlimeSize(2, false);
    } else if (entity instanceof EntitySkeletonCreeper) {
        if (entity instanceof EntityStrayCreeper) {
            if (!flg) {
                entity = new EntitySkeletonCreeper(((Entity) entity).world);
            }
            ItemStack stack = new ItemStack(Items.POTIONITEM);
            PotionUtils.addPotionToItemStack(stack, PotionType.getPotionTypeForName("water"));
            ((EntitySkeletonCreeper) entity).setItemStackToSlot(EntityEquipmentSlot.OFFHAND, stack, false);
        }
        ((EntitySkeletonCreeper) entity).setItemStackToSlot(EntityEquipmentSlot.MAINHAND, entity instanceof EntityWitherSkeletonCreeper ? new ItemStack(TakumiItemCore.TAKUMI_SWORD) : new ItemStack(TakumiItemCore.TAKUMI_BOW), false);
    } else if (entity instanceof EntitySquidCreeper) {
        ((EntitySquidCreeper) entity).tentacleAngle = 45;
        ((EntitySquidCreeper) entity).squidPitch = 60;
    } else if (entity instanceof EntitySheepCreeper && !flg) {
        ((EntitySheepCreeper) entity).setSheared(true);
    } else if (entity instanceof EntityVindicatorCreeper) {
        ((EntityVindicatorCreeper) entity).setAggressive(true);
        ((Entity) entity).setItemStackToSlot(EntityEquipmentSlot.OFFHAND, new ItemStack(TakumiItemCore.TAKUMI_SHIELD));
        ((Entity) entity).setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(TakumiItemCore.TAKUMI_SWORD));
    } else if (entity instanceof EntityIllusionerCreeper) {
        ((EntityIllusionerCreeper) entity).setAggressive(true);
        ((Entity) entity).setItemStackToSlot(EntityEquipmentSlot.OFFHAND, new ItemStack(TakumiItemCore.TAKUMI_ARROW_HA));
        ((Entity) entity).setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(TakumiItemCore.TAKUMI_BOW));
    }
    return (EntityLivingBase) entity;
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) Entity(net.minecraft.entity.Entity) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class TakumiEvents method onExplosion.

@SubscribeEvent
public void onExplosion(Detonate event) {
    if (!event.getWorld().isRemote) {
        event.getAffectedEntities().removeIf(entity -> entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getActiveItemStack().getItem() == TakumiItemCore.TAKUMI_SHIELD);
        if (event.getWorld().getBlockState(new BlockPos(event.getExplosion().getPosition())).getBlock() == TakumiBlockCore.ACID_BLOCK) {
            IBlockState state = event.getWorld().getBlockState(new BlockPos(event.getExplosion().getPosition()));
            int i = state.getValue(BlockTakumiAcid.META) + 1;
            event.getAffectedBlocks().forEach(pos -> {
                if (i < 16) {
                    for (EnumFacing facing : EnumFacing.values()) {
                        BlockPos blockPos = pos.offset(facing);
                        if (!event.getAffectedBlocks().contains(blockPos) && !event.getWorld().isAirBlock(blockPos) && event.getWorld().getBlockState(blockPos).getBlockHardness(event.getWorld(), blockPos) != -1 && event.getWorld().getBlockState(blockPos).getBlock() != TakumiBlockCore.ACID_BLOCK) {
                            event.getWorld().setBlockState(blockPos, TakumiBlockCore.ACID_BLOCK.getDefaultState().withProperty(BlockTakumiAcid.META, i));
                        }
                    }
                }
                event.getWorld().setBlockToAir(pos);
            });
            event.getAffectedBlocks().clear();
        }
    }
    if (event.getExplosion() instanceof TakumiExplosion) {
        if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof AbstractEntityTakumiGrenade) {
            AbstractEntityTakumiGrenade grenade = (AbstractEntityTakumiGrenade) ((TakumiExplosion) event.getExplosion()).getExploder();
            if (grenade.getThrower() != null) {
                event.getAffectedEntities().remove(grenade.getThrower());
            }
        }
        if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTakumiArrow) {
            EntityTakumiArrow takumiArrow = (EntityTakumiArrow) ((TakumiExplosion) event.getExplosion()).getExploder();
            if (takumiArrow.shootingEntity instanceof EntityStrayCreeper) {
                PotionType type = PotionUtils.getPotionFromItem(((EntityLivingBase) takumiArrow.shootingEntity).getHeldItem(EnumHand.OFF_HAND));
                for (Entity entity : event.getAffectedEntities()) {
                    if (entity instanceof EntityLivingBase && entity != takumiArrow.shootingEntity) {
                        PotionEffect effect = new PotionEffect(type.getEffects().get(0).getPotion(), 400);
                        ((EntityLivingBase) entity).addPotionEffect(effect);
                    }
                }
            }
        }
        if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTakumiPotion) {
            for (Entity entity : event.getAffectedEntities()) {
                if (entity instanceof EntityLivingBase) {
                    List<PotionEffect> effects = PotionUtils.getEffectsFromStack(((EntityPotion) ((TakumiExplosion) event.getExplosion()).getExploder()).getPotion());
                    for (PotionEffect effect : effects) {
                        ((EntityLivingBase) entity).addPotionEffect(effect);
                    }
                }
            }
        }
        if (((TakumiExplosion) event.getExplosion()).getExploder() instanceof EntityTransHomingBomb) {
            event.getAffectedEntities().forEach(entity -> {
                if (entity instanceof EntityPlayer) {
                    ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 150));
                    ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(TakumiPotionCore.INVERSION, 150));
                }
            });
        }
    }
    if (event.getExplosion().getExplosivePlacedBy() instanceof ITakumiEntity) {
        boolean flg = ((ITakumiEntity) event.getExplosion().getExplosivePlacedBy()).takumiExplodeEvent(event);
        if (!flg) {
            event.setCanceled(true);
        }
    }
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) PotionType(net.minecraft.potion.PotionType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class EntityFireworksCreeper method spawn.

public static void spawn(EntityTakumiAbstractCreeper entity) {
    for (int x = (int) entity.posX - 4; x <= (int) entity.posX + 4; x++) {
        for (int z = (int) entity.posZ - 4; z <= (int) entity.posZ + 4; z++) {
            for (int y = (int) entity.posY + 2; y >= (int) entity.posY + 1; y--) {
                for (int i = 0; i < (entity.getPowered() ? 4 : 2); i++) {
                    entity.world.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState());
                    if (entity.world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.AIR && entity.world.getBlockState(new BlockPos(x, y + 1, z)).getBlock() == Blocks.AIR && entity.world.rand.nextInt(15) == 0) {
                        Class<? extends ITakumiEntity> clazz = TakumiEntityCore.getEntityList().get(entity.world.rand.nextInt(TakumiEntityCore.getEntityList().size())).getClass();
                        try {
                            Entity creeper = (Entity) clazz.getConstructor(World.class).newInstance(entity.world);
                            if (((ITakumiEntity) creeper).takumiRank() == EnumTakumiRank.LOW || ((ITakumiEntity) creeper).takumiRank() == EnumTakumiRank.MID) {
                                creeper.world = entity.world;
                                creeper.setPosition(x, y, z);
                                entity.world.spawnEntity(creeper);
                            }
                        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) TileEntity(net.minecraft.tileentity.TileEntity) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) BlockPos(net.minecraft.util.math.BlockPos) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 5 with ITakumiEntity

use of com.tntmodders.takumi.entity.ITakumiEntity in project takumicraft by TNTModders.

the class TakumiEvents method onKillEntity.

@SubscribeEvent
public void onKillEntity(LivingDeathEvent event) {
    if (!event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer && TakumiBlockCore.BOMB_MAP.containsKey(event.getEntityLiving().getClass()) && event.getEntityLiving().getRNG().nextInt(10) == 0) {
        event.getEntityLiving().dropItem(Item.getItemFromBlock(TakumiBlockCore.BOMB_MAP.get(event.getEntityLiving().getClass())), 1);
    }
    if (!event.getEntityLiving().world.isRemote) {
        Calendar calendar = event.getEntityLiving().world.getCurrentDate();
        int month = calendar.get(Calendar.MONTH) + 1;
        int date = calendar.get(Calendar.DATE);
        if (month == 12 && (date == 24 || date == 25)) {
            event.getEntityLiving().dropItem(Item.getItemFromBlock(Blocks.CHEST), 1);
        } else if (month == 1 && date < 8) {
            event.getEntityLiving().entityDropItem(new ItemStack(Items.SKULL, 1, 4).setStackDisplayName(TakumiUtils.takumiTranslate("takumicraft.newyear.item.name")), 0.1f);
        }
    }
    if (FMLCommonHandler.instance().getSide().isClient() && (event.getEntityLiving() instanceof ITakumiEntity || event.getEntityLiving() instanceof EntityCreeper) && event.getSource().getTrueSource() instanceof EntityPlayerMP) {
        boolean isOK = true;
        for (ITakumiEntity takumiEntity : TakumiEntityCore.getEntityList()) {
            if (!TakumiUtils.getAdvancementUnlocked(new ResourceLocation(TakumiCraftCore.MODID, "slay/slay_" + takumiEntity.getRegisterName())) && takumiEntity.getClass() != event.getEntityLiving().getClass()) {
                isOK = false;
                break;
            }
        }
        if (isOK && event.getSource().getTrueSource() instanceof EntityPlayerMP) {
            TakumiUtils.giveAdvancementImpossible((EntityPlayerMP) event.getSource().getTrueSource(), new ResourceLocation(TakumiCraftCore.MODID, "creeperbomb"), new ResourceLocation(TakumiCraftCore.MODID, "allcomplete"));
        }
    }
    if (event.getEntityLiving() instanceof ITakumiEntity && event.getEntityLiving() instanceof EntityLiving && ((EntityLiving) event.getEntityLiving()).getAttackTarget() instanceof EntityAttackBlock && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityAttackBlock entity = ((EntityAttackBlock) ((EntityLiving) event.getEntityLiving()).getAttackTarget());
        entity.setHealth(entity.getHealth() - ((ITakumiEntity) event.getEntityLiving()).takumiRank().getPoint());
        if (entity.getHealth() <= 0) {
            event.getEntityLiving().world.playerEntities.forEach(player -> player.sendMessage(new TextComponentTranslation("entity.attackblock.win")));
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityLiving(net.minecraft.entity.EntityLiving) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) Calendar(java.util.Calendar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)10 Entity (net.minecraft.entity.Entity)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 TakumiCraftCore (com.tntmodders.takumi.TakumiCraftCore)2 EntityKingCreeper (com.tntmodders.takumi.entity.mobs.boss.EntityKingCreeper)2 Material (net.minecraft.block.material.Material)2 IBlockState (net.minecraft.block.state.IBlockState)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 RenderAttackBlock (com.tntmodders.takumi.client.render.RenderAttackBlock)1 RenderDarkVillager (com.tntmodders.takumi.client.render.RenderDarkVillager)1 RenderLlamaCreeperSpit (com.tntmodders.takumi.client.render.RenderLlamaCreeperSpit)1 RenderTakumiTNTPrimed (com.tntmodders.takumi.client.render.RenderTakumiTNTPrimed)1 TakumiBlockCore (com.tntmodders.takumi.core.TakumiBlockCore)1 TakumiEntityCore (com.tntmodders.takumi.core.TakumiEntityCore)1 TakumiClientCore (com.tntmodders.takumi.core.client.TakumiClientCore)1