本文整理匯總了Java中net.minecraft.util.BlockPos.add方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.add方法的具體用法?Java BlockPos.add怎麽用?Java BlockPos.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.BlockPos
的用法示例。
在下文中一共展示了BlockPos.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generate
import net.minecraft.util.BlockPos; //導入方法依賴的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 < 128; ++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.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
{
worldIn.setBlockState(blockpos, this.tallGrassState, 2);
}
}
return true;
}
示例2: func_175928_b
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
protected void func_175928_b(World worldIn, BlockPos p_175928_2_, int p_175928_3_)
{
int i = p_175928_3_ * p_175928_3_;
for (int j = -p_175928_3_; j <= p_175928_3_; ++j)
{
for (int k = -p_175928_3_; k <= p_175928_3_; ++k)
{
if (j * j + k * k <= i)
{
BlockPos blockpos = p_175928_2_.add(j, 0, k);
Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();
if (material == Material.air || material == Material.leaves)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
}
}
}
}
}
示例3: getPathToEntityLiving
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Returns the path to the given EntityLiving. Args : entity
*/
public PathEntity getPathToEntityLiving(Entity entityIn)
{
if (!this.canNavigate())
{
return null;
}
else
{
float f = this.getPathSearchRange();
this.worldObj.theProfiler.startSection("pathfind");
BlockPos blockpos = (new BlockPos(this.theEntity)).up();
int i = (int)(f + 16.0F);
ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0);
PathEntity pathentity = this.pathFinder.createEntityPathTo(chunkcache, this.theEntity, entityIn, f);
this.worldObj.theProfiler.endSection();
return pathentity;
}
}
示例4: getTarget
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public BlockData getTarget(BlockPos pos) {
EnumFacing[] orderedFacingValues = new EnumFacing[] {
EnumFacing.UP,
EnumFacing.EAST,
EnumFacing.NORTH,
EnumFacing.WEST,
EnumFacing.SOUTH,
EnumFacing.DOWN
};
for (EnumFacing facing : orderedFacingValues) {
BlockPos alteredPos = pos.add(facing.getOpposite().getDirectionVec());
if (!mc.theWorld.getBlockState(alteredPos).getBlock().isReplaceable(mc.theWorld, alteredPos) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockLiquid) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockAir)) {
return new BlockData(alteredPos, facing);
}
}
return null;
}
示例5: generate
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (; position.getY() < 128; position = position.up())
{
if (worldIn.isAirBlock(position))
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings())
{
if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing))
{
IBlockState iblockstate = Blocks.vine.getDefaultState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == EnumFacing.WEST));
worldIn.setBlockState(position, iblockstate, 2);
break;
}
}
}
else
{
position = position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4));
}
}
return true;
}
示例6: checkBlockLine
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
* (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
*/
int checkBlockLine(BlockPos posOne, BlockPos posTwo)
{
BlockPos blockpos = posTwo.add(-posOne.getX(), -posOne.getY(), -posOne.getZ());
int i = this.getGreatestDistance(blockpos);
float f = (float)blockpos.getX() / (float)i;
float f1 = (float)blockpos.getY() / (float)i;
float f2 = (float)blockpos.getZ() / (float)i;
if (i == 0)
{
return -1;
}
else
{
for (int j = 0; j <= i; ++j)
{
BlockPos blockpos1 = posOne.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
if (!this.func_150523_a(this.world.getBlockState(blockpos1).getBlock()))
{
return j;
}
}
return -1;
}
}
示例7: addDoorsAround
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private void addDoorsAround(BlockPos central)
{
int i = 16;
int j = 4;
int k = 16;
for (int l = -i; l < i; ++l)
{
for (int i1 = -j; i1 < j; ++i1)
{
for (int j1 = -k; j1 < k; ++j1)
{
BlockPos blockpos = central.add(l, i1, j1);
if (this.isWoodDoor(blockpos))
{
VillageDoorInfo villagedoorinfo = this.checkDoorExistence(blockpos);
if (villagedoorinfo == null)
{
this.addToNewDoorsList(blockpos);
}
else
{
villagedoorinfo.func_179849_a(this.tickCounter);
}
}
}
}
}
}
示例8: func_175937_a
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
void func_175937_a(BlockPos p_175937_1_, BlockPos p_175937_2_, Block p_175937_3_)
{
BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
int i = this.getGreatestDistance(blockpos);
float f = (float)blockpos.getX() / (float)i;
float f1 = (float)blockpos.getY() / (float)i;
float f2 = (float)blockpos.getZ() / (float)i;
for (int j = 0; j <= i; ++j)
{
BlockPos blockpos1 = p_175937_1_.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
BlockLog.EnumAxis blocklog$enumaxis = this.func_175938_b(p_175937_1_, blockpos1);
this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState().withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
}
}
示例9: searchForDestination
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Searches and sets new destination block and returns true if a suitable block (specified in {@link
* net.minecraft.entity.ai.EntityAIMoveToBlock#shouldMoveTo(World, BlockPos) EntityAIMoveToBlock#shouldMoveTo(World,
* BlockPos)}) can be found.
*/
private boolean searchForDestination()
{
int i = this.searchLength;
int j = 1;
BlockPos blockpos = new BlockPos(this.theEntity);
for (int k = 0; k <= 1; k = k > 0 ? -k : 1 - k)
{
for (int l = 0; l < i; ++l)
{
for (int i1 = 0; i1 <= l; i1 = i1 > 0 ? -i1 : 1 - i1)
{
for (int j1 = i1 < l && i1 > -l ? l : 0; j1 <= l; j1 = j1 > 0 ? -j1 : 1 - j1)
{
BlockPos blockpos1 = blockpos.add(i1, k - 1, j1);
if (this.theEntity.isWithinHomeDistanceFromPosition(blockpos1) && this.shouldMoveTo(this.theEntity.worldObj, blockpos1))
{
this.destinationBlock = blockpos1;
return true;
}
}
}
}
}
return false;
}
示例10: generate
import net.minecraft.util.BlockPos; //導入方法依賴的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;
}
示例11: teleport
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private void teleport(World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this)
{
for (int i = 0; i < 1000; ++i)
{
BlockPos blockpos = pos.add(worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16), worldIn.rand.nextInt(8) - worldIn.rand.nextInt(8), worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16));
if (worldIn.getBlockState(blockpos).getBlock().blockMaterial == Material.air)
{
if (worldIn.isRemote)
{
for (int j = 0; j < 128; ++j)
{
double d0 = worldIn.rand.nextDouble();
float f = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
double d1 = (double)blockpos.getX() + (double)(pos.getX() - blockpos.getX()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
double d2 = (double)blockpos.getY() + (double)(pos.getY() - blockpos.getY()) * d0 + worldIn.rand.nextDouble() * 1.0D - 0.5D;
double d3 = (double)blockpos.getZ() + (double)(pos.getZ() - blockpos.getZ()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d1, d2, d3, (double)f, (double)f1, (double)f2, new int[0]);
}
}
else
{
worldIn.setBlockState(blockpos, iblockstate, 2);
worldIn.setBlockToAir(pos);
}
return;
}
}
}
}
示例12: generate
import net.minecraft.util.BlockPos; //導入方法依賴的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.netherrack)
{
worldIn.setBlockState(blockpos, Blocks.fire.getDefaultState(), 2);
}
}
return true;
}
示例13: generate
import net.minecraft.util.BlockPos; //導入方法依賴的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.provider.getHasNoSky() || blockpos.getY() < 255) && this.flower.canBlockStay(worldIn, blockpos, this.field_175915_b))
{
worldIn.setBlockState(blockpos, this.field_175915_b, 2);
}
}
return true;
}
示例14: setPosition
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public void setPosition(BlockPos pos)
{
this.stopCompileTask();
this.position = pos;
this.boundingBox = new AxisAlignedBB(pos, pos.add(16, 16, 16));
for (EnumFacing enumfacing : EnumFacing.values())
{
this.field_181702_p.put(enumfacing, pos.offset(enumfacing, 16));
}
this.initModelviewMatrix();
}
示例15: generate
import net.minecraft.util.BlockPos; //導入方法依賴的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() > 1)
{
position = position.down();
}
if (position.getY() < 1)
{
return false;
}
else
{
position = position.up();
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(4) - rand.nextInt(4), rand.nextInt(3) - rand.nextInt(3), rand.nextInt(4) - rand.nextInt(4));
if (worldIn.isAirBlock(blockpos) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos.down()))
{
worldIn.setBlockState(blockpos, Blocks.chest.getDefaultState(), 2);
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityChest)
{
WeightedRandomChestContent.generateChestContents(rand, this.chestItems, (TileEntityChest)tileentity, this.itemsToGenerateInBonusChest);
}
BlockPos blockpos1 = blockpos.east();
BlockPos blockpos2 = blockpos.west();
BlockPos blockpos3 = blockpos.north();
BlockPos blockpos4 = blockpos.south();
if (worldIn.isAirBlock(blockpos2) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos2.down()))
{
worldIn.setBlockState(blockpos2, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos1) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos1.down()))
{
worldIn.setBlockState(blockpos1, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos3) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos3.down()))
{
worldIn.setBlockState(blockpos3, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos4) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos4.down()))
{
worldIn.setBlockState(blockpos4, Blocks.torch.getDefaultState(), 2);
}
return true;
}
}
return false;
}
}