use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class PoisonContagion method performEffect.
@Override
public void performEffect(EntityLivingBase entityLiving, int amplifier) {
if (!(entityLiving instanceof EntityZombie) && !(entityLiving instanceof EntityPigZombie)) {
entityLiving.attackEntityFrom(DamageSource.magic, 1);
}
if (entityLiving.worldObj.rand.nextFloat() > 0.8) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(entityLiving.worldObj, entityLiving.posX, entityLiving.posY, entityLiving.posZ, ExplosiveType.ALL, Explosives.CHEMICAL.handler);
MinecraftForge.EVENT_BUS.post(evt);
// Poison things around it
if (!evt.isCanceled()) {
int r = 13;
AxisAlignedBB entitySurroundings = AxisAlignedBB.getBoundingBox(entityLiving.posX - r, entityLiving.posY - r, entityLiving.posZ - r, entityLiving.posX + r, entityLiving.posY + r, entityLiving.posZ + r);
List<EntityLivingBase> entities = entityLiving.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entitySurroundings);
for (EntityLivingBase entity : entities) {
if (entity != null && entity != entityLiving) {
if (entity instanceof EntityPig) {
EntityPigZombie newEntity = new EntityPigZombie(entity.worldObj);
newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (!entity.worldObj.isRemote) {
entity.worldObj.spawnEntityInWorld(newEntity);
}
entity.setDead();
} else if (entity instanceof EntityVillager) {
EntityZombie newEntity = new EntityZombie(entity.worldObj);
newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
newEntity.setVillager(true);
if (!entity.worldObj.isRemote) {
entity.worldObj.spawnEntityInWorld(newEntity);
}
entity.setDead();
}
ICBMClassic.contagios_potion.poisonEntity(new Pos(entity), entity);
}
}
}
}
}
use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class EntityExplosive method onUpdate.
/** Called to update the entity's position/logic. */
@Override
public void onUpdate() {
if (!this.worldObj.isRemote) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(worldObj, posX, posY, posZ, ExplosiveType.BLOCK, explosiveID.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (evt.isCanceled()) {
ICBMClassic.blockExplosive.dropBlockAsItem(this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, this.explosiveID.ordinal(), 0);
this.setDead();
return;
}
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionX *= 0.95;
this.motionY -= 0.045D;
this.motionZ *= 0.95;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.fuse < 1) {
this.explode();
} else {
this.explosiveID.handler.onYinZha(this.worldObj, new Pos(this.posX, this.posY, this.posZ), this.fuse);
}
this.fuse--;
super.onUpdate();
}
use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class ItemGrenade method onPlayerStoppedUsing.
@Override
public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer entityPlayer, int nengLiang) {
if (!world.isRemote) {
Explosives zhaPin = Explosives.get(itemStack.getItemDamage());
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, entityPlayer, ExplosiveType.ITEM, zhaPin.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
if (!entityPlayer.capabilities.isCreativeMode) {
itemStack.stackSize--;
if (itemStack.stackSize <= 0) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
}
}
world.playSoundAtEntity(entityPlayer, "random.fuse", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
world.spawnEntityInWorld(new EntityGrenade(world, entityPlayer, zhaPin, (float) (this.getMaxItemUseDuration(itemStack) - nengLiang) / (float) this.getMaxItemUseDuration(itemStack)));
} else {
entityPlayer.addChatMessage(new ChatComponentText("Grenades are banned in this region."));
}
}
}
use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class ItemGrenade method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
if (itemStack != null) {
Explosive zhaPin = Explosives.get(itemStack.getItemDamage()).handler;
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, entityPlayer, ExplosiveType.ITEM, zhaPin);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
entityPlayer.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
} else {
entityPlayer.addChatMessage(new ChatComponentText("Grenades are banned in this region."));
}
}
return itemStack;
}
use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class ItemRocketLauncher method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote) {
long clickMs = System.currentTimeMillis();
if (clickTimePlayer.containsKey(player.getCommandSenderName())) {
if (clickMs - clickTimePlayer.get(player.getCommandSenderName()) < firingDelay) {
//TODO play weapon empty click audio to note the gun is reloading
return itemStack;
}
}
if (this.getEnergy(itemStack) >= ENERGY || player.capabilities.isCreativeMode) {
// Check the player's inventory and look for missiles.
for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
if (inventoryStack != null) {
if (inventoryStack.getItem() instanceof ItemMissile) {
int meta = inventoryStack.getItemDamage();
Explosives ex = Explosives.get(meta);
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, player.posX, player.posY, player.posZ, ExplosiveType.AIR, Explosives.get(meta).handler);
MinecraftForge.EVENT_BUS.post(evt);
if (((Explosion) ex.handler) != null && !evt.isCanceled()) {
// Limit the missile to tier two.
if ((((Explosion) ex.handler).getTier() <= Settings.MAX_ROCKET_LAUCNHER_TIER || Engine.runningAsDev) && ((Explosion) ex.handler).isCruise()) {
EntityMissile entityMissile = new EntityMissile(player);
entityMissile.missileType = EntityMissile.MissileType.LAUNCHER;
entityMissile.explosiveID = ex;
entityMissile.acceleration = 1;
entityMissile.launch(null);
world.spawnEntityInWorld(entityMissile);
if (player.isSneaking()) {
player.mountEntity(entityMissile);
player.setSneaking(false);
}
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(slot, null);
player.inventoryContainer.detectAndSendChanges();
this.discharge(itemStack, ENERGY, true);
}
//Store last time player launched a rocket
clickTimePlayer.put(player.getCommandSenderName(), clickMs);
return itemStack;
}
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("message.launcher.protected")));
}
}
}
}
}
}
return itemStack;
}
Aggregations