net.minecraft.util.math.BlockPos#getZ ( )源码实例Demo

下面列出了net.minecraft.util.math.BlockPos#getZ ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Wizardry   文件: BlockOrbHolder.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack heldItem = playerIn.getHeldItem(hand);

	TileOrbHolder te = getTE(worldIn, pos);

	if (!te.containsCell()) {
		if (heldItem.getItem() == ModItems.ORB || heldItem.getItem() == ModItems.PEARL_NACRE) {
			te.setItemStack(heldItem.copy());
			te.getItemStack().setCount(1);
			heldItem.shrink(1);
		} else return false;

	} else {
		ItemStack stack = te.getItemStack().copy();

		te.setItemStack(ItemStack.EMPTY);
		if (playerIn.inventory.addItemStackToInventory(stack)) playerIn.openContainer.detectAndSendChanges();
		else {
			EntityItem entityItem = new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
			worldIn.spawnEntity(entityItem);
		}
	}
	te.markDirty();
	return true;
}
 
源代码2 项目: litematica   文件: WorldUtils.java
public static void loadChunksClientWorld(WorldClient world, BlockPos origin, Vec3i areaSize)
{
    BlockPos posEnd = origin.add(PositionUtils.getRelativeEndPositionFromAreaSize(areaSize));
    BlockPos posMin = fi.dy.masa.malilib.util.PositionUtils.getMinCorner(origin, posEnd);
    BlockPos posMax = fi.dy.masa.malilib.util.PositionUtils.getMaxCorner(origin, posEnd);
    final int cxMin = posMin.getX() >> 4;
    final int czMin = posMin.getZ() >> 4;
    final int cxMax = posMax.getX() >> 4;
    final int czMax = posMax.getZ() >> 4;

    for (int cz = czMin; cz <= czMax; ++cz)
    {
        for (int cx = cxMin; cx <= cxMax; ++cx)
        {
            world.getChunkProvider().loadChunk(cx, cz);
        }
    }
}
 
源代码3 项目: GregTech   文件: RecipeLogicSteam.java
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
源代码4 项目: EnderZoo   文件: EntityUtil.java
public static BlockPos findRandomLandingSurface(EntityLiving entity, int searchRange, int minY, int maxY) {
  BlockPos ep = entity.getPosition();
  World worldObj = entity.getEntityWorld();
  int x = ep.getX() + -searchRange + (worldObj.rand.nextInt(searchRange + 1) * 2);
  int z = ep.getZ() + -searchRange + (worldObj.rand.nextInt(searchRange + 1) * 2);
  return findClearLandingSurface(entity, x, z, minY, maxY);
}
 
源代码5 项目: Galacticraft-Rewoven   文件: ScorchedRockBlock.java
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
    double x = (double) pos.getX() + random.nextDouble() * 0.10000000149011612D;
    double y = (double) pos.getY() + random.nextDouble();
    double z = (double) pos.getZ() + random.nextDouble();

    world.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, 0.0D, 0.0D, 0.0D);
}
 
源代码6 项目: litematica   文件: PositionUtils.java
/**
 * Mirrors and then rotates the given position around the origin
 */
public static BlockPos getTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation)
{
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    boolean isMirrored = true;

    switch (mirror)
    {
        // LEFT_RIGHT is essentially NORTH_SOUTH
        case LEFT_RIGHT:
            z = -z;
            break;
        // FRONT_BACK is essentially EAST_WEST
        case FRONT_BACK:
            x = -x;
            break;
        default:
            isMirrored = false;
    }

    switch (rotation)
    {
        case CLOCKWISE_90:
            return new BlockPos(-z, y,  x);
        case COUNTERCLOCKWISE_90:
            return new BlockPos( z, y, -x);
        case CLOCKWISE_180:
            return new BlockPos(-x, y, -z);
        default:
            return isMirrored ? new BlockPos(x, y, z) : pos;
    }
}
 
源代码7 项目: litematica   文件: ChunkCacheSchematic.java
@Nullable
public TileEntity getTileEntity(BlockPos pos, Chunk.EnumCreateEntityType type)
{
    int i = (pos.getX() >> 4) - this.chunkStartX;
    int j = (pos.getZ() >> 4) - this.chunkStartZ;
    return this.chunkArray[i][j].getTileEntity(pos, type);
}
 
