Java 类net.minecraft.block.BlockTNT 实例源码

项目:Cyclic    文件:BlockFireSafe.java   
private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
  int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);
  if (random.nextInt(chance) < i && worldIn.isAirBlock(pos)) {//safe fire: only set fire if air
    IBlockState iblockstate = worldIn.getBlockState(pos);
    if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) {
      int j = age + random.nextInt(5) / 4;
      if (j > 15) {
        j = 15;
      }
      worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
    }
    if (iblockstate.getBlock() == Blocks.TNT) {
      Blocks.TNT.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
    }
  }
}
项目:ZeroQuest    文件:BlockNileFire.java   
private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
    int k = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);

    if (random.nextInt(chance) < k) {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos)) {
            int l = age + random.nextInt(5) / 4;

            if (l > 15) {
                l = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(l)), 3);
        }
        else {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt) {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
项目:ZeroQuest    文件:BlockDarkFire.java   
private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
    int k = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);

    if (random.nextInt(chance) < k) {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos)) {
            int l = age + random.nextInt(5) / 4;

            if (l > 15) {
                l = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(l)), 3);
        }
        else {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt) {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
项目:AbyssalCraft    文件:BlockMimicFire.java   
private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face)
{
    int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
                j = 15;

            worldIn.setBlockState(pos, getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        } else
            worldIn.setBlockToAir(pos);

        if (iblockstate.getBlock() == Blocks.TNT)
            Blocks.TNT.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
    }
}
项目:IceAndShadow2    文件:NyxMaterialDevora.java   
@Override
public boolean onKnifeHit(EntityLivingBase user, IaSEntityKnifeBase knife, ChunkCoordinates block) {
    if (knife.worldObj.isRemote)
        return false;
    final Block bl = knife.worldObj.getBlock(block.posX, block.posY, block.posZ);
    final Explosion ex = knife.worldObj.createExplosion(user, knife.posX, knife.posY, knife.posZ, 0.3F, true);
    if (bl == NyxBlocks.oreDevora || bl instanceof BlockTNT) {
        bl.onBlockExploded(knife.worldObj, block.posX, block.posY, block.posZ, ex);
    }
    final List ents = knife.worldObj.getEntitiesWithinAABBExcludingEntity(knife,
            AxisAlignedBB.getBoundingBox(knife.posX - 2.5F, knife.posY - 3.0F, knife.posZ - 2.5F, knife.posX + 2.5F,
                    knife.posY + 2.0F, knife.posZ + 2.5F));
    for (final Object o : ents)
        if (o instanceof EntityLivingBase) {
            final EntityLivingBase elb = (EntityLivingBase) o;
            if (o instanceof EntityPlayer && !(user instanceof EntityPlayer)) {
                continue;
            }
            if (o instanceof EntityMob && user instanceof EntityMob) {
                continue;
            }
            elb.attackEntityFrom(DamageSource.causeThrownDamage((Entity) o, user), getBaseDamage());
        }
    knife.setDead();
    return false;
}
项目:QmunityLib    文件:RedstoneHelper.java   
public static boolean canConnectVanilla(World world, BlockPos pos, ForgeDirection side, ForgeDirection face) {

        if (side == ForgeDirection.UNKNOWN)
            return false;

        Block block = world.getBlock(pos.getX(), pos.getY(), pos.getZ());
        int meta = world.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ());
        int d = Direction.getMovementDirection(side.offsetX, side.offsetZ);

        if ((block == Blocks.unpowered_repeater || block == Blocks.powered_repeater)
                && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN))
            if (d % 2 == meta % 2)
                return true;

        if (block instanceof BlockLever) {
            meta = meta % 8;
            ForgeDirection leverFace = ((meta == 0 || meta == 7) ? ForgeDirection.UP : ((meta == 5 || meta == 6) ? ForgeDirection.DOWN
                    : (meta == 1 ? ForgeDirection.WEST : (meta == 2 ? ForgeDirection.EAST : (meta == 3 ? ForgeDirection.NORTH
                            : (meta == 4 ? ForgeDirection.SOUTH : ForgeDirection.UNKNOWN))))));
            if (face != ForgeDirection.UNKNOWN && face != leverFace)
                return false;
            return side != leverFace.getOpposite();
        }

        if (block instanceof BlockRedstoneComparator && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN))
            return side != ForgeDirection.UP;

        if (block instanceof BlockRedstoneWire)
            return face == ForgeDirection.UNKNOWN || face == ForgeDirection.DOWN;

        return block instanceof BlockDoor || block instanceof BlockRedstoneLight || block instanceof BlockTNT
                || block instanceof BlockDispenser || block instanceof BlockNote
                || block instanceof BlockPistonBase;// true;
    }
