本文整理汇总了Java中net.minecraft.block.Block.isAir方法的典型用法代码示例。如果您正苦于以下问题:Java Block.isAir方法的具体用法?Java Block.isAir怎么用?Java Block.isAir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.Block
的用法示例。
在下文中一共展示了Block.isAir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isBlockValidForFilter
import net.minecraft.block.Block; //导入方法依赖的package包/类
public static boolean isBlockValidForFilter(IBlockAccess worldCache, IDroneBase drone, BlockPos pos, ProgWidgetAreaItemBase widget) {
IBlockState blockState = worldCache.getBlockState(pos);
Block block = blockState.getBlock();
if (!block.isAir(blockState, worldCache, pos)) {
NonNullList<ItemStack> droppedStacks = NonNullList.create();
if (block.canSilkHarvest(drone.world(), pos, blockState, drone.getFakePlayer())) {
droppedStacks.add(getSilkTouchBlock(block, blockState));
} else {
block.getDrops(droppedStacks, drone.world(), pos, blockState, 0);
}
for (ItemStack droppedStack : droppedStacks) {
if (widget.isItemValidForFilters(droppedStack, blockState)) {
return true;
}
}
}
return false;
}
示例2: canPlantStay
import net.minecraft.block.Block; //导入方法依赖的package包/类
public static boolean canPlantStay(World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
if (block.isAir(world, x, y - 1, z)) {
int adjecentCount = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (adjecentBlock == ModBlocks.chorus_plant)
adjecentCount++;
else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
return false;
}
return adjecentCount == 1;
} else
return false;
} else
return true;
}
示例3: breakBlocks
import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean breakBlocks(){
boolean flag = false;
AxisAlignedBB box=this.getBreakingBB();
for (int x = MathHelper.floor(box.minX); x <= MathHelper.floor(box.maxX); ++x)
for (int y = MathHelper.floor(box.minY); y <= MathHelper.floor(box.maxY); ++y)
for (int z = MathHelper.floor(box.minZ); z <= MathHelper.floor(box.maxZ); ++z) {
BlockPos blockpos = new BlockPos(x, y, z);
IBlockState iblockstate = this.world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (!block.isAir(iblockstate, this.world, blockpos) && !iblockstate.getMaterial().isLiquid()
&& EntityWither.canDestroyBlock(block)
&& block.canEntityDestroy(iblockstate, world, blockpos, this))
flag = this.world.destroyBlock(blockpos, true) || flag;
}
if (flag)
this.world.playEvent((EntityPlayer) null, 1022, new BlockPos(this), 0);
return flag;
}
示例4: destroyBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
/**
* Sets a block to air, but also plays the sound and particles and can spawn drops
*/
public boolean destroyBlock(BlockPos pos, boolean dropBlock)
{
IBlockState iblockstate = this.getBlockState(pos);
Block block = iblockstate.getBlock();
if (block.isAir(iblockstate, this, pos))
{
return false;
}
else
{
this.playEvent(2001, pos, Block.getStateId(iblockstate));
if (dropBlock)
{
block.dropBlockAsItem(this, pos, iblockstate, 0);
}
return this.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
}
}
示例5: isValid
import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean isValid(World world, long pos) {
if (pos == -1L) {
return false;
}
BlockPos p = BlockPos.fromLong(pos);
IBlockState state = world.getBlockState(p);
Block block = state.getBlock();
if (Config.getBlocksBlocking().contains(block.getRegistryName())) {
// Special case for doors
if (block instanceof BlockDoor) {
return state.getValue(BlockDoor.OPEN);
}
if (block instanceof BlockTrapDoor) {
return state.getValue(BlockTrapDoor.OPEN);
}
return false;
}
if (Config.getBlocksNonBlocking().contains(block.getRegistryName())) {
return true;
}
if (block.isAir(state, world, p)) {
return true;
} else {
AxisAlignedBB box = state.getCollisionBoundingBox(world, p);
if (box == null) {
return true;
}
return !block.isOpaqueCube(state);
}
}
示例6: isReplaceable
import net.minecraft.block.Block; //导入方法依赖的package包/类
protected boolean isReplaceable(World world, int x, int y, int z) {
IBlockState state = world.getBlockState(new BlockPos(x, y, z));
Block block = state.getBlock();
return (block.isAir(state, world, new BlockPos(x, y, z))) || (block.isLeaves(state, world, new BlockPos(x, y, z))) || (block.isWood(world, new BlockPos(x, y, z))) || (func_150523_a(block));
}
示例7: breakBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void breakBlock(EnumFacing facing) {
BlockPos newPos = pos.offset(facing, 1);
IBlockState state = this.world.getBlockState(newPos);
Block block = state.getBlock();
if (!block.isAir(state, this.world, newPos) && block.getBlockHardness(state, this.world, newPos) >= 0
&& !(block instanceof BlockDynamicLiquid) && !(block instanceof BlockStaticLiquid)) {
// Creates a fake player which will berak the block
EntityPlayer player = new EntityPlayer(world, new GameProfile(null, "BlockBreaker")) {
@Override
public boolean isSpectator() {
return true;
}
@Override
public boolean isCreative() {
return false;
}
};
List<ItemStack> drops = new ArrayList<ItemStack>();
boolean customDrops = false;
if (this.handler.getStackInSlot(9).getItem() == Items.ENCHANTED_BOOK) {
ItemStack enchantedBook = this.handler.getStackInSlot(9);
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(enchantedBook);
if (enchantments.containsKey(Enchantments.FORTUNE)) {
int fortune = enchantments.get(Enchantments.FORTUNE);
drops.add(new ItemStack(block.getItemDropped(state, this.random, fortune),
block.quantityDroppedWithBonus(fortune, this.random), block.damageDropped(state)));
customDrops = true;
}
if (enchantments.containsKey(Enchantments.SILK_TOUCH)
&& block.canSilkHarvest(world, newPos, state, player)) {
// HARD FIX FOR LAPIS
if (block == Blocks.LAPIS_ORE)
drops.add(new ItemStack(block, 1));
else
drops.add(new ItemStack(block, 1, block.damageDropped(state)));
customDrops = true;
}
}
if (!customDrops)
drops = block.getDrops(world, newPos, state, 0);
for (ItemStack stack : drops) {
Utils.addStackToInventory(this.handler, 9, stack, false);
}
if (!Utils.isInventoryFull(this.handler, 9)) {
this.world.playEvent(2001, pos, Block.getStateId(state));
this.world.playSound(null, pos, block.getSoundType(state, world, newPos, player).getBreakSound(),
SoundCategory.BLOCKS, 1, 1);
this.world.setBlockToAir(newPos);
if (block == Blocks.ICE)
this.world.setBlockState(newPos, Blocks.FLOWING_WATER.getDefaultState());
}
}
}
示例8: updateTick
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if (world.isRemote)
return;
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 5)
return;
if (!canBlockStay(world, x, y, z))
world.func_147480_a(x, y, z, true);
else if (world.isAirBlock(x, y + 1, z)) {
boolean canGrowUp = false;
boolean isSegmentOnEndstone = false;
Block lowerBlock = world.getBlock(x, y - 1, z);
if (lowerBlock == Blocks.end_stone)
canGrowUp = true;
else if (lowerBlock == ModBlocks.chorus_plant) {
int par8 = 1;
int height;
for (height = 0; height < 4; height++) {
Block b = world.getBlock(x, y - (par8 + 1), z);
if (b != ModBlocks.chorus_plant) {
if (b == Blocks.end_stone)
isSegmentOnEndstone = true;
break;
}
par8++;
}
height = 4;
if (isSegmentOnEndstone)
height++;
if (par8 < 2 || rand.nextInt(height) >= par8)
canGrowUp = true;
} else if (lowerBlock.isAir(world, x, y - 1, z))
canGrowUp = true;
if (canGrowUp && isSpaceAroundFree(world, x, y + 1, z, ForgeDirection.DOWN) && world.isAirBlock(x, y + 2, z)) {
world.setBlock(x, y, z, ModBlocks.chorus_plant);
world.setBlock(x, y + 1, z, this, meta, 3);
} else if (meta < 4) {
int tries = rand.nextInt(4);
boolean grew = false;
if (isSegmentOnEndstone)
tries++;
for (int i = 0; i < tries; i++) {
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[rand.nextInt(ForgeDirection.VALID_DIRECTIONS.length)];
int xx = x + dir.offsetX;
int yy = y + dir.offsetY;
int zz = z + dir.offsetZ;
if (world.isAirBlock(xx, yy, zz) && isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) {
world.setBlock(xx, yy, zz, this, meta + 1, 3);
grew = true;
}
}
if (grew)
world.setBlock(x, y, z, ModBlocks.chorus_plant, 0, 3);
else
world.setBlock(x, y, z, this, 5, 3);
} else if (meta == 4)
world.setBlock(x, y, z, this, 5, 3);
}
}
示例9: damageBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
public static float damageBlock(BlockPos pos, EntityLivingBase living, World world, float damage) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block.isAir(state, world, pos) || state.getMaterial() == Material.WATER || state.getMaterial() == Material.LAVA || state.getBlockHardness(world, pos) < 0)
return damage;
DestroyBlockEntry finalEntry = null;
int entryId = 0;
int emptyId = -1;
for (int i = 0; i < BlockEventBus.destroyProgress.size(); i++) {
DestroyBlockEntry entry = BlockEventBus.destroyProgress.get(i);
if (emptyId == -1 && entry == null)
emptyId = i;
if (entry != null && entry.world == world && entry.pos.equals(pos)) {
finalEntry = entry;
entryId = i;
break;
}
}
if (finalEntry == null) {
finalEntry = new DestroyBlockEntry(pos, world);
if (emptyId != -1) {
BlockEventBus.destroyProgress.set(emptyId, finalEntry);
entryId = emptyId;
} else {
BlockEventBus.destroyProgress.add(finalEntry);
entryId = BlockEventBus.destroyProgress.size() - 1;
}
}
/*if (block instanceof BlockChest) {
((TileEntityChest) world.getTileEntity(pos)).setLootTable(LootTableList.CHESTS_NETHER_BRIDGE, living.getRNG().nextLong());
}*/
float hardness = BlockLauncher.getHardness(state, world);
finalEntry.curDamage += damage;
if (living != null)
world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, (int) ((finalEntry.curDamage / hardness) * 10));
if (finalEntry.curDamage >= hardness) {
if (living != null && living instanceof EntityPlayer)
block.harvestBlock(world, (EntityPlayer) living, pos, state, null, ItemStack.EMPTY);
else {
block.dropBlockAsItem(world, pos, state, 0);
}
BlockEventBus.destroyProgress.remove(finalEntry);
boolean flag = (living == null || !(living instanceof EntityPlayer) && world.isAirBlock(pos)) || block.removedByPlayer(state, world, pos, (EntityPlayer) living, true);
if (flag) {
if (living != null) {
world.playEvent(2001, pos, Block.getStateId(state));
world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, -1);
}
block.onBlockDestroyedByPlayer(world, pos, state);
}
return finalEntry.curDamage - hardness;
}
return 0;
}
示例10: damageBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
public static float damageBlock(BlockPos pos, EntityLivingBase living, World world, ItemStack stack, int critical, float damage, Vec3d forwardVec, Explosion explosion) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block.isAir(state, world, pos) || TF2ConfigVars.destTerrain == 0 || state.getBlockHardness(world, pos) < 0 ||
(!(living instanceof EntityPlayer) && !world.getGameRules().getBoolean("mobGriefing")) || (living instanceof EntityPlayer && !world.isBlockModifiable((EntityPlayer) living, pos)))
return 0;
DestroyBlockEntry finalEntry = null;
int entryId = 0;
int emptyId = -1;
for (int i = 0; i < TF2EventsCommon.destroyProgress.size(); i++) {
DestroyBlockEntry entry = TF2EventsCommon.destroyProgress.get(i);
if (emptyId == -1 && entry == null)
emptyId = i;
if (entry != null && entry.world == world && entry.pos.equals(pos)) {
finalEntry = entry;
entryId = i;
break;
}
}
if (finalEntry == null) {
finalEntry = new DestroyBlockEntry(pos, world);
if (emptyId != -1) {
TF2EventsCommon.destroyProgress.set(emptyId, finalEntry);
entryId = emptyId;
} else {
TF2EventsCommon.destroyProgress.add(finalEntry);
entryId = TF2EventsCommon.destroyProgress.size() - 1;
}
}
/*if (block instanceof BlockChest) {
((TileEntityChest) world.getTileEntity(pos)).setLootTable(LootTableList.CHESTS_NETHER_BRIDGE, living.getRNG().nextLong());
}*/
float hardness = TF2Util.getHardness(state, world, pos);
if (!stack.isEmpty() && stack.getItem() instanceof ItemSniperRifle && hardness > 100)
damage *= 3;
finalEntry.curDamage += damage;
if (living != null)
world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, (int) ((finalEntry.curDamage / hardness) * 10));
if (finalEntry.curDamage >= hardness) {
if (living != null && living instanceof EntityPlayer)
block.harvestBlock(world, (EntityPlayer) living, pos, state, null, stack);
else {
block.dropBlockAsItem(world, pos, state, 0);
block.onBlockExploded(world, pos, explosion);
}
TF2EventsCommon.destroyProgress.remove(finalEntry);
boolean flag = (living == null || !(living instanceof EntityPlayer) && world.isAirBlock(pos)) || block.removedByPlayer(state, world, pos, (EntityPlayer) living, true);
if (flag) {
if (living != null) {
world.playEvent(2001, pos, Block.getStateId(state));
world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, -1);
}
block.onBlockDestroyedByPlayer(world, pos, state);
if (forwardVec != null) {
RayTraceResult trace = world.rayTraceBlocks(living.getPositionVector().addVector(0, living.getEyeHeight(), 0), forwardVec, false, true, false);
if (trace != null)
damageBlock(trace.getBlockPos(), living, world, stack, critical, finalEntry.curDamage - hardness, forwardVec, explosion);
}
}
return finalEntry.curDamage - hardness;
}
return 0;
}
示例11: destroyBlocksInAABB
import net.minecraft.block.Block; //导入方法依赖的package包/类
/**
* Destroys all blocks that aren't associated with 'The End' inside the given bounding box.
*/
private boolean destroyBlocksInAABB(AxisAlignedBB p_70972_1_)
{
int i = MathHelper.floor_double(p_70972_1_.minX);
int j = MathHelper.floor_double(p_70972_1_.minY);
int k = MathHelper.floor_double(p_70972_1_.minZ);
int l = MathHelper.floor_double(p_70972_1_.maxX);
int i1 = MathHelper.floor_double(p_70972_1_.maxY);
int j1 = MathHelper.floor_double(p_70972_1_.maxZ);
boolean flag = false;
boolean flag1 = false;
for (int k1 = i; k1 <= l; ++k1)
{
for (int l1 = j; l1 <= i1; ++l1)
{
for (int i2 = k; i2 <= j1; ++i2)
{
BlockPos blockpos = new BlockPos(k1, l1, i2);
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (!block.isAir(iblockstate, this.worldObj, blockpos) && iblockstate.getMaterial() != Material.FIRE)
{
if (!this.worldObj.getGameRules().getBoolean("mobGriefing"))
{
flag = true;
}
else if (block.canEntityDestroy(iblockstate, this.worldObj, blockpos, this))
{
if (block != Blocks.COMMAND_BLOCK && block != Blocks.REPEATING_COMMAND_BLOCK && block != Blocks.CHAIN_COMMAND_BLOCK && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY)
{
flag1 = this.worldObj.setBlockToAir(blockpos) || flag1;
}
else
{
flag = true;
}
}
else
{
flag = true;
}
}
}
}
}
if (flag1)
{
double d0 = p_70972_1_.minX + (p_70972_1_.maxX - p_70972_1_.minX) * (double)this.rand.nextFloat();
double d1 = p_70972_1_.minY + (p_70972_1_.maxY - p_70972_1_.minY) * (double)this.rand.nextFloat();
double d2 = p_70972_1_.minZ + (p_70972_1_.maxZ - p_70972_1_.minZ) * (double)this.rand.nextFloat();
this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
return flag;
}
示例12: updateBlockRemoving
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void updateBlockRemoving()
{
++this.curblockDamage;
if (this.receivedFinishDiggingPacket)
{
int i = this.curblockDamage - this.initialBlockDamage;
IBlockState iblockstate = this.theWorld.getBlockState(this.delayedDestroyPos);
Block block = iblockstate.getBlock();
if (block.isAir(iblockstate, theWorld, delayedDestroyPos))
{
this.receivedFinishDiggingPacket = false;
}
else
{
float f = iblockstate.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.delayedDestroyPos) * (float)(i + 1);
int j = (int)(f * 10.0F);
if (j != this.durabilityRemainingOnBlock)
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.delayedDestroyPos, j);
this.durabilityRemainingOnBlock = j;
}
if (f >= 1.0F)
{
this.receivedFinishDiggingPacket = false;
this.tryHarvestBlock(this.delayedDestroyPos);
}
}
}
else if (this.isDestroyingBlock)
{
IBlockState iblockstate1 = this.theWorld.getBlockState(this.destroyPos);
Block block1 = iblockstate1.getBlock();
if (block1.isAir(iblockstate1, theWorld, destroyPos))
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.destroyPos, -1);
this.durabilityRemainingOnBlock = -1;
this.isDestroyingBlock = false;
}
else
{
int k = this.curblockDamage - this.initialDamage;
float f1 = iblockstate1.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.destroyPos) * (float)(k + 1); // Forge: Fix network break progress using wrong position
int l = (int)(f1 * 10.0F);
if (l != this.durabilityRemainingOnBlock)
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.destroyPos, l);
this.durabilityRemainingOnBlock = l;
}
}
}
}