Java Code Examples for net.minecraft.util.math.AxisAlignedBB#union()
The following examples show how to use
net.minecraft.util.math.AxisAlignedBB#union() .
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: GlideHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onUpdate(WUpdateEvent event) { EntityPlayerSP player = event.getPlayer(); World world = WPlayer.getWorld(player); if(!player.isAirBorne || player.isInWater() || player.isInLava() || player.isOnLadder() || player.motionY >= 0) return; if(minHeight.getValue() > 0) { AxisAlignedBB box = player.getEntityBoundingBox(); box = box.union(box.offset(0, -minHeight.getValue(), 0)); // Using expand() with negative values doesn't work in 1.10.2. if(world.collidesWithAnyBlock(box)) return; BlockPos min = new BlockPos(new Vec3d(box.minX, box.minY, box.minZ)); BlockPos max = new BlockPos(new Vec3d(box.maxX, box.maxY, box.maxZ)); Stream<BlockPos> stream = StreamSupport .stream(BlockPos.getAllInBox(min, max).spliterator(), true); // manual collision check, since liquids don't have bounding boxes if(stream.map(BlockUtils::getBlock) .anyMatch(b -> b instanceof BlockLiquid)) return; } player.motionY = Math.max(player.motionY, -fallSpeed.getValue()); player.jumpMovementFactor *= moveSpeed.getValueF(); }
Example 2
Source File: JesusHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
private boolean isStandingOnLiquid(EntityPlayer player) { if(!isLiquidCollisionEnabled(player)) return false; World world = WPlayer.getWorld(player); boolean foundLiquid = false; boolean foundSolid = false; // check collision boxes below player AxisAlignedBB playerBox = player.getEntityBoundingBox(); playerBox = playerBox.union(playerBox.offset(0, -0.5, 0)); // Using expand() with negative values doesn't work in 1.10.2. for(AxisAlignedBB box : world.getCollisionBoxes(player, playerBox)) { BlockPos pos = new BlockPos(box.getCenter()); Material material = BlockUtils.getMaterial(pos); if(material == Material.WATER || material == Material.LAVA) foundLiquid = true; else if(material != Material.AIR) foundSolid = true; } return foundLiquid && !foundSolid; }
Example 3
Source File: BlockWaterChannelValve.java From AgriCraft with MIT License | 5 votes |
@Override @SuppressWarnings("deprecation") public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { // Fetch Tile Entity final TileEntityChannelValve tile = WorldHelper.getTile(world, pos, TileEntityChannelValve.class).orElse(null); // Define Core Bounding Box AxisAlignedBB selection = CENTER_BOX; // Expand Bounding Box if (tile != null) { if (tile.getConnections().get(EnumFacing.NORTH) > 0) { selection = selection.union(NORTH_BOX); } if (tile.getConnections().get(EnumFacing.EAST) > 0) { selection = selection.union(EAST_BOX); } if (tile.getConnections().get(EnumFacing.SOUTH) > 0) { selection = selection.union(SOUTH_BOX); } if (tile.getConnections().get(EnumFacing.WEST) > 0) { selection = selection.union(WEST_BOX); } } return selection; }
Example 4
Source File: BlockWaterChannel.java From AgriCraft with MIT License | 5 votes |
@Override @SuppressWarnings("deprecation") public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { // Fetch Tile Entity final TileEntityChannel tile = WorldHelper.getTile(world, pos, TileEntityChannel.class).orElse(null); // Define Core Bounding Box AxisAlignedBB selection = CENTER_BOX; // Expand Bounding Box if (tile != null) { if (tile.getConnections().get(EnumFacing.NORTH) > 0) { selection = selection.union(NORTH_BOX); } if (tile.getConnections().get(EnumFacing.EAST) > 0) { selection = selection.union(EAST_BOX); } if (tile.getConnections().get(EnumFacing.SOUTH) > 0) { selection = selection.union(SOUTH_BOX); } if (tile.getConnections().get(EnumFacing.WEST) > 0) { selection = selection.union(WEST_BOX); } } return selection; }