源代码8 项目: litematica   文件: RenderUtils.java
public static void drawBlockBoundingBoxOutlinesBatchedLines(BlockPos pos, Color4f color, double expand, BufferBuilder buffer,
        Entity renderViewEntity, float partialTicks)
{
    double dx = renderViewEntity.lastTickPosX + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * partialTicks;
    double dy = renderViewEntity.lastTickPosY + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * partialTicks;
    double dz = renderViewEntity.lastTickPosZ + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * partialTicks;
    double minX = pos.getX() - dx - expand;
    double minY = pos.getY() - dy - expand;
    double minZ = pos.getZ() - dz - expand;
    double maxX = pos.getX() - dx + expand + 1;
    double maxY = pos.getY() - dy + expand + 1;
    double maxZ = pos.getZ() - dz + expand + 1;

    fi.dy.masa.malilib.render.RenderUtils.drawBoxAllEdgesBatchedLines(minX, minY, minZ, maxX, maxY, maxZ, color, buffer);
}
 
源代码9 项目: Valkyrien-Skies   文件: VSWorldEventListener.java
@Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
    if (!worldObj.isRemote) {
        for (EntityPlayer entityplayermp : worldObj.playerEntities) {
            if (entityplayermp != null && entityplayermp.getEntityId() != breakerId) {
                Vector posVector = new Vector(pos.getX(), pos.getY(), pos.getZ());

                Optional<PhysicsObject> physicsObject = ValkyrienUtils
                    .getPhysicsObject(worldObj, pos);

                physicsObject.ifPresent(object -> object
                    .getShipTransformationManager()
                    .getCurrentTickTransform()
                    .transform(posVector,
                        TransformType.SUBSPACE_TO_GLOBAL));

                double d0 = posVector.X - entityplayermp.posX;
                double d1 = posVector.Y - entityplayermp.posY;
                double d2 = posVector.Z - entityplayermp.posZ;

                if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
                    ((EntityPlayerMP) entityplayermp).connection
                        .sendPacket(new SPacketBlockBreakAnim(breakerId, pos, progress));
                }
            }
        }
    }
}
 
源代码10 项目: AdvancedRocketry   文件: BlockElectricMushroom.java
@Override
public void updateTick(World world, BlockPos pos, IBlockState state,
		Random rand) {
	if(!world.isRemote && Configuration.electricPlantsSpawnLightning && world.isRaining() && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		int lightningX = pos.getX() + rand.nextInt(24) - 12;
		int lightningZ = pos.getZ() + rand.nextInt(24) - 12;
		BlockPos lightning = new BlockPos(lightningX, 0, lightningZ );
		lightning = world.getTopSolidOrLiquidBlock(lightning);
		
		world.addWeatherEffect(new EntityLightningBolt(world, lightning.getX(), lightning.getY(), lightning.getZ(), true));
	}
}
 
源代码11 项目: Valkyrien-Skies   文件: WorldPhysicsCollider.java
private boolean handleLikelyCollision(BlockPos inWorldPos, BlockPos inLocalPos,
    IBlockState inWorldState,
    IBlockState inLocalState) {
    // System.out.println("Handling a likely collision");
    AxisAlignedBB inLocalBB = new AxisAlignedBB(inLocalPos.getX(), inLocalPos.getY(),
        inLocalPos.getZ(),
        inLocalPos.getX() + 1, inLocalPos.getY() + 1, inLocalPos.getZ() + 1);
    AxisAlignedBB inGlobalBB = new AxisAlignedBB(inWorldPos.getX(), inWorldPos.getY(),
        inWorldPos.getZ(),
        inWorldPos.getX() + 1, inWorldPos.getY() + 1, inWorldPos.getZ() + 1);

    // This changes the box bounding box to the real bounding box, not sure if this
    // is better or worse for this mod
    // List<AxisAlignedBB> colBB = worldObj.getCollisionBoxes(inLocalBB);
    // inLocalBB = colBB.get(0);

    Polygon shipInWorld = new Polygon(inLocalBB,
        parent.getShipTransformationManager().getCurrentPhysicsTransform(),
        TransformType.SUBSPACE_TO_GLOBAL);
    Polygon worldPoly = new Polygon(inGlobalBB);
    PhysPolygonCollider collider = new PhysPolygonCollider(shipInWorld, worldPoly,
        parent.getShipTransformationManager().normals);
    if (!collider.seperated) {
        return handleActualCollision(collider, inWorldPos, inLocalPos, inWorldState,
            inLocalState);
    }

    return false;
}
 
