use of net.minecraft.world.level.border.WorldBorder in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method setWorldBorder.
@Override
public void setWorldBorder(Player player, Location center, double size, double currSize, long time, int warningDistance, int warningTime) {
WorldBorder wb = new WorldBorder();
wb.world = ((CraftWorld) player.getWorld()).getHandle();
wb.setCenter(center.getX(), center.getZ());
wb.setWarningBlocks(warningDistance);
wb.setWarningTime(warningTime);
if (time > 0) {
wb.lerpSizeBetween(currSize, size, time);
} else {
wb.setSize(size);
}
send(player, new ClientboundInitializeBorderPacket(wb));
}
use of net.minecraft.world.level.border.WorldBorder in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method resetWorldBorder.
@Override
public void resetWorldBorder(Player player) {
WorldBorder wb = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder();
send(player, new ClientboundInitializeBorderPacket(wb));
}
use of net.minecraft.world.level.border.WorldBorder in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method setWorldBorder.
@Override
public void setWorldBorder(Player player, Location center, double size, double currSize, long time, int warningDistance, int warningTime) {
WorldBorder wb = new WorldBorder();
wb.world = ((CraftWorld) player.getWorld()).getHandle();
wb.setCenter(center.getX(), center.getZ());
wb.setWarningBlocks(warningDistance);
wb.setWarningTime(warningTime);
if (time > 0) {
wb.lerpSizeBetween(currSize, size, time);
} else {
wb.setSize(size);
}
send(player, new ClientboundInitializeBorderPacket(wb));
}
use of net.minecraft.world.level.border.WorldBorder in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method resetWorldBorder.
@Override
public void resetWorldBorder(Player player) {
WorldBorder wb = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder();
send(player, new ClientboundInitializeBorderPacket(wb));
}
use of net.minecraft.world.level.border.WorldBorder in project SpongeCommon by SpongePowered.
the class SpongeTeleportHelper method getBlockLocations.
private Stream<Vector3i> getBlockLocations(ServerLocation worldLocation, int height, int width) {
// We don't want to warp outside of the world border, so we want to check that we're within it.
final WorldBorder.Settings worldBorder = (WorldBorder.Settings) worldLocation.world().properties().worldBorder();
final double radius = worldBorder.getSize() / 2.0D;
int worldBorderMinX = GenericMath.floor(worldBorder.getCenterX() - radius);
int worldBorderMinZ = GenericMath.floor(worldBorder.getCenterZ() - radius);
int worldBorderMaxX = GenericMath.floor(worldBorder.getCenterX() + radius);
int worldBorderMaxZ = GenericMath.floor(worldBorder.getCenterZ() + radius);
// Get the World and get the maximum Y value.
int worldMaxY = worldLocation.world().max().y();
Vector3i vectorLocation = worldLocation.blockPosition();
// We use clamp to remain within the world confines, so we don't waste time checking blocks outside of the
// world border and the world height.
int minY = GenericMath.clamp(vectorLocation.y() - height, 0, worldMaxY);
int maxY = GenericMath.clamp(vectorLocation.y() + height, 0, worldMaxY);
int minX = GenericMath.clamp(vectorLocation.x() - width, worldBorderMinX, worldBorderMaxX);
int maxX = GenericMath.clamp(vectorLocation.x() + width, worldBorderMinX, worldBorderMaxX);
int minZ = GenericMath.clamp(vectorLocation.z() - width, worldBorderMinZ, worldBorderMaxZ);
int maxZ = GenericMath.clamp(vectorLocation.z() + width, worldBorderMinZ, worldBorderMaxZ);
// We now iterate over all possible x, y and z positions to get all possible vectors.
List<Vector3i> vectors = new ArrayList<>();
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
vectors.add(new Vector3i(x, y, z));
}
}
}
Comparator<Vector3i> c = Comparator.comparingInt(vectorLocation::distanceSquared);
// The compiler seems to need this to be a new line.
// We check to see what the y location is, preferring changes in Y over X and Z, and higher over lower locations.
c = c.thenComparing(x -> -Math.abs(vectorLocation.y() - x.y())).thenComparing(x -> -x.y());
// Sort them according to the distance to the provided worldLocation.
return vectors.stream().sorted(c);
}
Aggregations