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;
}
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;
}
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);
}
}
}
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();
}
}
}
}
}
}
}
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")));
}
}
}
Aggregations