源代码12 项目: enderutilities   文件: TileEntityElevator.java
private Vec3d getMoveVector(boolean goingUp)
{
    BlockPos center = goingUp ? this.getPos().up() : this.getPos().down();
    int rangeHorizontal = 64;
    int rangeVerticalUp = goingUp ? 256 : 0;
    int rangeVerticalDown = goingUp ? 0 : 256;

    IBlockState state = this.getWorld().getBlockState(this.getPos());

    if ((state.getBlock() instanceof BlockElevator) == false)
    {
        EnderUtilities.logger.warn("Wrong block in {}#getMoveVector", this.getClass().getSimpleName());
        return null;
    }

    List<BlockPosDistance> elevators = PositionUtils.getTileEntityPositions(this.getWorld(), center,
            rangeHorizontal, rangeVerticalUp, rangeVerticalDown, isMatchingElevator(state.getValue(BlockElevator.COLOR)));

    if (elevators.size() > 0)
    {
        World world = this.getWorld();
        BlockPos posFound = elevators.get(0).pos;
        AxisAlignedBB bbThis = world.getBlockState(this.getPos()).getBoundingBox(world, this.getPos());
        AxisAlignedBB bbFound = world.getBlockState(posFound).getBoundingBox(world, posFound);
        double yDiff = (posFound.getY() + bbFound.maxY) - (this.getPos().getY() + bbThis.maxY);
        return new Vec3d(posFound.getX() - this.getPos().getX(), yDiff, posFound.getZ() - this.getPos().getZ());
    }

    return null;
}
 
源代码13 项目: TFC2   文件: WeatherRenderer.java
public static void addRainParticles(Random random, int rendererUpdateCount)
{
	Minecraft mc = Minecraft.getMinecraft();
	WorldClient worldclient = mc.world;
	if(worldclient.provider.getDimension() != 0)
		return;
	float rainStrength = (float)WeatherManager.getInstance().getPrecipitation((int)mc.player.posX, (int)mc.player.posZ);
	double tempPlayer = WeatherManager.getInstance().getTemperature((int)mc.player.posX,(int)mc.player.posY, (int)mc.player.posZ);
	if(tempPlayer <= 0)
		return;

	if (!mc.gameSettings.fancyGraphics)
	{
		rainStrength /= 2.0F;
	}

	if (rainStrength > 0.0F)
	{
		worldclient.rand.setSeed((long)rendererUpdateCount * 312987231L);
		Entity entity = mc.getRenderViewEntity();
		BlockPos blockpos = new BlockPos(entity);
		byte b0 = 10;
		double d0 = 0.0D;
		double d1 = 0.0D;
		double d2 = 0.0D;
		int i = 0;
		int rainParticles = Math.max((int)(100.0F * rainStrength * rainStrength), 4);

		if (mc.gameSettings.particleSetting == 1)
		{
			rainParticles >>= 1;
		}
		else if (mc.gameSettings.particleSetting == 2)
		{
			rainParticles = 0;
		}

		for (int k = 0; k < rainParticles; ++k)
		{
			BlockPos blockPos1 = worldclient.getPrecipitationHeight(blockpos.add(worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0), 0, worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0)));
			double temp = WeatherManager.getInstance().getTemperature(blockPos1);
			BlockPos blockpos2 = blockPos1.down();
			IBlockState state = worldclient.getBlockState(blockpos2);
			Block block = worldclient.getBlockState(blockpos2).getBlock();

			if (blockPos1.getY() <= blockpos.getY() + b0 && blockPos1.getY() >= blockpos.getY() - b0 && temp > 0)
			{
				float f1 = worldclient.rand.nextFloat();
				float f2 = worldclient.rand.nextFloat();
				AxisAlignedBB axisalignedbb = state.getBoundingBox(worldclient, blockpos2);

				if (block.getMaterial(state) == Material.LAVA)
				{
					mc.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)((float)blockPos1.getX() + f1), (double)((float)blockPos1.getY() + 0.1F) - axisalignedbb.minY, (double)((float)blockPos1.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]);
				}
				else if (block.getMaterial(state) != Material.AIR)
				{
					//block.setBlockBoundsBasedOnState(worldclient, blockpos2);
					++i;

					if (worldclient.rand.nextInt(i) == 0)
					{
						d0 = (double)((float)blockpos2.getX() + f1);
						d1 = (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY - 1.0D;
						d2 = (double)((float)blockpos2.getZ() + f2);
					}

					mc.world.spawnParticle(EnumParticleTypes.WATER_DROP, (double)((float)blockpos2.getX() + f1), (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY, (double)((float)blockpos2.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]);
				}
			}
		}

		if (i > 0 && worldclient.rand.nextInt(3) < rainSoundCounter++)
		{
			rainSoundCounter = 0;

			if (d1 > (double)(blockpos.getY() + 1) && worldclient.getPrecipitationHeight(blockpos).getY() > MathHelper.floor((float)blockpos.getY()))
			{
				mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN_ABOVE, SoundCategory.WEATHER, 0.1F*rainStrength, 0.5F, false);
			}
			else
			{
				mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN, SoundCategory.WEATHER, 0.2F*rainStrength, 1.0F, false);
			}
		}
	}
}
 
