本文整理汇总了Java中net.minecraft.util.math.BlockPos.add方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPos.add方法的具体用法?Java BlockPos.add怎么用?Java BlockPos.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.BlockPos
的用法示例。
在下文中一共展示了BlockPos.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decorate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public void decorate(World worldIn, Random rand, BlockPos pos)
{
super.decorate(worldIn, rand, pos);
int i = 3 + rand.nextInt(6);
for (int j = 0; j < i; ++j)
{
int k = rand.nextInt(16);
int l = rand.nextInt(28) + 4;
int i1 = rand.nextInt(16);
BlockPos blockpos = pos.add(k, l, i1);
if (worldIn.getBlockState(blockpos).getBlock() == Blocks.STONE)
{
worldIn.setBlockState(blockpos, Blocks.EMERALD_ORE.getDefaultState(), 2);
}
}
for (i = 0; i < 7; ++i)
{
int j1 = rand.nextInt(16);
int k1 = rand.nextInt(64);
int l1 = rand.nextInt(16);
this.theWorldGenerator.generate(worldIn, rand, pos.add(j1, k1, l1));
}
}
示例2: growLeavesLayerStrict
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* grow leaves in a circle with the outsides being within the circle
*/
protected void growLeavesLayerStrict(World worldIn, BlockPos layerCenter, int width)
{
int i = width * width;
for (int j = -width; j <= width + 1; ++j)
{
for (int k = -width; k <= width + 1; ++k)
{
int l = j - 1;
int i1 = k - 1;
if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
{
BlockPos blockpos = layerCenter.add(j, 0, k);
Material material = worldIn.getBlockState(blockpos).getMaterial();
if (material == Material.AIR || material == Material.LEAVES)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
}
}
}
}
}
示例3: findPossibleShelter
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable
private Vec3d findPossibleShelter()
{
Random random = this.theCreature.getRNG();
BlockPos blockpos = new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ);
for (int i = 0; i < 10; ++i)
{
BlockPos blockpos1 = blockpos.add(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);
if (!this.theWorld.canSeeSky(blockpos1) && this.theCreature.getBlockPathWeight(blockpos1) < 0.0F)
{
return new Vec3d((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ());
}
}
return null;
}
示例4: 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);
}
}
}
}
示例5: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
if (!worldIn.isAirBlock(position)) return false;
if (worldIn.isAirBlock(position.up())) return false;
worldIn.setBlockState(position, Blocks.GLOWSTONE.getDefaultState(), 2);
for (int i = 0; i < 1500; ++i) {
BlockPos scatter = position.add(rand.nextInt(8) - rand.nextInt(8), -rand.nextInt(12), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(scatter)) {
int adjacent = 0;
for (EnumFacing enumfacing : EnumFacing.values()) {
if (worldIn.getBlockState(scatter.offset(enumfacing)).getBlock() == Blocks.GLOWSTONE) {
adjacent++;
}
if (adjacent > 1) {
break;
}
}
if (adjacent == 1) {
worldIn.setBlockState(scatter, Blocks.GLOWSTONE.getDefaultState(), 2);
}
}
}
return true;
}
示例6: isPossible
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean isPossible(World world, BlockPos pos, EnumFacing side) {
if (!InventoryTools.isInventory(world, pos)) {
return false;
}
// @todo config for pickup area
AxisAlignedBB box = new AxisAlignedBB(pos.add(-10, -10, -10), pos.add(10, 10, 10));
return !world.getEntitiesWithinAABB(EntityItem.class, box).isEmpty();
}
示例7: findSpotToFlatten
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* Returns absolute position
*/
@Override
public BlockPos findSpotToFlatten(@Nonnull IBuildSchematic schematic) {
BlockPos tpos = options.getTargetPos();
BlockPos minPos = schematic.getMinPos();
BlockPos maxPos = schematic.getMaxPos();
List<BlockPos> todo = new ArrayList<>();
for (int x = minPos.getX(); x <= maxPos.getX(); x++) {
for (int y = minPos.getY(); y <= maxPos.getY(); y++) {
for (int z = minPos.getZ(); z <= maxPos.getZ(); z++) {
BlockPos relativePos = new BlockPos(x, y, z);
BlockPos p = tpos.add(relativePos);
IBlockState state = entity.getWorld().getBlockState(p);
IDesiredBlock desired = schematic.getDesiredBlock(relativePos);
if (desired != IGNORE) {
if (!desired.getStateMatcher().test(state) && !entity.getWorld().isAirBlock(p) && !positionsToSkip.contains(p)) {
todo.add(p);
}
}
}
}
}
if (todo.isEmpty()) {
return null;
}
BlockPos position = entity.getEntity().getPosition();
todo.sort((o1, o2) -> {
double d1 = position.distanceSq(o1);
double d2 = position.distanceSq(o2);
return Double.compare(d1, d2);
});
return todo.get(0);
}
示例8: generate
import net.minecraft.util.math.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;
}
示例9: findSpotToBuild
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* Return the relative spot to build
*/
@Override
public BlockPos findSpotToBuild(@Nonnull IBuildSchematic schematic, @Nonnull BuildProgress progress, @Nonnull Set<BlockPos> toSkip) {
BlockPos tpos = options.getTargetPos();
BlockPos minPos = schematic.getMinPos();
BlockPos maxPos = schematic.getMaxPos();
List<BlockPos> todo = new ArrayList<>();
for (int x = minPos.getX(); x <= maxPos.getX(); x++) {
for (int z = minPos.getZ(); z <= maxPos.getZ(); z++) {
BlockPos relativePos = new BlockPos(x, progress.getHeight(), z);
if (!toSkip.contains(relativePos)) {
BlockPos p = tpos.add(relativePos);
IBlockState state = entity.getWorld().getBlockState(p);
IDesiredBlock desired = schematic.getDesiredBlock(relativePos);
if (desired.getPass() == progress.getPass() && !desired.getStateMatcher().test(state) && !positionsToSkip.contains(p)) {
todo.add(relativePos);
}
}
}
}
if (todo.isEmpty()) {
if (!progress.next(schematic)) {
return null; // Done
}
return findSpotToBuild(schematic, progress, toSkip);
}
BlockPos position = entity.getEntity().getPosition().subtract(tpos); // Make entity position relative for distance calculation
todo.sort((o1, o2) -> {
double d1 = position.distanceSq(o1);
double d2 = position.distanceSq(o2);
return Double.compare(d1, d2);
});
return todo.get(0);
}
示例10: 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 = 1;
int j = 2;
int k = pos.getX();
int l = pos.getY();
int i1 = pos.getZ();
if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2)))
{
for (int j1 = -1; j1 <= 1; ++j1)
{
for (int k1 = -1; k1 <= 1; ++k1)
{
for (int l1 = -1; l1 <= 1; ++l1)
{
BlockPos blockpos = pos.add(j1, k1, l1);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.LEAVES && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
{
worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
}
}
}
}
}
}
示例11: teleport
import net.minecraft.util.math.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) + 0.5D;
double d2 = (double)blockpos.getY() + (double)(pos.getY() - blockpos.getY()) * d0 + worldIn.rand.nextDouble() - 0.5D;
double d3 = (double)blockpos.getZ() + (double)(pos.getZ() - blockpos.getZ()) * d0 + (worldIn.rand.nextDouble() - 0.5D) + 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: grow
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
BlockPos blockpos = pos.up();
for (int i = 0; i < 128; ++i)
{
BlockPos blockpos1 = blockpos;
int j = 0;
while (true)
{
if (j >= i / 16)
{
if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.AIR)
{
if (rand.nextInt(8) == 0)
{
BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiome(blockpos1).pickRandomFlower(rand, blockpos1);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);
if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
{
worldIn.setBlockState(blockpos1, iblockstate, 3);
}
}
else
{
IBlockState iblockstate1 = Blocks.TALLGRASS.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);
if (Blocks.TALLGRASS.canBlockStay(worldIn, blockpos1, iblockstate1))
{
worldIn.setBlockState(blockpos1, iblockstate1, 3);
}
}
}
break;
}
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.GRASS || worldIn.getBlockState(blockpos1).isNormalCube())
{
break;
}
++j;
}
}
}
示例13: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean generate(World world, Random rand, BlockPos position) {
BlockPos pos = NeoHellGenerators.findSurface(world, position);
if (pos==null) {
//System.out.println("Failed to generate at "+position);
return false;
} else {
//System.out.println("Generating at "+pos);
}
int height = rand.nextInt(4) + 7;
IBlockState trunkState = Blocks.BONE_BLOCK.getDefaultState().withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
//EnumFacing.Axis axis = rand.nextBoolean() ? EnumFacing.Axis.X : EnumFacing.Axis.Z;
EnumAxis axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
BlockPos section = pos;
for(int y=0; y<height; y++) {
world.setBlockState(section, trunkState);
if (y>3 && y%2==0) {
axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
BlockPos arm = section;
int width = (height-y) / 2;
for(int i=0; i<width; i++) {
arm = arm.add(axis.xofs, axis.yofs, axis.zofs);
world.setBlockState(arm, axis==EnumAxis.X ?
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
}
arm = section;
for(int i=0; i<width; i++) {
arm = arm.add(-axis.xofs, -axis.yofs, -axis.zofs);
world.setBlockState(arm, axis==EnumAxis.X ?
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
}
}
section = section.up();
}
return true;
}
示例14: getRedstoneValue
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
AxisAlignedBB aabb = new AxisAlignedBB(pos.add(-sensorRange, -sensorRange, -sensorRange), pos.add(1 + sensorRange, 1 + sensorRange, 1 + sensorRange));
return getRedstoneValue(world.getEntitiesWithinAABB(getEntityTracked(), aabb), textBoxText);
}
示例15: right
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static BlockPos right(EnumFacing facing, BlockPos pos, int i) {
Stepper stepper = rightSteppers.get(facing);
return pos.add(stepper.x * i, 0, stepper.z * i);
}