Java Code Examples for net.minecraft.util.math.BlockPos#getX()
The following examples show how to use
net.minecraft.util.math.BlockPos#getX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TofuVillage.java From TofuCraftReload with MIT License | 6 votes |
/** * Checks to see if the volume around blockLocation is clear and able to fit blockSize */ private boolean isAreaClearAround(BlockPos blockSize, BlockPos blockLocation) { if (!this.world.getBlockState(blockLocation.down()).isSideSolid(world, blockLocation, EnumFacing.UP)) { return false; } else { int i = blockLocation.getX() - blockSize.getX() / 2; int j = blockLocation.getZ() - blockSize.getZ() / 2; for (int k = i; k < i + blockSize.getX(); ++k) { for (int l = blockLocation.getY(); l < blockLocation.getY() + blockSize.getY(); ++l) { for (int i1 = j; i1 < j + blockSize.getZ(); ++i1) { if (this.world.getBlockState(new BlockPos(k, l, i1)).isNormalCube()) { return false; } } } } return true; } }
Example 2
Source File: BlockSoyMilk.java From TofuCraftReload with MIT License | 6 votes |
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { super.randomDisplayTick(state, world, pos, rand); if (world.getBlockState(pos.up()).getMaterial() != Material.WATER && rand.nextInt(3) == 0) { if (this.getHeatStrength(world, pos) > 0) { float steamX = pos.getX() + 0.5F; float steamY = pos.getY() + 0.9F; float steamZ = pos.getZ() + 0.5F; float steamRandX = rand.nextFloat() * 0.6F - 0.3F; float steamRandZ = rand.nextFloat() * 0.6F - 0.3F; double gRand1 = rand.nextGaussian() * 0.01D; double gRand2 = rand.nextGaussian() * 0.01D; double gRand3 = rand.nextGaussian() * 0.01D; world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (steamX + steamRandX), steamY, (steamZ + steamRandZ), gRand1, gRand2, gRand3); } } }
Example 3
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public boolean useHoeArea(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, int rWidth, int rHeight) { boolean northSouth = (((int)MathHelper.floor(player.rotationYaw * 4.0f / 360.0f + 0.5f)) & 1) == 0; boolean retValue = false; if (northSouth == false) { int tmp = rWidth; rWidth = rHeight; rHeight = tmp; } for (int x = pos.getX() - rWidth; x <= (pos.getX() + rWidth); ++x) { for (int z = pos.getZ() - rHeight; z <= (pos.getZ() + rHeight); ++z) { retValue |= this.useHoe(stack, player, world, new BlockPos(x, pos.getY(), z), side); } } return retValue; }
Example 4
Source File: WorldGenCrops.java From TofuCraftReload with MIT License | 6 votes |
@Override public boolean generate(World par1World, Random par2Random, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (int l = 0; l < 64; ++l) { int i1 = x + par2Random.nextInt(8) - par2Random.nextInt(8); int j1 = y + par2Random.nextInt(4) - par2Random.nextInt(4); int k1 = z + par2Random.nextInt(8) - par2Random.nextInt(8); mutable.setPos(i1, j1, k1); IBlockState state = this.getStateToPlace(); if (par1World.isAirBlock(mutable) && this.plantBlock.canBlockStay(par1World, mutable, state)) { par1World.setBlockState(mutable, state, 2); } } return true; }
Example 5
Source File: Area.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
public void expandToFit(BlockPos bp) { if (startX == null || bp.getX() < startX) { startX = bp.getX(); } if (endX == null || bp.getX() > endX) { endX = bp.getX(); } if (startY == null || bp.getY() < startY) { startY = bp.getY(); } if (endY == null || bp.getY() > endY) { endY = bp.getY(); } if (startZ == null || bp.getZ() < startZ) { startZ = bp.getZ(); } if (endZ == null || bp.getZ() > endZ) { endZ = bp.getZ(); } }
Example 6
Source File: BlockAirshipEngineLore.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@Override public Vector getCustomBlockForcePosition(World world, BlockPos pos, IBlockState state, PhysicsObject physicsObject, double secondsToApply) { TileEntityPropellerEngine engineTile = (TileEntityPropellerEngine) world.getTileEntity(pos); if (engineTile != null) { VectorImmutable forceOutputNormal = engineTile.getForceOutputNormal(secondsToApply, physicsObject); // System.out.println(forceOutputNormal.getX() + ":" + forceOutputNormal.getY() // + ":" + forceOutputNormal.getZ()); return new Vector(pos.getX() + .5D - forceOutputNormal.getX() * .75, pos.getY() + .5D - forceOutputNormal.getY() * .75, pos.getZ() + .5D - forceOutputNormal.getZ() * .75); } else { return null; } }
Example 7
Source File: CoalGeneratorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState state, World world, BlockPos blockPos_1, Random rand) { if (world.getBlockEntity(blockPos_1) instanceof CoalGeneratorBlockEntity && ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.ACTIVE || ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.WARMING) { double x = (double) blockPos_1.getX() + 0.5D; double y = blockPos_1.getY(); double z = (double) blockPos_1.getZ() + 0.5D; if (rand.nextDouble() < 0.1D) { world.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); } Direction direction_1 = state.get(FACING); Direction.Axis direction$Axis_1 = direction_1.getAxis(); double d = rand.nextDouble() * 0.6D - 0.3D; double xo = direction$Axis_1 == Direction.Axis.X ? (double) direction_1.getOffsetX() * 0.52D : d; double yo = rand.nextDouble() * 6.0D / 16.0D; double zo = direction$Axis_1 == Direction.Axis.Z ? (double) direction_1.getOffsetZ() * 0.52D : d; world.addParticle(ParticleTypes.SMOKE, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.FLAME, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D); } }
Example 8
Source File: PositionHelper.java From malmo with MIT License | 6 votes |
public static List<BlockPos> getTouchingBlocks(EntityPlayerSP player) { // Determine which blocks we are touching. // This code is adapted from Entity, where it is used to fire the Block.onEntityCollidedWithBlock methods. BlockPos blockposmin = new BlockPos(player.getEntityBoundingBox().minX - 0.001D, player.getEntityBoundingBox().minY - 0.001D, player.getEntityBoundingBox().minZ - 0.001D); BlockPos blockposmax = new BlockPos(player.getEntityBoundingBox().maxX + 0.001D, player.getEntityBoundingBox().maxY + 0.001D, player.getEntityBoundingBox().maxZ + 0.001D); List<BlockPos> blocks = new ArrayList<BlockPos>(); if (player.world.isAreaLoaded(blockposmin, blockposmax)) { for (int i = blockposmin.getX(); i <= blockposmax.getX(); ++i) { for (int j = blockposmin.getY(); j <= blockposmax.getY(); ++j) { for (int k = blockposmin.getZ(); k <= blockposmax.getZ(); ++k) { blocks.add(new BlockPos(i, j, k)); } } } } return blocks; }
Example 9
Source File: BlockCampfirePot.java From Sakura_mod with MIT License | 5 votes |
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { double d0 = pos.getX() + 0.5D; double d2 = pos.getZ() + 0.5D; double d4 = rand.nextDouble() * 0.4D - 0.2D; if (this.isBurning) { worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D); worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D); if (rand.nextDouble() < 0.15D) { worldIn.playSound(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); } } }
Example 10
Source File: BlockLeaves.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if ((worldIn.isRainingAt(pos.up())) && (!worldIn.getBlockState(pos.down()).isFullyOpaque()) && (rand.nextInt(15) == 1)) { double d0 = pos.getX() + rand.nextFloat(); double d1 = pos.getY() - 0.05D; double d2 = pos.getZ() + rand.nextFloat(); worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); } }
Example 11
Source File: BlockWaterHyacinth.java From Production-Line with MIT License | 5 votes |
@Override public void randomTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) { int changedX = rand.nextInt(5) - 3 + pos.getX(); int changedZ = rand.nextInt(5) - 3 + pos.getZ(); BlockPos check = new BlockPos(changedX, pos.getY(), changedZ); if ((world.isAirBlock(check)) && (this.canSustainBush(world.getBlockState(check.down())))) { world.setBlockState(pos, getDefaultState()); } }
Example 12
Source File: SchematicUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Nullable public static BlockPos getSchematicContainerPositionFromWorldPosition(BlockPos worldPos, ISchematic schematic, String regionName, SchematicPlacement schematicPlacement, SubRegionPlacement regionPlacement, ILitematicaBlockStateContainer container) { ISchematicRegion region = schematic.getSchematicRegion(regionName); if (region == null) { return null; } BlockPos boxMinRel = getReverseTransformedWorldPosition(worldPos, schematic, schematicPlacement, regionPlacement, region.getSize()); if (boxMinRel == null) { return null; } final int startX = boxMinRel.getX(); final int startY = boxMinRel.getY(); final int startZ = boxMinRel.getZ(); Vec3i size = container.getSize(); /* if (startX < 0 || startY < 0 || startZ < 0 || startX >= size.getX() || startY >= size.getY() || startZ >= size.getZ()) { System.out.printf("DEBUG ============= OUT OF BOUNDS - region: %s, startX: %d, startY %s, startZ: %d - size x: %d y: %s z: %d =============\n", regionName, startX, startY, startZ, size.getX(), size.getY(), size.getZ()); return null; } return boxMinRel; */ return new BlockPos(MathHelper.clamp(startX, 0, size.getX() - 1), MathHelper.clamp(startY, 0, size.getY() - 1), MathHelper.clamp(startZ, 0, size.getZ() - 1)); }
Example 13
Source File: EntityUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
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); }
Example 14
Source File: CraftingFluidBlock.java From the-hallow with MIT License | 4 votes |
private void spawnCraftingResult(World world, BlockPos pos, ItemStack result) { ItemEntity itemEntity = new ItemEntity(world, pos.getX() + .5, pos.getY() + 1, pos.getZ() + .5, result); world.spawnEntity(itemEntity); // todo: add particles and/or an animation when dropping the recipe result }
Example 15
Source File: BlockUtils.java From OpenModsLib with MIT License | 4 votes |
public static AxisAlignedBB singleBlock(BlockPos pos) { return new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); }
Example 16
Source File: BlockUtils.java From OpenModsLib with MIT License | 4 votes |
public static AxisAlignedBB expandAround(BlockPos pos, int x, int y, int z) { return new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + x, pos.getY() + y, pos.getZ() + z); }
Example 17
Source File: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
public static TargetPoint blockPoint(World world, BlockPos blockPos) { return new TargetPoint(world.provider.getDimension(), blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5, 128.0); }
Example 18
Source File: NearbySmeltCommandsImplementation.java From malmo with MIT License | 4 votes |
@Override public IMessage onMessage(SmeltNearbyMessage message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; Vec3d headPos = new Vec3d(player.posX, player.posY + 1.6, player.posZ); // Location checking boolean closeFurnace = false; for (BlockPos furnace : furnaces) { Vec3d blockVec = new Vec3d(furnace.getX() + 0.5, furnace.getY() + 0.5, furnace.getZ() + 0.5); if (headPos.squareDistanceTo(blockVec) <= 25.0) { // Within a reasonable FOV? // Lots of trig, let's go double fov = Minecraft.getMinecraft().gameSettings.fovSetting; double height = Minecraft.getMinecraft().displayHeight; double width = Minecraft.getMinecraft().displayWidth; Vec3d lookVec = player.getLookVec(); Vec3d toBlock = blockVec.subtract(headPos); // Projection of block onto player look vector - if greater than 0, then in front of us double scalarProjection = lookVec.dotProduct(toBlock) / lookVec.lengthVector(); if (scalarProjection > 0) { Vec3d yUnit = new Vec3d(0, 1.0, 0); Vec3d lookCross = lookVec.crossProduct(yUnit); Vec3d blockProjectedOntoCross = lookCross.scale(lookCross.dotProduct(toBlock) / lookCross.lengthVector()); Vec3d blockProjectedOntoPlayerPlane = toBlock.subtract(blockProjectedOntoCross); double xyDot = lookVec.dotProduct(blockProjectedOntoPlayerPlane); double pitchTheta = Math.acos(xyDot / (lookVec.lengthVector() * blockProjectedOntoPlayerPlane.lengthVector())); Vec3d playerY = lookCross.crossProduct(lookVec); Vec3d blockProjectedOntoPlayerY = playerY.scale(playerY.dotProduct(toBlock) / playerY.lengthVector()); Vec3d blockProjectedOntoYawPlane = toBlock.subtract(blockProjectedOntoPlayerY); double xzDot = lookVec.dotProduct(blockProjectedOntoYawPlane); double yawTheta = Math.acos(xzDot / (lookVec.lengthVector() * blockProjectedOntoYawPlane.lengthVector())); if (Math.abs(Math.toDegrees(yawTheta)) <= Math.min(1, width / height) * (fov / 2.0) && Math.abs(Math.toDegrees(pitchTheta)) <= Math.min(1, height / width) * (fov / 2.0)) closeFurnace = true; } } } if (closeFurnace) { ItemStack input = CraftingHelper.getSmeltingRecipeForRequestedOutput(message.parameters); if (input != null) if (CraftingHelper.attemptSmelting(player, input)) return null; } return null; }
Example 19
Source File: WorldGenMapleTree.java From Sakura_mod with MIT License | 4 votes |
/** * Fill the given area with the selected blocks */ private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){ int xx = pos.getX(); int yy = pos.getY(); int zz = pos.getZ(); boolean setFlg = false; int YEND = 4; for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) { for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) { if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0))) { setFlg = false; int yy1 = yy + yADD; Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock(); if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) { for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--) { boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1)); cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock(); if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube()))) { if (cBl != Blocks.AIR) { break; } } else if (cAir) { setFlg = true; break; } } } if (setFlg) { setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState); } } } } }
Example 20
Source File: WorldGenBigSakura.java From Sakura_mod with MIT License | 4 votes |
public FoliageCoordinates(BlockPos pos, int p_i45635_2_) { super(pos.getX(), pos.getY(), pos.getZ()); this.branchBase = p_i45635_2_; }