Search in sources :

Example 1 with ExplosivePreDetonationEvent

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);
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) EntityZombie(net.minecraft.entity.monster.EntityZombie) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPig(net.minecraft.entity.passive.EntityPig) EntityPigZombie(net.minecraft.entity.monster.EntityPigZombie) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 2 with ExplosivePreDetonationEvent

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();
}
Also used : ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Example 3 with ExplosivePreDetonationEvent

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."));
        }
    }
}
Also used : ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) EntityGrenade(icbm.classic.content.entity.EntityGrenade) Explosives(icbm.classic.content.explosive.Explosives) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 4 with ExplosivePreDetonationEvent

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;
}
Also used : Explosive(icbm.classic.content.explosive.Explosive) ItemBlockExplosive(icbm.classic.content.explosive.tile.ItemBlockExplosive) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 5 with ExplosivePreDetonationEvent

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;
}
Also used : Explosion(icbm.classic.content.explosive.ex.Explosion) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Explosives(icbm.classic.content.explosive.Explosives) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) EntityMissile(icbm.classic.content.entity.EntityMissile)

Aggregations

ExplosivePreDetonationEvent (resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent)7 Pos (com.builtbroken.mc.imp.transform.vector.Pos)4 Explosives (icbm.classic.content.explosive.Explosives)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 TileEntity (net.minecraft.tileentity.TileEntity)2 RenderBombBlock (icbm.classic.client.render.tile.RenderBombBlock)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1 EntityGrenade (icbm.classic.content.entity.EntityGrenade)1 EntityMissile (icbm.classic.content.entity.EntityMissile)1 Explosive (icbm.classic.content.explosive.Explosive)1 Explosion (icbm.classic.content.explosive.ex.Explosion)1 ItemBlockExplosive (icbm.classic.content.explosive.tile.ItemBlockExplosive)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)1 EntityZombie (net.minecraft.entity.monster.EntityZombie)1 EntityPig (net.minecraft.entity.passive.EntityPig)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1