本文整理匯總了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);
}
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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());
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
}
}
}