本文整理汇总了Java中net.minecraft.world.World.isAirBlock方法的典型用法代码示例。如果您正苦于以下问题:Java World.isAirBlock方法的具体用法?Java World.isAirBlock怎么用?Java World.isAirBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.isAirBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findPosY
import net.minecraft.world.World; //导入方法依赖的package包/类
private static int findPosY(World world, BlockPos pos) {
BlockPos checkPos = new BlockPos(pos.getX(), 120, pos.getZ());
int airBlocks = 0;
for (int yOffset = 1; yOffset <= 88; yOffset++) {
if (world.isAirBlock(checkPos.down(yOffset))) {
airBlocks++;
} else {
if (airBlocks > 20) {
return 120 - yOffset;
}
airBlocks = 0;
}
}
return -1;
}
示例2: harvestAndPickup
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean harvestAndPickup(BlockPos pos) {
World world = entity.getEntityWorld();
if (world.isAirBlock(pos)) {
return true;
}
IBlockState state = world.getBlockState(pos);
if (!allowedToHarvest(state, world, pos, GeneralTools.getHarvester())) {
return false;
}
Block block = state.getBlock();
List<ItemStack> drops = block.getDrops(world, pos, state, 0);
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1.0f, false, GeneralTools.getHarvester());
SoundTools.playSound(world, block.getSoundType().getBreakSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
block.onBlockHarvested(world, pos, state, GeneralTools.getHarvester());
entity.getEntityWorld().setBlockToAir(pos);
giveDropsToMeeCreeps(drops);
return true;
}
示例3: trySpread
import net.minecraft.world.World; //导入方法依赖的package包/类
private void trySpread(World world, BlockPos pos) {
for (EnumFacing face : EnumFacing.HORIZONTALS) {
BlockPos looppos = pos.offset(face);
if (world.getLightFor(EnumSkyBlock.BLOCK, looppos) > 5) continue;
if (world.isAirBlock(looppos) && (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT || world.getBlockState(looppos.down()).getBlock() == Blocks.FARMLAND)) {
if (world.rand.nextInt(2) == 0) {
if (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT)
world.setBlockState(looppos.down(), Blocks.FARMLAND.getDefaultState(), 3);
else
world.setBlockState(looppos, UCBlocks.cropDevilsnare.getDefaultState(), 3);
break;
}
}
}
}
示例4: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 10; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(blockpos))
{
int j = 1 + rand.nextInt(rand.nextInt(3) + 1);
for (int k = 0; k < j; ++k)
{
if (Blocks.CACTUS.canBlockStay(worldIn, blockpos))
{
worldIn.setBlockState(blockpos.up(k), Blocks.CACTUS.getDefaultState(), 2);
}
}
}
}
return true;
}
示例5: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(blockpos) && Blocks.deadbush.canBlockStay(worldIn, blockpos, Blocks.deadbush.getDefaultState()))
{
worldIn.setBlockState(blockpos, Blocks.deadbush.getDefaultState(), 2);
}
}
return true;
}
示例6: safeImpact
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
Random rand = world.rand;
int box = 1 + (int) ((float) amplifier / 2F);
BlockPos posI = pos.add(box, box, box);
BlockPos posF = pos.add(-box, -box, -box);
Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
for (BlockPos spot : spots) {
IBlockState state = world.getBlockState(spot);
boolean place = amplifier > 2 || world.rand.nextInt(3) == 0;
if (place && state.getBlock() == Blocks.GRASS && world.isAirBlock(spot.up())) {
world.getBiome(pos).plantFlower(world, rand, spot.up());
}
}
}
示例7: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES) && position.getY() > 0; iblockstate = worldIn.getBlockState(position))
{
position = position.down();
}
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(blockpos) && Blocks.DEADBUSH.canBlockStay(worldIn, blockpos, Blocks.DEADBUSH.getDefaultState()))
{
worldIn.setBlockState(blockpos, Blocks.DEADBUSH.getDefaultState(), 2);
}
}
return true;
}
示例8: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (int i = 0; i < 64; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(blockpos) && worldIn.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS && Blocks.PUMPKIN.canPlaceBlockAt(worldIn, blockpos))
{
worldIn.setBlockState(blockpos, Blocks.PUMPKIN.getDefaultState().withProperty(BlockPumpkin.FACING, EnumFacing.Plane.HORIZONTAL.random(rand)), 2);
}
}
return true;
}
示例9: clearCurrentPositionBlocksUpwards
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Deletes all continuous blocks from selected position upwards. Stops at hitting air.
*/
protected void clearCurrentPositionBlocksUpwards(World worldIn, int x, int y, int z, StructureBoundingBox structurebb)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (structurebb.isVecInside(blockpos))
{
while (!worldIn.isAirBlock(blockpos) && blockpos.getY() < 255)
{
worldIn.setBlockState(blockpos, Blocks.air.getDefaultState(), 2);
blockpos = blockpos.up();
}
}
}
示例10: doPlacementChecks
import net.minecraft.world.World; //导入方法依赖的package包/类
public void doPlacementChecks(IBlockAccess world, BlockPos pos)
{
if (world instanceof World)
{
World w = (World) world;
if (!Helpers.canPlantGrow(pos.up(), w))
{
this.breakReplaceSelf(w, pos);
return;
}
if (w.isAirBlock(pos.down()) || !w.getBlockState(pos.down()).isSideSolid(w, pos.down(), EnumFacing.UP))
{
this.breakReplaceSelf(w, pos);
return;
}
if (w.getBlockState(pos.up()).getMaterial() != Material.WATER)
{
this.breakReplaceSelf(w, pos);
return;
}
if (w.getBlockState(pos.up()).getBlock() instanceof IWater && ((IWater)w.getBlockState(pos.up()).getBlock()).isSalt(w, pos.up()))
{
this.breakReplaceSelf(w, pos);
}
}
}
示例11: findTopSpotNotDiggedYet
import net.minecraft.world.World; //导入方法依赖的package包/类
private BlockPos findTopSpotNotDiggedYet() {
IMeeCreep entity = helper.getMeeCreep();
BlockPos p = options.getTargetPos();
World world = entity.getWorld();
IBlockState state = world.getBlockState(p);
while (p.getY() > 0 && (world.isAirBlock(p) || state.getBlock() == Blocks.LADDER)) {
p = p.down();
state = world.getBlockState(p);
}
return p;
}
示例12: makePortalPair
import net.minecraft.world.World; //导入方法依赖的package包/类
public static void makePortalPair(World sourceWorld, BlockPos selectedBlock, EnumFacing selectedSide, TeleportDestination dest) {
BlockPos sourcePortalPos = findBestPosition(sourceWorld, selectedBlock, selectedSide);
if (sourcePortalPos == null) {
return;
}
World destWorld = mcjty.lib.varia.TeleportationTools.getWorldForDimension(dest.getDimension());
if (destWorld.getBlockState(dest.getPos()).getBlock() == ModBlocks.portalBlock) {
return;
}
if (dest.getSide() == EnumFacing.DOWN) {
if (!destWorld.isAirBlock(dest.getPos()) || !destWorld.isAirBlock(dest.getPos().down())) {
return;
}
} else {
if (!destWorld.isAirBlock(dest.getPos()) || !destWorld.isAirBlock(dest.getPos().up())) {
return;
}
}
sourceWorld.setBlockState(sourcePortalPos, ModBlocks.portalBlock.getDefaultState(), 3);
PortalTileEntity source = (PortalTileEntity) sourceWorld.getTileEntity(sourcePortalPos);
destWorld.setBlockState(dest.getPos(), ModBlocks.portalBlock.getDefaultState(), 3);
PortalTileEntity destination = (PortalTileEntity) destWorld.getTileEntity(dest.getPos());
source.setTimeout(Config.portalTimeout);
source.setOther(dest);
source.setPortalSide(selectedSide);
destination.setTimeout(Config.portalTimeout);
destination.setOther(new TeleportDestination("", sourceWorld.provider.getDimension(), sourcePortalPos, selectedSide));
destination.setPortalSide(dest.getSide());
}
示例13: neighborChanged
import net.minecraft.world.World; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
if (pos.getY() == fromPos.getY() && world.isAirBlock(fromPos) && !checkRecursive(world, pos, 0, new ArrayList<BlockPos>(6)) && blockIn.equals(ModBlocks.witch_altar)) {
dismantleRecursive(world, pos);
}
;
}
示例14: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
if (!worldIn.isAirBlock(position))
{
return false;
}
else if (worldIn.getBlockState(position.up()).getBlock() != Blocks.netherrack)
{
return false;
}
else
{
worldIn.setBlockState(position, Blocks.glowstone.getDefaultState(), 2);
for (int i = 0; i < 1500; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), -rand.nextInt(12), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air)
{
int j = 0;
for (EnumFacing enumfacing : EnumFacing.values())
{
if (worldIn.getBlockState(blockpos.offset(enumfacing)).getBlock() == Blocks.glowstone)
{
++j;
}
if (j > 1)
{
break;
}
}
if (j == 1)
{
worldIn.setBlockState(blockpos, Blocks.glowstone.getDefaultState(), 2);
}
}
}
return true;
}
}
示例15: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
if (worldIn.getBlockState(position.up()).getBlock() != Blocks.STONE)
{
return false;
}
else if (worldIn.getBlockState(position.down()).getBlock() != Blocks.STONE)
{
return false;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(position);
if (!iblockstate.getBlock().isAir(iblockstate, worldIn, position) && iblockstate.getBlock() != Blocks.STONE)
{
return false;
}
else
{
int i = 0;
if (worldIn.getBlockState(position.west()).getBlock() == Blocks.STONE)
{
++i;
}
if (worldIn.getBlockState(position.east()).getBlock() == Blocks.STONE)
{
++i;
}
if (worldIn.getBlockState(position.north()).getBlock() == Blocks.STONE)
{
++i;
}
if (worldIn.getBlockState(position.south()).getBlock() == Blocks.STONE)
{
++i;
}
int j = 0;
if (worldIn.isAirBlock(position.west()))
{
++j;
}
if (worldIn.isAirBlock(position.east()))
{
++j;
}
if (worldIn.isAirBlock(position.north()))
{
++j;
}
if (worldIn.isAirBlock(position.south()))
{
++j;
}
if (i == 3 && j == 1)
{
IBlockState iblockstate1 = this.block.getDefaultState();
worldIn.setBlockState(position, iblockstate1, 2);
worldIn.immediateBlockTick(position, iblockstate1, rand);
}
return true;
}
}
}