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


Java BlockPos.getAllInBox方法代码示例

本文整理汇总了Java中net.minecraft.util.math.BlockPos.getAllInBox方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPos.getAllInBox方法的具体用法?Java BlockPos.getAllInBox怎么用?Java BlockPos.getAllInBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.math.BlockPos的用法示例。


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

示例1: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, 1, box);
	BlockPos posF = pos.add(-box, -1, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	int chance = 10 + amplifier * 2;
	int fortune = MathHelper.clamp(amplifier, 0, 5);
	for (BlockPos spot : spots) {
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 1 || world.rand.nextBoolean();
		if (place && state.getBlock() instanceof BlockCrops) {
			BlockCrops crop = (BlockCrops) state.getBlock();
			if (crop.isMaxAge(state)) {
				crop.dropBlockAsItemWithChance(world, spot, state, chance, fortune);
				world.setBlockToAir(spot);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:23,代码来源:HarvestBrew.java

示例2: isPositionClear

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Returns true if an entity does not collide with any solid blocks at the position.
 */
private boolean isPositionClear(int p_179692_1_, int p_179692_2_, int p_179692_3_, int p_179692_4_, int p_179692_5_, int p_179692_6_, Vec3d p_179692_7_, double p_179692_8_, double p_179692_10_)
{
    for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(p_179692_1_, p_179692_2_, p_179692_3_), new BlockPos(p_179692_1_ + p_179692_4_ - 1, p_179692_2_ + p_179692_5_ - 1, p_179692_3_ + p_179692_6_ - 1)))
    {
        double d0 = (double)blockpos.getX() + 0.5D - p_179692_7_.xCoord;
        double d1 = (double)blockpos.getZ() + 0.5D - p_179692_7_.zCoord;

        if (d0 * p_179692_8_ + d1 * p_179692_10_ >= 0.0D)
        {
            Block block = this.worldObj.getBlockState(blockpos).getBlock();

            if (!block.isPassable(this.worldObj, blockpos))
            {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:PathNavigateGround.java

示例3: breakBlock

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 4;
    int j = 5;

    if (worldIn.isAreaLoaded(pos.add(-5, -5, -5), pos.add(5, 5, 5)))
    {
        for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-4, -4, -4), pos.add(4, 4, 4)))
        {
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos))
            {
                iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:BlockLog.java

示例4: transformBedrock

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private void transformBedrock(World world, BlockPos pos) {
	
	Iterable<BlockPos> poslist = BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, 0, range));
	Iterator posit = poslist.iterator();
	while (posit.hasNext()) {
		BlockPos looppos = (BlockPos)posit.next();
		if (!world.isAirBlock(looppos) && world.getBlockState(looppos).getBlock() == Blocks.BEDROCK) {
			if (looppos.getY() <= 1) continue;
			if (world.rand.nextBoolean()) {
				world.setBlockState(looppos, UCBlocks.darkBlock.getDefaultState(), 2);
				UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.CLOUD, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
				return;
			}
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:17,代码来源:Petramia.java

示例5: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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.nextBoolean();
		if (place && state.getBlock() == Blocks.FARMLAND && world.isAirBlock(spot.up())) {
			world.setBlockState(spot, Blocks.DIRT.getStateFromMeta(1), 3);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:18,代码来源:SaltLandBrew.java

示例6: plantAll

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private void plantAll(List<EntityItem> items, World world, BlockPos pos, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, 1, box);
	BlockPos posF = pos.add(-box, -1, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);

	for (EntityItem item : items) {
		ItemStack stack = item.getItem();
		for (BlockPos spot : spots) {
			if (stack.isEmpty()) {
				item.setDead();
				break;
			}
			IBlockState state = world.getBlockState(spot);
			IPlantable seed = (IPlantable) stack.getItem();
			if (world.isAirBlock(spot.up()) && state.getBlock().canSustainPlant(state, world, spot, EnumFacing.UP, seed)) {
				world.setBlockState(spot.up(), seed.getPlant(world, spot.up()));
				stack.shrink(1);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:25,代码来源:AutoPlantBrew.java

示例7: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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) {
		Block block = world.getBlockState(spot).getBlock();
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (place && stateMap.containsKey(block)) {
			world.setBlockState(spot, stateMap.get(block), 3);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:OzymandiasBrew.java

示例8: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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 && Blocks.SNOW_LAYER.canPlaceBlockAt(world, spot) && state.getBlock().isReplaceable(world, spot)) {
			world.setBlockState(spot, Blocks.SNOW_LAYER.getDefaultState()
					.withProperty(BlockSnow.LAYERS, 1 + world.rand.nextInt(7)), 3);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:18,代码来源:SnowTrailBrew.java

示例9: cast

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	World world = sender.getEntityWorld();
	BlockPos source = sender.getPosition();
	for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof TileCandle && ((TileCandle) tile).isLit()) {
			for (int i = 0; i < 5; i++) {
				double x = pos.getX() + world.rand.nextFloat();
				double y = pos.getY() + world.rand.nextFloat();
				double z = pos.getZ() + world.rand.nextFloat();
				world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
			}
			((TileCandle) tile).unLitCandle();
			PacketHandler.updateToNearbyPlayers(world, pos);
		}
	}
	EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:20,代码来源:IncantationSnuff.java

示例10: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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.nextBoolean();
		if (place && state.getBlock() instanceof IGrowable) {
			IGrowable crop = (IGrowable) state.getBlock();
			if (crop.canGrow(world, spot, state, false))
				crop.grow(world, world.rand, spot, state);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:19,代码来源:FertilizeBrew.java

示例11: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的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());
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:18,代码来源:GrowFlowersBrew.java

示例12: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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) {
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (place) {
			IBlockState state = world.getBlockState(spot);
			Block block = state.getBlock();
			if (block == Blocks.SANDSTONE_STAIRS) {
				IBlockState newState = Blocks.RED_SANDSTONE_STAIRS.getDefaultState()
						.withProperty(BlockStairs.FACING, state.getValue(BlockStairs.FACING))
						.withProperty(BlockStairs.HALF, state.getValue(BlockStairs.HALF));
				world.setBlockState(spot, newState);
			} else if (stateMap.containsKey(block)) {
				world.setBlockState(spot, stateMap.get(block), 3);
			} else if (block == Blocks.SANDSTONE) {
				BlockSandStone.EnumType type = state.getValue(BlockSandStone.TYPE);
				IBlockState other = getSandStone(type);
				world.setBlockState(spot, other, 3);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:30,代码来源:SetehsWastesBrew.java

示例13: findSpawnpointInChunk

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable
private static BlockPos findSpawnpointInChunk(Chunk chunkIn)
{
    BlockPos blockpos = new BlockPos(chunkIn.xPosition * 16, 30, chunkIn.zPosition * 16);
    int i = chunkIn.getTopFilledSegment() + 16 - 1;
    BlockPos blockpos1 = new BlockPos(chunkIn.xPosition * 16 + 16 - 1, i, chunkIn.zPosition * 16 + 16 - 1);
    BlockPos blockpos2 = null;
    double d0 = 0.0D;

    for (BlockPos blockpos3 : BlockPos.getAllInBox(blockpos, blockpos1))
    {
        IBlockState iblockstate = chunkIn.getBlockState(blockpos3);

        if (iblockstate.getBlock() == Blocks.END_STONE && !chunkIn.getBlockState(blockpos3.up(1)).isBlockNormalCube() && !chunkIn.getBlockState(blockpos3.up(2)).isBlockNormalCube())
        {
            double d1 = blockpos3.distanceSqToCenter(0.0D, 0.0D, 0.0D);

            if (blockpos2 == null || d1 < d0)
            {
                blockpos2 = blockpos3;
                d0 = d1;
            }
        }
    }

    return blockpos2;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:TileEntityEndGateway.java

示例14: safeImpact

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	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.nextBoolean();
		if (place && state.getBlock() == Blocks.WATER && world.isAirBlock(spot.up())) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.ICE) {
			world.setBlockState(spot, Blocks.PACKED_ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.SNOW_LAYER) {
			world.setBlockState(spot, Blocks.SNOW.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.SNOW) {
			world.setBlockState(spot, Blocks.PACKED_ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FROSTED_ICE) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.LAVA) {
			world.setBlockState(spot, Blocks.OBSIDIAN.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FLOWING_LAVA) {
			world.setBlockState(spot, Blocks.OBSIDIAN.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FLOWING_WATER) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:31,代码来源:FrostbiteBrew.java

示例15: onUpdate

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void onUpdate() {
	
	super.onUpdate();
	if (this.worldObj != null && this.ticksExisted % 300 == 0) {
		Iterable<BlockPos> poslist = BlockPos.getAllInBox(getPosition().add(-range, -range, -range), getPosition().add(range, range, range));
		Iterator it = poslist.iterator();
		while (it.hasNext()) {
			BlockPos posit = (BlockPos)it.next();
			if (!worldObj.isRemote && !worldObj.isAirBlock(posit)) {
				Block loopblock = worldObj.getBlockState(posit).getBlock();
				boolean flag = rand.nextInt(10) == 0;
				if (loopblock == Blocks.GRASS && flag) {
					setOldBlock(worldObj, posit, UCBlocks.oldGrass); break;
				}
				if (loopblock == Blocks.COBBLESTONE && flag) {
					setOldBlock(worldObj, posit, UCBlocks.oldCobble); break;
				}
				if (loopblock == Blocks.MOSSY_COBBLESTONE && flag) {
					setOldBlock(worldObj, posit, UCBlocks.oldCobbleMoss); break;
				}
				if (loopblock == Blocks.BRICK_BLOCK && flag) {
					setOldBlock(worldObj, posit, UCBlocks.oldBrick); break;
				}
				if (loopblock == Blocks.GRAVEL && flag) {
					setOldBlock(worldObj, posit, UCBlocks.oldGravel); break;
				}
			}
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:32,代码来源:EntityItemHourglass.java


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