源代码14 项目: Sakura_mod   文件: WorldGenBigSakura.java
public FoliageCoordinates(BlockPos pos, int p_i45635_2_)
{
    super(pos.getX(), pos.getY(), pos.getZ());
    this.branchBase = p_i45635_2_;
}
 
源代码15 项目: TFC2   文件: EntityAIWanderHex.java
@Nullable
public static Vec3d generateRandomPosInCenter(EntityCreature entity, int xz, int y,boolean pathThroughWater, IslandMap map, Center c)
{
	PathNavigate pathnavigate = entity.getNavigator();
	Random random = entity.getRNG();
	boolean flag;
	BlockPos centerPos = c.point.toBlockPos().add(map.getParams().getWorldX(), 0, map.getParams().getWorldZ());

	if (entity.hasHome())
	{
		double d0 = entity.getHomePosition().distanceSq((double)MathHelper.floor(entity.posX), (double)MathHelper.floor(entity.posY), (double)MathHelper.floor(entity.posZ)) + 4.0D;
		double d1 = (double)(entity.getMaximumHomeDistance() + (float)xz);
		flag = d0 < d1 * d1;
	}
	else
	{
		flag = false;
	}

	boolean flag1 = false;
	float weight = -99999.0F;
	int outX = 0;
	int outY = 0;
	int outZ = 0;

	for (int k = 0; k < 10; ++k)
	{
		int _x = random.nextInt(2 * xz + 1) - xz;
		int _y = random.nextInt(2 * y + 1) - y;
		int _z = random.nextInt(2 * xz + 1) - xz;


		if (entity.hasHome() && xz > 1)
		{
			BlockPos blockpos = entity.getHomePosition();

			if (entity.posX > (double)blockpos.getX())
			{
				_x -= random.nextInt(xz / 2);
			}
			else
			{
				_x += random.nextInt(xz / 2);
			}

			if (entity.posZ > (double)blockpos.getZ())
			{
				_z -= random.nextInt(xz / 2);
			}
			else
			{
				_z += random.nextInt(xz / 2);
			}
		}

		BlockPos blockpos1 = new BlockPos((double)_x + centerPos.getX(), (double)_y + centerPos.getY(), (double)_z + centerPos.getZ());

		if ((!flag || entity.isWithinHomeDistanceFromPosition(blockpos1)) && pathnavigate.canEntityStandOnPos(blockpos1))
		{
			if (!pathThroughWater)
			{
				blockpos1 = moveAboveSolid(blockpos1, entity);

				if (isWaterDestination(blockpos1, entity))
				{
					continue;
				}
			}

			float _weight = entity.getBlockPathWeight(blockpos1);

			if (_weight > weight)
			{
				weight = _weight;
				outX = _x;
				outY = _y;
				outZ = _z;
				flag1 = true;
			}
		}
	}

	if (flag1)
	{
		return new Vec3d((double)outX + centerPos.getX(), (double)outY + centerPos.getY(), (double)outZ + centerPos.getZ());
	}
	else
	{
		return null;
	}
}
 
