本文整理了Java中net.minecraft.util.math.BlockPos.getAllInBoxMutable()
方法的一些代码示例,展示了BlockPos.getAllInBoxMutable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockPos.getAllInBoxMutable()
方法的具体详情如下:
包路径:net.minecraft.util.math.BlockPos
类名称:BlockPos
方法名:getAllInBoxMutable
暂无
代码示例来源:origin: Vazkii/Botania
for(BlockPos pos : BlockPos.getAllInBoxMutable(startCenter.add(-range, -range, -range), startCenter.add(range, range, range))) {
IBlockState state = world.getBlockState(pos);
if(state.getBlock() == Blocks.AIR)
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote)
return;
if(ticksExisted % 200 == 0)
sync();
if(mana > COST_PER_TICK) {
mana -= COST_PER_TICK;
if(ticksExisted % 10 == 0 && range < getRange())
range++;
for(BlockPos pos : BlockPos.getAllInBoxMutable(getPos().add(-range, -range, -range), getPos().add(range, range, range))) {
if(getPos().distanceSq(pos) < range * range) {
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getMaterial() == Material.WATER) {
supertile.getWorld().setBlockState(pos, ModBlocks.fakeAir.getDefaultState(), 2);
TileFakeAir air = (TileFakeAir) supertile.getWorld().getTileEntity(pos);
air.setFlower(supertile);
}
}
}
}
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
private boolean hasWater(World world, BlockPos pos) {
for (BlockPos.MutableBlockPos nearPos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4))) {
if (world.getBlockState(nearPos).getMaterial() == Material.WATER) {
return true;
}
}
return false;
}
代码示例来源:origin: ForestryMC/ForestryMC
private static boolean isMoistened(World world, BlockPos pos) {
for (BlockPos.MutableBlockPos waterPos : BlockPos.getAllInBoxMutable(pos.add(-2, -2, -2), pos.add(2, 2, 2))) {
IBlockState blockState = world.getBlockState(waterPos);
Block block = blockState.getBlock();
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
return true;
}
}
return false;
}
代码示例来源:origin: Vazkii/Quark
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if(rand.nextInt(UndergroundBiomes.glowshroomGrowthRate) == 0) {
int i = 5;
int j = 4;
for(BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4))) {
if(worldIn.getBlockState(blockpos).getBlock() == this) {
--i;
if(i <= 0)
return;
}
}
BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
for(int k = 0; k < 4; ++k) {
if (worldIn.isAirBlock(blockpos1) && canBlockStay(worldIn, blockpos1, getDefaultState()))
pos = blockpos1;
blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
}
if(worldIn.isAirBlock(blockpos1) && canBlockStay(worldIn, blockpos1, getDefaultState()))
worldIn.setBlockState(blockpos1, getDefaultState(), 2);
}
}
代码示例来源:origin: CoFH/ThermalExpansion
protected int getTimeConstant() {
int constant = TIME_CONSTANT / 2;
Iterable<BlockPos.MutableBlockPos> area = BlockPos.getAllInBoxMutable(trunkPos.add(-1, 0, -1), trunkPos.add(1, 0, 1));
for (BlockPos scan : area) {
if (isTapper(world.getBlockState(scan))) {
constant += TIME_CONSTANT / 2;
}
}
return MathHelper.clamp(constant, TIME_CONSTANT, TIME_CONSTANT * 2);
}
代码示例来源:origin: sinkillerj/ProjectE
public static void igniteNearby(World world, EntityPlayer player)
{
for (BlockPos pos : BlockPos.getAllInBoxMutable(new BlockPos(player).add(-8, -5, -8), new BlockPos(player).add(8, 5, 8)))
{
if (world.rand.nextInt(128) == 0 && world.isAirBlock(pos))
{
PlayerHelper.checkedPlaceBlock(((EntityPlayerMP) player), pos.toImmutable(), Blocks.FIRE.getDefaultState());
}
}
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
for (BlockPos pos : BlockPos.getAllInBoxMutable(
new BlockPos(Math.floor(aabb.minX), Math.floor(aabb.minY), Math.floor(aabb.minZ)),
new BlockPos(Math.ceil(aabb.maxX), Math.ceil(aabb.maxY), Math.ceil(aabb.maxZ)))) {
代码示例来源:origin: Vazkii/Botania
range = 12;
BlockPos pos = new BlockPos(player);
for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))) {
TileEntity tile = player.world.getTileEntity(pos_);
if(tile != null) {
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (world.getBlockState(pos.down()).getBlock() instanceof PeatBlock) {
if (rand.nextInt(8) <= 3) {
int allowedInArea = DENSITY_PER_AREA;
BlockPos nextPos = null;
int placementAttempts = 3;
while (nextPos == null && placementAttempts > 0) {
int doubleRadius = SPREAD_RADIUS * 2;
BlockPos tmp = pos.add(rand.nextInt(doubleRadius) - SPREAD_RADIUS, -SPREAD_RADIUS, rand.nextInt(doubleRadius) - SPREAD_RADIUS);
nextPos = this.findGround(world, tmp);
placementAttempts--;
}
if (nextPos != null) {
for (BlockPos neighbourPos : BlockPos.getAllInBoxMutable(nextPos.add(-2, -3, -2), nextPos.add(2, 3, 2))) {
if (world.getBlockState(neighbourPos).getBlock() == this) {
allowedInArea--;
if (allowedInArea <= 0) {
return;
}
}
}
world.setBlockState(nextPos, this.getDefaultState());
}
}
}
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
for (BlockPos neighbourPos : BlockPos.getAllInBoxMutable(nextPos.add(-2, -3, -2), nextPos.add(2, 3, 2))) {
if (world.getBlockState(neighbourPos).getBlock() instanceof BlockBush) {
allowedInArea--;
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
protected boolean isNearWater(World world, BlockPos nextPos) {
for (BlockPos neighbourPos : BlockPos.getAllInBoxMutable(nextPos.add(-8, -3, -8), nextPos.add(8, 3, 8))) {
Block neighbourState = world.getBlockState(neighbourPos).getBlock();
if (neighbourState == Blocks.WATER || neighbourState == Blocks.FLOWING_WATER) {
if (neighbourPos.getDistance(nextPos.getX(), nextPos.getY(), nextPos.getZ()) < 9) {
return true;
}
}
}
return false;
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-SPREAD_RADIUS, -3, -SPREAD_RADIUS), pos.add(SPREAD_RADIUS, 3, SPREAD_RADIUS))) {
代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft
public int getWaterScore(IBlockAccess world, BlockPos pos)
{
final int hRange = 7;
float score = 0;
for (BlockPos.MutableBlockPos i : BlockPos.getAllInBoxMutable(pos.add(-hRange, -1, -hRange), pos.add(hRange, 2, hRange)))
{
BlockPos diff = i.subtract(pos);
float hDist = MathHelper.sqrt(diff.getX() * diff.getX() + diff.getZ() * diff.getZ());
if (hDist > hRange) continue;
if (world.getBlockState(i).getMaterial() != Material.WATER) continue;
score += ((hRange - hDist) / (float) hRange);
}
return score > 1 ? MAX_MOISTURE : Math.round(score * MAX_MOISTURE);
}
代码示例来源:origin: sinkillerj/ProjectE
private boolean useBoneMeal(World world, BlockPos pos)
{
boolean result = false;
for (BlockPos currentPos : BlockPos.getAllInBoxMutable(pos.add(-15, 0, -15), pos.add(15, 0, 15)))
{
IBlockState state = world.getBlockState(currentPos);
Block crop = state.getBlock();
if (crop instanceof IGrowable)
{
IGrowable growable = (IGrowable) crop;
if (growable.canUseBonemeal(world, world.rand, currentPos, state))
{
if (!result)
{
result = true;
}
growable.grow(world, world.rand, currentPos.toImmutable(), state);
}
}
}
return result;
}
代码示例来源:origin: Lunatrius/Schematica
private Set<EnumFacing> getVisibleSides(final BlockPos pos) {
final VisGraph visgraph = new VisGraph();
final BlockPos posChunk = new BlockPos(pos.getX() & ~0xF, pos.getY() & ~0xF, pos.getZ() & ~0xF);
for (final BlockPos.MutableBlockPos mutableBlockPos : BlockPos.getAllInBoxMutable(posChunk, posChunk.add(15, 15, 15))) {
if (this.world.getBlockState(mutableBlockPos).isOpaqueCube()) {
visgraph.setOpaqueCube(mutableBlockPos);
}
}
return visgraph.getVisibleFacings(pos);
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
@Override
public void startExecuting() {
int searchAttempts = 0;
this.entity.getNavigator().clearPath();
search:
while (searchAttempts++ < 20 && this.entity.getNavigator().noPath()) {
int offsetX = this.entity.getRNG().nextInt(8) - this.entity.getRNG().nextInt(8);
int offsetZ = this.entity.getRNG().nextInt(8) - this.entity.getRNG().nextInt(8);
BlockPos pos = this.entity.getPosition().add(offsetX, 0, offsetZ);
BlockPos surface = AIUtils.findSurface(this.entity.world, pos);
if (surface != null) {
Iterable<BlockPos.MutableBlockPos> surrounding = BlockPos.getAllInBoxMutable(surface.add(-1, -1, -1), surface.add(1, 1, 1));
for (BlockPos p : surrounding) {
if (this.entity.world.getBlockState(p).getBlock() == BlockHandler.LOW_SECURITY_FENCE_WIRE) {
continue search;
}
}
this.entity.getNavigator().tryMoveToXYZ(surface.getX(), surface.getY(), surface.getZ(), 1.4);
}
}
}
代码示例来源:origin: sinkillerj/ProjectE
case NORTH:
for (BlockPos pos : BlockPos.getAllInBoxMutable(player.getPosition().add(-30, -5, -3), player.getPosition().add(30, 5, 3)))
case EAST:
for (BlockPos pos : BlockPos.getAllInBoxMutable(player.getPosition().add(-3, -5, -30), player.getPosition().add(3, 5, 30)))
代码示例来源:origin: Chisel-Team/Chisel
@SuppressWarnings("null")
@SubscribeEvent
public void onLavaLakes(PopulateChunkEvent.Post event) {
if (Configurations.basaltSpecialGen && Features.BASALT.enabled()) {
BlockPos origin = new BlockPos(event.getChunkX() * 16 + 8, 0, event.getChunkZ() * 16 + 8);
for (BlockPos pos : BlockPos.getAllInBoxMutable(origin, origin.add(15, 11, 15))) {
IBlockState here = event.getWorld().getBlockState(pos);
if (here.getMaterial() == Material.LAVA) {
BlockPos p = pos.toImmutable();
World w = event.getWorld();
int size = Configurations.basaltSideThickness;
for (BlockPos p2 : BlockPos.getAllInBoxMutable(p.offset(EnumFacing.EAST, size).offset(EnumFacing.SOUTH, size), p.offset(EnumFacing.WEST, size).offset(EnumFacing.NORTH, size))) {
replace(w, p2);
}
for (int i = 1; i <= Configurations.basaltBottomThickness; i++) {
replace(w, p.offset(EnumFacing.DOWN, i));
}
}
}
}
}
代码示例来源:origin: TeamWizardry/Wizardry
});
if (!entitySource.world.isRemote) for (BlockPos pos : BlockPos.getAllInBoxMutable(
new BlockPos(entitySource.getPositionVector())
.add(-range,
内容来源于网络,如有侵权,请联系作者删除!