Java Code Examples for net.minecraft.util.math.BlockPos#south()
The following examples show how to use
net.minecraft.util.math.BlockPos#south() .
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: EatBreadcrumbsGoal.java From the-hallow with MIT License | 6 votes |
private BlockPos tweakToProperPos(BlockPos pos, BlockView blockView) { if (blockView.getBlockState(pos).getBlock() == this.targetBlock) { return pos; } else { BlockPos[] blockPoss = new BlockPos[]{pos.down(), pos.west(), pos.east(), pos.north(), pos.south(), pos.down().down()}; BlockPos[] var4 = blockPoss; int var5 = blockPoss.length; for (int var6 = 0; var6 < var5; ++var6) { BlockPos blockPos2 = var4[var6]; if (blockView.getBlockState(blockPos2).getBlock() == this.targetBlock) { return blockPos2; } } return null; } }
Example 2
Source File: BasicSolarPanelBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public List<BlockPos> getOtherParts(BlockState state, BlockPos pos) { List<BlockPos> parts = new LinkedList<>(); BlockPos rod = pos.up(); BlockPos mid = rod.up(); BlockPos front = mid.north(); BlockPos back = mid.south(); BlockPos right = mid.east(); BlockPos left = mid.west(); BlockPos frontLeft = front.east(); BlockPos frontRight = front.west(); BlockPos backLeft = back.east(); BlockPos backRight = back.west(); parts.add(rod); parts.add(mid); parts.add(front); parts.add(back); parts.add(right); parts.add(left); parts.add(frontLeft); parts.add(frontRight); parts.add(backLeft); parts.add(backRight); return parts; }
Example 3
Source File: HolesModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private boolean isBlockValid(IBlockState blockState, BlockPos blockPos) { if (this.holes.contains(blockPos)) return false; if (blockState.getBlock() != Blocks.AIR) return false; if (Minecraft.getMinecraft().player.getDistanceSq(blockPos) < 1) return false; if (Minecraft.getMinecraft().world.getBlockState(blockPos.up()).getBlock() != Blocks.AIR) return false; if (Minecraft.getMinecraft().world.getBlockState(blockPos.up(2)).getBlock() != Blocks.AIR) // ensure the area is tall enough for the player return false; final BlockPos[] touchingBlocks = new BlockPos[]{ blockPos.north(), blockPos.south(), blockPos.east(), blockPos.west() }; int validHorizontalBlocks = 0; for (BlockPos touching : touchingBlocks) { final IBlockState touchingState = Minecraft.getMinecraft().world.getBlockState(touching); if ((touchingState.getBlock() != Blocks.AIR) && touchingState.isFullBlock()) { validHorizontalBlocks++; } } if (validHorizontalBlocks < 4) return false; return true; }
Example 4
Source File: BlockRice.java From TofuCraftReload with MIT License | 4 votes |
protected float getRiceGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (this.isWater(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 5
Source File: BlockPepperCrop.java From Sakura_mod with MIT License | 4 votes |
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 6
Source File: BlockVanillaCrop.java From Sakura_mod with MIT License | 4 votes |
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 7
Source File: BlockRiceCrop.java From Sakura_mod with MIT License | 4 votes |
protected float getRiceGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (this.isWater(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 8
Source File: BlockGrapeVine.java From Sakura_mod with MIT License | 4 votes |
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 9
Source File: BlockGrapeLeaves.java From Sakura_mod with MIT License | 4 votes |
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 10
Source File: BlockChestnut.java From Sakura_mod with MIT License | 4 votes |
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; BlockPos blockpos = pos.down(); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j)); if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)blockIn)) { f1 = 1.0F; if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) { f1 = 3.0F; } } if (i != 0 || j != 0) { f1 /= 4.0F; } f += f1; } } BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock(); boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock(); if (flag && flag1) { f /= 2.0F; } else { boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock(); if (flag2) { f /= 2.0F; } } return f; }
Example 11
Source File: NoCrystalModule.java From seppuku with GNU General Public License v3.0 | 4 votes |
@Listener public void onWalkingUpdate(EventUpdateWalkingPlayer event) { if (event.getStage() == EventStageable.EventStage.PRE) { final FreeCamModule freeCam = (FreeCamModule) Seppuku.INSTANCE.getModuleManager().find(FreeCamModule.class); if(freeCam != null && freeCam.isEnabled()) { return; } final Vec3d pos = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks()); final float playerSpeed = (float) MathUtil.getDistance(pos, mc.player.posX, mc.player.posY, mc.player.posZ); final BlockPos interpPos = new BlockPos(pos.x, pos.y, pos.z); final BlockPos north = interpPos.north(); final BlockPos south = interpPos.south(); final BlockPos east = interpPos.east(); final BlockPos west = interpPos.west(); final BlockPos northBelow = interpPos.north().down(); final BlockPos southBelow = interpPos.south().down(); final BlockPos eastBelow = interpPos.east().down(); final BlockPos westBelow = interpPos.west().down(); int lastSlot; final int slot = findStackHotbar(Blocks.OBSIDIAN); if (hasStack(Blocks.OBSIDIAN) || slot != -1) { if ((mc.player.onGround && playerSpeed <= 0.005f) && (this.sneak.getValue() || (!mc.gameSettings.keyBindSneak.isKeyDown()))) { lastSlot = mc.player.inventory.currentItem; mc.player.inventory.currentItem = slot; mc.playerController.updateController(); // Place supporting blocks if (valid(northBelow)) { place(northBelow, EnumFacing.SOUTH); } if (valid(southBelow)) { place(southBelow, EnumFacing.NORTH); } if (valid(eastBelow)) { place(eastBelow, EnumFacing.WEST); } if (valid(westBelow)) { place(westBelow, EnumFacing.EAST); } // Place protecting blocks if (valid(north)) { place(north, EnumFacing.SOUTH); } if (valid(south)) { place(south, EnumFacing.NORTH); } if (valid(east)) { place(east, EnumFacing.WEST); } if (valid(west)) { place(west, EnumFacing.EAST); } if (!slotEqualsBlock(lastSlot, Blocks.OBSIDIAN)) { mc.player.inventory.currentItem = lastSlot; } mc.playerController.updateController(); if (this.disable.getValue()) { this.toggle(); } } } } }
Example 12
Source File: TeleporterPaths.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { boolean flag = true; int playerX = MathHelper.floor(entityIn.posX); int playerZ = MathHelper.floor(entityIn.posZ); boolean shouldAddPortalPosition = true; boolean foundPortal = false; BlockPos object = new BlockPos(entityIn); long k = ChunkPos.asLong(playerX, playerZ); IslandMap islandMap = Core.getMapForWorld(worldServerInstance, entityIn.getPosition()); Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096)); //Check if we already have a portal position cached here if (this.destinationCoordinateCache.containsKey(k)) { Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.get(k); object = portalposition; portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); shouldAddPortalPosition = false; } else //If not then we do a simple search for the closest portal block { object = this.findPortal(new BlockPos(entityIn)); } //If we found a portal location then we need to move the player to it if (object != null) { if (shouldAddPortalPosition) { this.destinationCoordinateCache.put(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime())); //this.destinationCoordinateKeys.add(Long.valueOf(k)); } EnumFacing enumfacing = null; BlockPos pos = object; PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal); if(this.checkRoomForPlayer(pos.north())) pos = pos.north(); else if(this.checkRoomForPlayer(pos.south())) pos = pos.south(); else if(this.checkRoomForPlayer(pos.east())) pos = pos.east(); else if(this.checkRoomForPlayer(pos.west())) pos = pos.west(); entityIn.setLocationAndAngles(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, rotationYaw, entityIn.rotationPitch); return true; } else { return false; } }