Java Code Examples for net.minecraft.util.math.BlockPos#getY()
The following examples show how to use
net.minecraft.util.math.BlockPos#getY() .
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: NukerModule.java From seppuku with GNU General Public License v3.0 | 8 votes |
private BlockPos getClosestBlockAll() { final Minecraft mc = Minecraft.getMinecraft(); float maxDist = this.distance.getValue(); BlockPos ret = null; for (float x = maxDist; x >= -maxDist; x--) { for (float y = maxDist; y >= -maxDist; y--) { for (float z = maxDist; z >= -maxDist; z--) { final BlockPos pos = new BlockPos(mc.player.posX + x, mc.player.posY + y, mc.player.posZ + z); final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ()); if (dist <= maxDist && (mc.world.getBlockState(pos).getBlock() != Blocks.AIR && !(mc.world.getBlockState(pos).getBlock() instanceof BlockLiquid)) && canBreak(pos)) { if (pos.getY() >= mc.player.posY) { maxDist = (float) dist; ret = pos; } } } } } return ret; }
Example 2
Source File: GraveyardGenerator.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
private boolean levelEnough(BlockPos pos, int rows, int cols) { int max = 0, min = 1000; int y; BlockPos surf; for (int x = -2; x <= cols * 2; x++) { for (int z = -1; z <= rows * 4 - 2; z++) { surf = findSurface(pos.add(x, 0, z)); if (surf == null) { return false; } y = surf.getY(); max = Math.max(y, max); min = Math.min(y, min); } } return max - min < 5; }
Example 3
Source File: TreeHandler.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) { MutableBlockPos start = new MutableBlockPos(pos); while (canBreak(world, start)) { start.move(EnumFacing.UP); } start.move(EnumFacing.DOWN); if (start.getY() >= pos.getY()) { BlockPos target = search(world, pos); IBlockState targetState = world.getBlockState(target); targetState.getBlock().breakBlock(world, pos, state); PlantHarvestHelper.breakBlockHandleDrop(world, target, targetState, chest); return true; } return false; }
Example 4
Source File: WorldGenBigSakura.java From Sakura_mod with MIT License | 6 votes |
/** * 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; } for (int j = 0; j <= i; ++j) { BlockPos blockpos1 = posOne.add(0.5F + j * f, 0.5F + j * f1, 0.5F + j * f2); if (!this.isReplaceable(world, blockpos1)) { return j; } } return -1; }
Example 5
Source File: BlockMapleLeaveRed.java From Sakura_mod with MIT License | 6 votes |
@SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { Blocks.LEAVES.randomDisplayTick(stateIn, worldIn, pos, rand); if (rand.nextInt(40) == 0) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; double d0 = pos.getX() + 0.5D + 0.25D * j; double d1 = pos.getY() - 0.15D; double d2 = pos.getZ() + 0.5D + 0.25D * k; double d3 = rand.nextFloat() * j * 0.1D; double d4 = ((rand.nextFloat()) * 0.055D) + 0.015D; double d5 = rand.nextFloat() * k * 0.1D; SakuraMain.proxy.spawnParticle(SakuraParticleType.MAPLERED, d0, d1, d2, d3, -d4, d5); } }
Example 6
Source File: HandItem.java From pycode-minecraft with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(ItemStack stackIn, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (world.isRemote) { return EnumActionResult.PASS; } if (stackIn.stackSize != 0) { float yaw = player.getHorizontalFacing().getHorizontalAngle(); NBTTagCompound compound = stackIn.getTagCompound(); HandEntity entity = new HandEntity(world, compound, pos.getX() + .5, pos.getY() + 1.0, pos.getZ() + .5, yaw); world.spawnEntityInWorld(entity); --stackIn.stackSize; return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
Example 7
Source File: Effects.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public static void spawnParticlesAround(World world, EnumParticleTypes type, BlockPos pos, int count, Random rand) { for (int i = 0; i < count; ++i) { int i1 = rand.nextInt(2) * 2 - 1; int j1 = rand.nextInt(2) * 2 - 1; double x1 = (double)pos.getX() + 0.5D + 0.25D * (double)i1; double y1 = (double)((float)pos.getY() + rand.nextFloat()); double z1 = (double)pos.getZ() + 0.5D + 0.25D * (double)j1; double vx = (double)(rand.nextFloat() * 1.0F * (float)i1); double vy = ((double)rand.nextFloat() - 0.5D) * 0.125D; double vz = (double)(rand.nextFloat() * 1.0F * (float)j1); world.spawnParticle(type, x1, y1, z1, vx, vy, vz); } }
Example 8
Source File: BlockConfusingCharge.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
public void explode(World world, BlockPos pos, IBlockState state, EntityLivingBase igniter) { if (!world.isRemote) { if (((Boolean) state.getValue(EXPLODE)).booleanValue()) { // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn, // (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + // 0.5F), (double)((float)pos.getZ() + 0.5F), igniter); // worldIn.spawnEntityInWorld(entitytntprimed); // worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, // 1.0F); EntityPrimedCharge entity = new EntityPrimedCharge(this, world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter); world.spawnEntity(entity); world.playSound((EntityPlayer)null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1); world.updateEntity(entity); } } }
Example 9
Source File: MessageBarrelModeUpdate.java From ExNihiloAdscensio with MIT License | 5 votes |
public MessageBarrelModeUpdate(String modeName, BlockPos pos) { this.x = pos.getX(); this.y = pos.getY(); this.z = pos.getZ(); this.modeName = modeName; }
Example 10
Source File: GTTileMagicEnergyAbsorber.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) @Override public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (this.isActive && this.portalMode && worldIn.getBlockState(this.pos.offset(EnumFacing.DOWN)).getBlock() == Blocks.END_PORTAL) { for (EnumFacing facing : EnumFacing.HORIZONTALS) { BlockPos sidePos = pos.offset(facing); if (world.getBlockState(sidePos).isFullBlock()) { continue; } for (int k = 3; k > 0; --k) { ParticleManager er = Minecraft.getMinecraft().effectRenderer; float multPos = (float) (.1 * 2) + 0.9F; double x = (double) ((float) sidePos.getX() + 0.05F + rand.nextFloat() * multPos); double y = (double) ((float) sidePos.getY() + 0.0F + rand.nextFloat() * 0.5F); double z = (double) ((float) sidePos.getZ() + 0.05F + rand.nextFloat() * multPos); double[] velocity = new double[] { 0.0D, 7.6D, 0.0D }; if (k < 4) { velocity[2] *= 0.55D; } float foo = rand.nextFloat() * .25F; float[] colour = new float[] { 0.0F, foo, foo }; er.addEffect(new EntityChargePadAuraFX(this.world, x, y, z, 8, velocity, colour, false)); } } } }
Example 11
Source File: OreProcessor.java From TFC2 with GNU General Public License v3.0 | 5 votes |
private BlockPos getMidpoint(BlockPos p0, BlockPos p1) { int x = (p0.getX() + p1.getX()) / 2; int y = (p0.getY() + p1.getY()) / 2; int z = (p0.getZ() + p1.getZ()) / 2; return new BlockPos(x, y, z); }
Example 12
Source File: Area.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isPointInArea(BlockPos bp) { if (bp.getX() >= startX && bp.getX() <= endX && bp.getY() >= startY && bp.getY() <= endY && bp.getZ() >= startZ && bp.getZ() <= endZ) { return true; } else { return false; } }
Example 13
Source File: BlockPosEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public BlockPosEU(BlockPos pos, int dim, EnumFacing facing) { this(pos.getX(), pos.getY(), pos.getZ(), dim, facing); }
Example 14
Source File: WorldGenMapleTreeGreen.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 15
Source File: TileStationDeployedAssembler.java From AdvancedRocketry with MIT License | 4 votes |
/** * Does not make sure the structure is complete, only gets max bounds! * @param world the world * @param x coord to evaluate from * @param y coord to evaluate from * @param z coord to evaluate from * @return AxisAlignedBB bounds of structure if valid otherwise null */ @Override public AxisAlignedBB getRocketPadBounds(World world, BlockPos pos2) { EnumFacing direction = RotatableBlock.getFront(world.getBlockState(pos2)).getOpposite(); int xMin, zMin, xMax, zMax, yMax, yMin; int yCurrent = pos2.getY(); int xCurrent = pos2.getX(); int zCurrent = pos2.getZ(); xMax = xMin = xCurrent; zMax = zMin = zCurrent; int xSize, zSize; yMax = ZUtils.getContinuousBlockLength(world, EnumFacing.UP, getPos().add(0,1,0), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower); //Get min and maximum Z/X bounds if(direction.getFrontOffsetX() != 0) { xSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower); zMin = ZUtils.getContinuousBlockLength(world, EnumFacing.NORTH, pos2.add(0, 0, -1), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1; zMax = ZUtils.getContinuousBlockLength(world, EnumFacing.SOUTH, pos2.add(0, 0, 1), MAX_SIZE - zMin, AdvancedRocketryBlocks.blockStructureTower); zSize = zMin + zMax; zMin = zCurrent - zMin +1; zMax = zCurrent + zMax; if(direction.getFrontOffsetX() > 0) { xMax = xCurrent + xSize - 1; xMin++; } if(direction.getFrontOffsetX() < 0) { xMin = xCurrent - xSize+1; xMax--; } } else { zSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower); xMin = ZUtils.getContinuousBlockLength(world, EnumFacing.WEST, pos2.add(-1, 0, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1; xMax = ZUtils.getContinuousBlockLength(world, EnumFacing.EAST, pos2.add(1, 0, 0), MAX_SIZE - xMin, AdvancedRocketryBlocks.blockStructureTower); xSize = xMin + xMax; xMin = xCurrent - xMin +1; xMax = xCurrent + xMax; if(direction.getFrontOffsetZ() > 0) { zMax = zCurrent + zSize - 1; zMin++; } if(direction.getFrontOffsetZ() < 0) { zMin = zCurrent - zSize+1; zMax --; } } //if tower does not meet criteria then reutrn null if(yMax < MIN_SIZE_Y || xSize < MIN_SIZE || zSize < MIN_SIZE) { return null; } return new AxisAlignedBB(xMin, yCurrent, zMin, xMax, yCurrent + yMax - 1, zMax); }
Example 16
Source File: ForgePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public FaweLocation getLocation() { World world = parent.world; BlockPos pos = parent.getPosition(); return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ()); }
Example 17
Source File: ChunkProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
private boolean isAir(ChunkPrimer chunkprimer, BlockPos pos) { if(pos.getX() < 0 || pos.getX() > 15 || pos.getZ() < 0 || pos.getZ() > 15 || pos.getY() < 0 || pos.getY() > 255) return false; return chunkprimer.getBlockState(pos.getX(), pos.getY(), pos.getZ()) == Blocks.AIR.getDefaultState(); }
Example 18
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public static BlockPos getReverseTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); boolean isRotated = true; int tmp = x; switch (rotation) { case CLOCKWISE_90: x = z; z = -tmp; break; case COUNTERCLOCKWISE_90: x = -z; z = tmp; break; case CLOCKWISE_180: x = -x; z = -z; break; default: isRotated = false; } 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: if (isRotated == false) { return pos; } } return new BlockPos(x, y, z); }
Example 19
Source File: Jesus.java From ForgeHax with MIT License | 4 votes |
private static boolean isAboveBlock(Entity entity, BlockPos pos) { return entity.posY >= pos.getY(); }
Example 20
Source File: FWItemBlock.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); }