本文整理汇总了Java中net.minecraft.util.math.BlockPos.getAllInBoxMutable方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPos.getAllInBoxMutable方法的具体用法?Java BlockPos.getAllInBoxMutable怎么用?Java BlockPos.getAllInBoxMutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.BlockPos
的用法示例。
在下文中一共展示了BlockPos.getAllInBoxMutable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVisibleFacings
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private Set<EnumFacing> getVisibleFacings(BlockPos pos)
{
VisGraph visgraph = new VisGraph();
BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15)))
{
if (chunk.getBlockState(blockpos$mutableblockpos).isOpaqueCube())
{
visgraph.setOpaqueCube(blockpos$mutableblockpos);
}
}
return visgraph.getVisibleFacings(pos);
}
示例2: getNearbyCornerBlocks
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private List<TileEntityStructure> getNearbyCornerBlocks(BlockPos p_184418_1_, BlockPos p_184418_2_)
{
List<TileEntityStructure> list = Lists.<TileEntityStructure>newArrayList();
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(p_184418_1_, p_184418_2_))
{
IBlockState iblockstate = this.worldObj.getBlockState(blockpos$mutableblockpos);
if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK)
{
TileEntity tileentity = this.worldObj.getTileEntity(blockpos$mutableblockpos);
if (tileentity != null && tileentity instanceof TileEntityStructure)
{
list.add((TileEntityStructure)tileentity);
}
}
}
return list;
}
示例3: getNearbyCornerBlocks
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private List<TileEntityStructure> getNearbyCornerBlocks(BlockPos p_184418_1_, BlockPos p_184418_2_)
{
List<TileEntityStructure> list = Lists.<TileEntityStructure>newArrayList();
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(p_184418_1_, p_184418_2_))
{
IBlockState iblockstate = this.world.getBlockState(blockpos$mutableblockpos);
if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK)
{
TileEntity tileentity = this.world.getTileEntity(blockpos$mutableblockpos);
if (tileentity != null && tileentity instanceof TileEntityStructure)
{
list.add((TileEntityStructure)tileentity);
}
}
}
return list;
}
示例4: getColorAtPos
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private static int getColorAtPos(IBlockAccess blockAccess, BlockPos pos, BiomeColorHelper.ColorResolver colorResolver)
{
int i = 0;
int j = 0;
int k = 0;
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-1, 0, -1), pos.add(1, 0, 1)))
{
int l = colorResolver.getColorAtPos(blockAccess.getBiome(blockpos$mutableblockpos), blockpos$mutableblockpos);
i += (l & 16711680) >> 16;
j += (l & 65280) >> 8;
k += l & 255;
}
return (i / 9 & 255) << 16 | (j / 9 & 255) << 8 | k / 9 & 255;
}
示例5: randomDisplayTick
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
super.randomDisplayTick(stateIn, worldIn, pos, rand);
for (BlockPos pos1 : BlockPos.getAllInBoxMutable(pos.add(-2, 0, -2), pos.add(2, 0, 2))) {
if (worldIn.getBlockState(pos1).getBlock() instanceof IGrowable && rand.nextBoolean() && rand.nextBoolean() && rand.nextBoolean()) {
worldIn.spawnParticle(EnumParticleTypes.WATER_WAKE, pos1.getX() + rand.nextDouble(), pos1.getY(), pos1.getZ() + rand.nextDouble(), 0.0D, 0.0D, 0.0D);
}
}
}
示例6: hasWater
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private boolean hasWater(World worldIn, BlockPos pos)
{
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4)))
{
if (worldIn.getBlockState(blockpos$mutableblockpos).getMaterial() == Material.WATER)
{
return true;
}
}
return false;
}
示例7: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(position.add(-1, -2, -1), position.add(1, 2, 1)))
{
boolean flag = blockpos$mutableblockpos.getX() == position.getX();
boolean flag1 = blockpos$mutableblockpos.getY() == position.getY();
boolean flag2 = blockpos$mutableblockpos.getZ() == position.getZ();
boolean flag3 = Math.abs(blockpos$mutableblockpos.getY() - position.getY()) == 2;
if (flag && flag1 && flag2)
{
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.END_GATEWAY.getDefaultState());
}
else if (flag1)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
}
else if (flag3 && flag && flag2)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
}
else if ((flag || flag2) && !flag3)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
}
else
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
}
}
return true;
}
示例8: updateTick
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if (rand.nextInt(25) == 0) {
int i = 5;
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) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState())) {
pos = blockpos1;
}
blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
}
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState())) {
worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
}
}
}
示例9: getGrassColour
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static int getGrassColour(World world, Biome biome, BlockPos pos) {
int rad = 6;
int divisor = (rad*2 + 1);
divisor *= divisor;
int r = 0;
int g = 0;
int b = 0;
Map<Biome, Integer> biomeColours = new HashMap<>();
Biome ib;
int col,x,z;
for (BlockPos.MutableBlockPos ipos : BlockPos.getAllInBoxMutable(pos.add(-rad, 0, -rad), pos.add(rad, 0, rad)))
{
ib = grassCache.getUnchecked(new GrassCacheKey(world, ipos));
if (biomeColours.containsKey(ib)) {
col = biomeColours.get(ib);
} else {
col = ib.getGrassColorAtPos(pos);
biomeColours.put(ib, col);
}
r += (col & 0xFF0000) >> 16;
g += (col & 0x00FF00) >> 8;
b += (col & 0x0000FF);
}
return (r / divisor & 255) << 16 | (g / divisor & 255) << 8 | b / divisor & 255;
}
示例10: noteBlockPlayEvent
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@SubscribeEvent
public void noteBlockPlayEvent(NoteBlockEvent.Play event) {
if (event.getWorld().isRemote)
return;
BlockPos epos = event.getPos();
int range = 10;
for (BlockPos pos : BlockPos.getAllInBoxMutable(epos.add(-range, -2, -range), epos.add(range, 2, range))) {
TileEntity te = event.getWorld().getTileEntity(pos);
if (te != null && te instanceof TileMusicaPlant) {
TileMusicaPlant plant = (TileMusicaPlant)te;
if (plant.getBeats().size() > 0)
{
for (int i = 0; i < plant.getBeats().size(); i++) {
Beat beat = plant.getBeats().get(i);
if (beat.beatMatches(new Beat(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime()))) {
plant.setNewBeatTime(i, event.getWorld().getTotalWorldTime());
return;
}
}
}
if (plant.canAddNote())
plant.setNote(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime());
}
}
}
示例11: updateTick
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (rand.nextInt(25) == 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) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
{
pos = blockpos1;
}
blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
}
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
{
worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
}
}
}
示例12: freezeNearby
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
if (living.onGround)
{
float f = (float)Math.min(16, 2 + level);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);
for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
{
if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
{
blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
if (iblockstate.getMaterial() == Material.AIR)
{
IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);
if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.canBlockBePlaced(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null, (ItemStack)null))
{
worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getRandomIntegerInRange(living.getRNG(), 60, 120));
}
}
}
}
}
}
示例13: freezeNearby
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
if (living.onGround)
{
float f = (float)Math.min(16, 2 + level);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);
for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
{
if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
{
blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
if (iblockstate.getMaterial() == Material.AIR)
{
IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);
if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.func_190527_a(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
{
worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getInt(living.getRNG(), 60, 120));
}
}
}
}
}
}
示例14: takeBlocksFromWorld
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* takes blocks from the world and puts the data them into this template
*/
public void takeBlocksFromWorld(World worldIn, BlockPos startPos, BlockPos endPos, boolean takeEntities, @Nullable Block toIgnore)
{
if (endPos.getX() >= 1 && endPos.getY() >= 1 && endPos.getZ() >= 1)
{
BlockPos blockpos = startPos.add(endPos).add(-1, -1, -1);
List<Template.BlockInfo> list = Lists.<Template.BlockInfo>newArrayList();
List<Template.BlockInfo> list1 = Lists.<Template.BlockInfo>newArrayList();
List<Template.BlockInfo> list2 = Lists.<Template.BlockInfo>newArrayList();
BlockPos blockpos1 = new BlockPos(Math.min(startPos.getX(), blockpos.getX()), Math.min(startPos.getY(), blockpos.getY()), Math.min(startPos.getZ(), blockpos.getZ()));
BlockPos blockpos2 = new BlockPos(Math.max(startPos.getX(), blockpos.getX()), Math.max(startPos.getY(), blockpos.getY()), Math.max(startPos.getZ(), blockpos.getZ()));
this.size = endPos;
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos1, blockpos2))
{
BlockPos blockpos3 = blockpos$mutableblockpos.subtract(blockpos1);
IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
if (toIgnore == null || toIgnore != iblockstate.getBlock())
{
TileEntity tileentity = worldIn.getTileEntity(blockpos$mutableblockpos);
if (tileentity != null)
{
NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
nbttagcompound.removeTag("x");
nbttagcompound.removeTag("y");
nbttagcompound.removeTag("z");
list1.add(new Template.BlockInfo(blockpos3, iblockstate, nbttagcompound));
}
else if (!iblockstate.isFullBlock() && !iblockstate.isFullCube())
{
list2.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
}
else
{
list.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
}
}
}
this.blocks.clear();
this.blocks.addAll(list);
this.blocks.addAll(list1);
this.blocks.addAll(list2);
if (takeEntities)
{
this.takeEntitiesFromWorld(worldIn, blockpos1, blockpos2.add(1, 1, 1));
}
else
{
this.entities.clear();
}
}
}
示例15: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(new BlockPos(position.getX() - 4, position.getY() - 1, position.getZ() - 4), new BlockPos(position.getX() + 4, position.getY() + 32, position.getZ() + 4)))
{
double d0 = blockpos$mutableblockpos.getDistance(position.getX(), blockpos$mutableblockpos.getY(), position.getZ());
if (d0 <= 3.5D)
{
if (blockpos$mutableblockpos.getY() < position.getY())
{
if (d0 <= 2.5D)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
}
else if (blockpos$mutableblockpos.getY() < position.getY())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.END_STONE.getDefaultState());
}
}
else if (blockpos$mutableblockpos.getY() > position.getY())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
}
else if (d0 > 2.5D)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
}
else if (this.activePortal)
{
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.END_PORTAL.getDefaultState());
}
else
{
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.AIR.getDefaultState());
}
}
}
for (int i = 0; i < 4; ++i)
{
this.setBlockAndNotifyAdequately(worldIn, position.up(i), Blocks.BEDROCK.getDefaultState());
}
BlockPos blockpos = position.up(2);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos.offset(enumfacing), Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, enumfacing));
}
return true;
}