当前位置: 首页>>代码示例>>Java>>正文


Java BlockTNT类代码示例

本文整理汇总了Java中net.minecraft.block.BlockTNT的典型用法代码示例。如果您正苦于以下问题:Java BlockTNT类的具体用法?Java BlockTNT怎么用?Java BlockTNT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockTNT类属于net.minecraft.block包,在下文中一共展示了BlockTNT类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryCatchFire

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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)));
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:17,代码来源:BlockFireSafe.java

示例2: tryCatchFire

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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)));
		}
	}
}
 
开发者ID:NovaViper,项目名称:ZeroQuest,代码行数:25,代码来源:BlockNileFire.java

示例3: tryCatchFire

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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)));
	}
}
 
开发者ID:Shinoow,项目名称:AbyssalCraft,代码行数:24,代码来源:BlockMimicFire.java

示例4: onKnifeHit

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
@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;
}
 
开发者ID:TheDaemoness,项目名称:IceAndShadow2,代码行数:27,代码来源:NyxMaterialDevora.java

示例5: canConnectVanilla

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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;
    }
 
开发者ID:Qmunity,项目名称:QmunityLib,代码行数:35,代码来源:RedstoneHelper.java

示例6: isVanillaBlock

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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;
    }
 
开发者ID:Qmunity,项目名称:QmunityLib,代码行数:9,代码来源:RedstoneHelper.java

示例7: processBlock

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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();		
}
 
开发者ID:TeamMonumental,项目名称:FissionWarfare,代码行数:17,代码来源:ExplosionUtil.java

示例8: trigger

import net.minecraft.block.BlockTNT; //导入依赖的package包/类
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?
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:54,代码来源:Invoke.java


注:本文中的net.minecraft.block.BlockTNT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。