當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockPos.add方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:BiomeHills.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:WorldGenHugeTrees.java

示例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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:EntityAIFleeSun.java

示例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);
			}
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:25,代碼來源:AutoPlantBrew.java

示例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;
}
 
開發者ID:elytra,項目名稱:ThermionicsWorld,代碼行數:32,代碼來源:NeoHellGenerators.java

示例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();
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:11,代碼來源:PickupActionFactory.java

示例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);
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:38,代碼來源:WorkerHelper.java

示例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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:15,代碼來源:WorldGenPumpkin.java

示例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);
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:38,代碼來源:WorkerHelper.java

示例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);
                    }
                }
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:32,代碼來源:BlockLeaves.java

示例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;
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:38,代碼來源:BlockDragonEgg.java

示例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;
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:52,代碼來源:BlockGrass.java

示例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;
}
 
開發者ID:elytra,項目名稱:ThermionicsWorld,代碼行數:46,代碼來源:GeneratorBoneTree.java

示例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);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:6,代碼來源:EntityPollSensor.java

示例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);
}
 
開發者ID:JustinSDK,項目名稱:craftsman,代碼行數:5,代碼來源:FstWalker.java


注:本文中的net.minecraft.util.math.BlockPos.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。