Search in sources :

Example 6 with TakumiExplosion

use of com.tntmodders.takumi.world.TakumiExplosion in project takumicraft by TNTModders.

the class EntityBangCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    float power = this.getPowered() ? 6f : 3f;
    if (event.getExplosion() instanceof TakumiExplosion) {
        power = ((TakumiExplosion) event.getExplosion()).getSize();
    }
    if (power > 0.5) {
        for (BlockPos pos : event.getAffectedBlocks()) {
            if (!this.world.isRemote && this.world.getBlockState(pos).getBlock().getExplosionResistance(world, pos, this, event.getExplosion()) >= Blocks.OBSIDIAN.getExplosionResistance(world, pos, this, event.getExplosion()) && TakumiUtils.takumiGetBlockResistance(this, this.world.getBlockState(pos), pos) != -1) {
                this.world.setBlockToAir(pos);
                TakumiUtils.takumiCreateExplosion(this.world, this, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, power - 0.2f, false, true);
            }
        }
    }
    return true;
}
Also used : TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) BlockPos(net.minecraft.util.math.BlockPos)

Example 7 with TakumiExplosion

use of com.tntmodders.takumi.world.TakumiExplosion in project takumicraft by TNTModders.

the class EntityBedCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    if (!this.world.isRemote) {
        if (event.getExplosion() instanceof TakumiExplosion) {
            event.getAffectedEntities().clear();
            event.getAffectedBlocks().forEach(pos -> {
                if (EntityBedCreeper.this.world.getTileEntity(pos) instanceof IInventory) {
                    ((IInventory) EntityBedCreeper.this.world.getTileEntity(pos)).clear();
                    EntityBedCreeper.this.world.setBlockToAir(pos);
                } else if (EntityBedCreeper.this.world.getBlockState(pos).getBlock().isBed(this.world.getBlockState(pos), this.world, pos, null)) {
                    EntityBedCreeper.this.world.setBlockToAir(pos);
                }
            });
        } else {
            event.getAffectedEntities().forEach(entity -> {
                if (entity instanceof EntityPlayer) {
                    BlockPos pos = ((EntityPlayer) entity).getBedLocation(this.world.provider.getDimension());
                    if (pos != null && this.world.getBlockState(pos).getBlock().isBed(this.world.getBlockState(pos), this.world, pos, entity)) {
                        TakumiUtils.takumiCreateExplosion(this.world, this, pos.getX(), pos.getY(), pos.getZ(), this.getPowered() ? 20 : 12, false, true);
                    }
                }
            });
        }
    }
    return true;
}
Also used : TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) IInventory(net.minecraft.inventory.IInventory) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with TakumiExplosion

use of com.tntmodders.takumi.world.TakumiExplosion in project takumicraft by TNTModders.

the class EntityWoodCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    float power = this.getPowered() ? 6f : 3f;
    if (event.getExplosion() instanceof TakumiExplosion) {
        power = ((TakumiExplosion) event.getExplosion()).getSize();
    }
    if (power > 0.1) {
        for (BlockPos pos : event.getAffectedBlocks()) {
            String s = this.world.getBlockState(pos).getBlock().getHarvestTool(this.world.getBlockState(pos));
            if (!this.world.isRemote && s != null && s.equalsIgnoreCase("axe") && TakumiUtils.takumiGetBlockResistance(this, this.world.getBlockState(pos), pos) != -1) {
                this.world.setBlockToAir(pos);
                TakumiUtils.takumiCreateExplosion(this.world, this, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, power - 0.1f, false, true);
            }
        }
    }
    return true;
}
Also used : TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) BlockPos(net.minecraft.util.math.BlockPos)

Example 9 with TakumiExplosion

use of com.tntmodders.takumi.world.TakumiExplosion in project takumicraft by TNTModders.

the class EntityStoneCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    float power = this.getPowered() ? 6f : 3f;
    if (event.getExplosion() instanceof TakumiExplosion) {
        power = ((TakumiExplosion) event.getExplosion()).getSize();
    }
    if (power > 0.1) {
        for (BlockPos pos : event.getAffectedBlocks()) {
            String s = this.world.getBlockState(pos).getBlock().getHarvestTool(this.world.getBlockState(pos));
            if (!this.world.isRemote && s != null && s.equalsIgnoreCase("pickaxe") && TakumiUtils.takumiGetBlockResistance(this, this.world.getBlockState(pos), pos) != -1) {
                this.world.setBlockToAir(pos);
                TakumiUtils.takumiCreateExplosion(this.world, this, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, power - 0.2f, false, true);
            }
        }
    }
    return true;
}
Also used : TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

TakumiExplosion (com.tntmodders.takumi.world.TakumiExplosion)9 BlockPos (net.minecraft.util.math.BlockPos)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 IBlockState (net.minecraft.block.state.IBlockState)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 IInventory (net.minecraft.inventory.IInventory)2 PotionEffect (net.minecraft.potion.PotionEffect)2 ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 Ingredient (net.minecraft.item.crafting.Ingredient)1 SPacketExplosion (net.minecraft.network.play.server.SPacketExplosion)1 PotionType (net.minecraft.potion.PotionType)1 WorldServer (net.minecraft.world.WorldServer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1