net.minecraft.world.border.WorldBorder Java Examples
The following examples show how to use
net.minecraft.world.border.WorldBorder.
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: ShipTransformationManager.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
/** * Keeps the Ship in the world border */ private void forceShipIntoWorldBorder() { WorldBorder border = parent.world().getWorldBorder(); AxisAlignedBB shipBB = parent.getShipBoundingBox(); if (shipBB.maxX > border.maxX()) { parent.getWrapperEntity().posX += border.maxX() - shipBB.maxX; } if (shipBB.minX < border.minX()) { parent.getWrapperEntity().posX += border.minX() - shipBB.minX; } if (shipBB.maxZ > border.maxZ()) { parent.getWrapperEntity().posZ += border.maxZ() - shipBB.maxZ; } if (shipBB.minZ < border.minZ()) { parent.getWrapperEntity().posZ += border.minZ() - shipBB.minZ; } }
Example #2
Source File: ServerWorld_tickMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "tick", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/border/WorldBorder;tick()V" )) private void tickWorldBorder(WorldBorder worldBorder) { if (TickSpeed.process_entities) worldBorder.tick(); }
Example #3
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean arePositionsWithinWorld(World world, BlockPos pos1, BlockPos pos2) { if (pos1.getY() >= LayerRange.WORLD_VERTICAL_SIZE_MIN && pos1.getY() <= LayerRange.WORLD_VERTICAL_SIZE_MAX && pos2.getY() >= LayerRange.WORLD_VERTICAL_SIZE_MIN && pos2.getY() <= LayerRange.WORLD_VERTICAL_SIZE_MAX) { WorldBorder border = world.getWorldBorder(); return border.contains(pos1) && border.contains(pos2); } return false; }
Example #4
Source File: PositionUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns the given position scaled by the given scale factors, and clamped to within the world border * of the destination world, with the given margin to the border. */ public static Vec3d getScaledClampedPosition(Vec3d pos, @Nullable World world, double scaleX, double scaleY, double scaleZ, int margin) { // The world border in other dimensions than the Overworld gets always // reset to the default 60M blocks when the dimensions loads. // The client side WorldBorder is synced on world load, so the // border _appears_ to be where the Overworld border is, // but on the server side the border is actually at 60M blocks, // unless the border has been changed using the commands, // because the border change listener will then update the border // size from the Overworld border to the other dimensions (see WorldServerMulti), // however that change only persists as long as the dimension stays loaded. // So we are just getting the border size from the Overworld for now... world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0); int worldLimit = 30000000 - margin; // Note: getActualHeight() could be better (at least for the Nether), but it would return 128 for the End too... int worldHeight = world != null ? world.getHeight() : 256; double posX = MathHelper.clamp(pos.x * scaleX, -worldLimit, worldLimit); double posY = MathHelper.clamp(pos.y * scaleY, 0, worldHeight); double posZ = MathHelper.clamp(pos.z * scaleZ, -worldLimit, worldLimit); if (world != null) { WorldBorder border = world.getWorldBorder(); margin = Math.min(margin, (int)(border.getDiameter() / 2)); posX = MathHelper.clamp(pos.x * scaleX, border.minX() + margin, border.maxX() - margin); posZ = MathHelper.clamp(pos.z * scaleZ, border.minZ() + margin, border.maxZ() - margin); //System.out.printf("border size: %.2f posX: %.4f posY: %.4f posZ: %.4f\n", border.getDiameter(), posX, posY, posZ); //System.out.printf("border: %s (%s)\n", border.getClass().getName(), border); } return new Vec3d(posX, posY, posZ); }