源代码16 项目: multiconnect   文件: ChunkUpgrader.java
public static UpgradeData fixChunk(WorldChunk chunk) {
    IntList centerIndicesToUpgrade = new IntArrayList();
    int sidesToUpgrade = 0;

    BlockPos.Mutable otherPos = new BlockPos.Mutable();
    for (BlockPos pos : BlockPos.iterate(chunk.getPos().getStartX(), 0, chunk.getPos().getStartZ(),
            chunk.getPos().getEndX(), chunk.getHighestNonEmptySectionYOffset() + 15, chunk.getPos().getEndZ())) {
        BlockState state = chunk.getBlockState(pos);
        Block block = state.getBlock();
        inPlaceFix(chunk, state, pos, otherPos);

        int blockId = Registry.BLOCK.getRawId(block) & 4095;
        if (ChunkPalettedStorageFixAccessor.getBlocksNeedingSideUpdate().get(blockId)) {
            boolean west = (pos.getX() & 15) == 0;
            boolean east = (pos.getX() & 15) == 15;
            boolean north = (pos.getZ() & 15) == 0;
            boolean south = (pos.getZ() & 15) == 15;
            if (north) {
                if (east) {
                    sidesToUpgrade |= 2;
                } else if (west) {
                    sidesToUpgrade |= 128;
                } else {
                    sidesToUpgrade |= 1;
                }
            } else if (south) {
                if (west) {
                    sidesToUpgrade |= 32;
                } else if (east) {
                    sidesToUpgrade |= 8;
                } else {
                    sidesToUpgrade |= 16;
                }
            } else if (east) {
                sidesToUpgrade |= 4;
            } else if (west) {
                sidesToUpgrade |= 64;
            } else {
                centerIndicesToUpgrade.add(pos.getY() << 8 | (pos.getZ() & 15) << 4 | (pos.getX() & 15));
            }
        }
    }

    if (centerIndicesToUpgrade.isEmpty() && sidesToUpgrade == 0)
        return null;

    CompoundTag upgradeData = new CompoundTag();
    upgradeData.putInt("Sides", sidesToUpgrade);
    CompoundTag centerIndices = new CompoundTag();
    centerIndicesToUpgrade.forEach((IntConsumer) index -> {
        int low = index & 4095;
        int high = index >>> 12;
        Tag tag = centerIndices.get(String.valueOf(high));
        if (tag == null)
            centerIndices.put(String.valueOf(high), tag = new ListTag());
        ((ListTag) tag).add(IntTag.of(low));
    });
    for (String key : centerIndices.getKeys()) {
        //noinspection ConstantConditions
        centerIndices.put(key, new IntArrayTag(((ListTag) centerIndices.get(key)).stream().mapToInt(val -> ((IntTag) val).getInt()).toArray()));
    }
    upgradeData.put("Indices", centerIndices);
    return new UpgradeData(upgradeData);
}
 
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int num = rand.nextInt(5);
    EnumFacing orientation;
    if (num == 0) {
        orientation = EnumFacing.EAST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.WEST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.SOUTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    } else {
        orientation = EnumFacing.NORTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    }
    int i = rand.nextInt(2) + this.minTreeLength;
    boolean flag = true;

    if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;

            if (j == position.getY()) {
                k = 0;
            }

            if (j >= position.getY() + 1 + i - 2) {
                k = 2;
            }

            BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();

            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < worldIn.getHeight()) {
                        if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }

        if (!flag) {
            return false;
        } else {
            IBlockState state = worldIn.getBlockState(position.down());

            if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
                state.getBlock().onPlantGrow(state, worldIn, position.down(), position);

                for (int j3 = 0; j3 < i; ++j3) {
                    BlockPos offsetPos = position.offset(orientation, j3);
                    state = worldIn.getBlockState(offsetPos);

                    if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) {
                        this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood);
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}
 
源代码18 项目: enderutilities   文件: BlockPosBox.java
public boolean containsPosition(BlockPos pos)
{
    return pos.getX() >= this.posMin.getX() && pos.getX() <= this.posMax.getX() &&
            pos.getY() >= this.posMin.getY() && pos.getY() <= this.posMax.getY() &&
            pos.getZ() >= this.posMin.getZ() && pos.getZ() <= this.posMax.getZ();
}
 
源代码19 项目: enderutilities   文件: BlockPosEU.java
public BlockPosEU(BlockPos pos)
{
    this(pos.getX(), pos.getY(), pos.getZ());
}
 
源代码20 项目: Sakura_mod   文件: WorldGenSakuraTree.java
public boolean generate(World worldIn, Random rand, BlockPos position) {
      int i = rand.nextInt(3) + this.minTreeHeight;
      boolean flag = true;

      if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
          for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
              int k = 1;

              if (j == position.getY()) {
                  k = 0;
              }

              if (j >= position.getY() + 1 + i - 2) {
                  k = 2;
              }

              BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

              for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                  for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                      if (j >= 0 && j < worldIn.getHeight()) {
                          if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) {
                              flag = false;
                          }
                      } else {
                          flag = false;
                      }
                  }
              }
          }

          if (!flag) {
              return false;
          }
	IBlockState state = worldIn.getBlockState(position.down());

	if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
	    state.getBlock().onPlantGrow(state, worldIn, position.down(), position);

	    for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
	        int i4 = i3 - (position.getY() + i);
	        int j1 = 1 - i4 / 2;

	        for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
	            int l1 = k1 - position.getX();

	            for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
	                int j2 = i2 - position.getZ();

	                if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) {
	                    BlockPos blockpos = new BlockPos(k1, i3, i2);
	                    state = worldIn.getBlockState(blockpos);

	                    if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
	                        this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
	                    }
	                }
	            }
	        }
	    }

	    for (int j3 = 0; j3 < i; ++j3) {
	        BlockPos upN = position.up(j3);
	        state = worldIn.getBlockState(upN);

	        if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
	            this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);

	        }
	    }

	    return true;
	}
	return false;
      }
return false;
  }