项目:QmunityLib    文件:RedstoneHelper.java   
private static boolean isVanillaBlock(World world, BlockPos pos) {

        Block b = world.getBlock(pos.getX(), pos.getY(), pos.getZ());
        return b instanceof BlockRedstoneRepeater || b instanceof BlockLever || b instanceof BlockRedstoneWire
                || b instanceof BlockRedstoneComparator || b instanceof BlockDoor || b instanceof BlockRedstoneLight
                || b instanceof BlockTNT || b instanceof BlockDispenser || b instanceof BlockNote
                || b instanceof BlockPistonBase;
    }
项目:FissionWarfare    文件:ExplosionUtil.java   
private static void processBlock(Location loc) {    

    if (loc.getBlock() instanceof BlockTNT) {

        EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc.world, (double)((float)loc.x + 0.5F), (double)((float)loc.y + 0.5F), (double)((float)loc.z + 0.5F), (EntityLivingBase)null);
           entitytntprimed.fuse = loc.world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
           loc.world.spawnEntityInWorld(entitytntprimed);
    }

    if (loc.getBlock() instanceof BlockExplosive) {

        ((BlockExplosive)loc.getBlock()).activate(loc.world, loc.x, loc.y, loc.z);          
    }

    else loc.setBlockToAir();       
}
项目:TaleCraft    文件:Invoke.java   
public static final void trigger(World world, BlockPos position, IBlockState state, EnumTriggerState state2) {
    Block block = state.getBlock();

    if(block instanceof TCITriggerableBlock){
        ((TCITriggerableBlock) state.getBlock()).trigger(world, position, state2);
        return;
    }

    if(block instanceof BlockCommandBlock) {
        ((TileEntityCommandBlock)world.getTileEntity(position)).getCommandBlockLogic().trigger(world);
        return;
    }

    // Just for the heck of it!
    if(block instanceof BlockTNT) {
        ((BlockTNT) block).explode(world, position, state.withProperty(BlockTNT.EXPLODE, Boolean.TRUE), null);
        world.setBlockToAir(position);
        return;
    }

    if(block instanceof BlockDispenser) {
        block.updateTick(world, position, state, TaleCraft.random);
        return;
    }

    if(block instanceof BlockDropper) {
        block.updateTick(world, position, state, TaleCraft.random);
        return;
    }

    // XXX: Experimental: This could break with any update.
    if(block instanceof BlockLever) {
        state = state.cycleProperty(BlockLever.POWERED);
        world.setBlockState(position, state, 3);
        world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, state.getValue(BlockLever.POWERED).booleanValue() ? 0.6F : 0.5F, false);
        world.notifyNeighborsOfStateChange(position, block, true);
        EnumFacing enumfacing1 = state.getValue(BlockLever.FACING).getFacing();
        world.notifyNeighborsOfStateChange(position.offset(enumfacing1.getOpposite()), block, true);
        return;
    }

    // XXX: Experimental: This could break with any update.
    if(block instanceof BlockButton) {
        world.setBlockState(position, state.withProperty(BlockButton.POWERED, Boolean.valueOf(true)), 3);
        world.markBlockRangeForRenderUpdate(position, position);
        world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F, false); //TODO There are multiple button click sounds
        world.notifyNeighborsOfStateChange(position, block, true);
        world.notifyNeighborsOfStateChange(position.offset(state.getValue(BlockDirectional.FACING).getOpposite()), block, true);
        world.scheduleUpdate(position, block, block.tickRate(world));
    }

    // XXX: Implement more vanilla triggers?
}