use of icbm.classic.content.entity.EntityBombCart in project ICBM-Classic by BuiltBrokenModding.
the class ItemDefuser method onLeftClickEntity.
/**
* Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if
* return value is true further processing is canceled and the entity is not attacked.
*
* @param itemStack The Item being used
* @param player The player that is attacking
* @param entity The entity being attacked
* @return True to cancel the rest of the interaction.
*/
@Override
public boolean onLeftClickEntity(ItemStack itemStack, EntityPlayer player, Entity entity) {
if (this.getEnergy(itemStack) >= ENERGY_COST) {
if (entity instanceof EntityExplosive) {
if (!entity.worldObj.isRemote) {
EntityExplosive entityTNT = (EntityExplosive) entity;
EntityItem entityItem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, new ItemStack(ICBMClassic.blockExplosive, 1, entityTNT.explosiveID.ordinal()));
float var13 = 0.05F;
Random random = new Random();
entityItem.motionX = ((float) random.nextGaussian() * var13);
entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
entityItem.motionZ = ((float) random.nextGaussian() * var13);
entity.worldObj.spawnEntityInWorld(entityItem);
}
entity.setDead();
} else if (entity instanceof EntityTNTPrimed) {
if (!entity.worldObj.isRemote) {
EntityItem entityItem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, new ItemStack(Blocks.tnt));
float var13 = 0.05F;
Random random = new Random();
entityItem.motionX = ((float) random.nextGaussian() * var13);
entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
entityItem.motionZ = ((float) random.nextGaussian() * var13);
entity.worldObj.spawnEntityInWorld(entityItem);
}
entity.setDead();
} else if (entity instanceof EntityBombCart) {
((EntityBombCart) entity).killMinecart(DamageSource.generic);
}
this.discharge(itemStack, ENERGY_COST, true);
return true;
} else {
player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("message.defuser.nopower")));
}
return false;
}
Aggregations