diff --git a/patches/api/Add-getComputedBiome-API.patch b/patches/api/Add-getComputedBiome-API.patch index 430ae01a73..f7389965b5 100644 --- a/patches/api/Add-getComputedBiome-API.patch +++ b/patches/api/Add-getComputedBiome-API.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bu index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/RegionAccessor.java +++ b/src/main/java/org/bukkit/RegionAccessor.java -@@ -0,0 +0,0 @@ public interface RegionAccessor { +@@ -0,0 +0,0 @@ public interface RegionAccessor extends Keyed { // Paper * * @param location the location of the biome * @return Biome at the given location @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ @NotNull Biome getBiome(@NotNull Location location); -@@ -0,0 +0,0 @@ public interface RegionAccessor { +@@ -0,0 +0,0 @@ public interface RegionAccessor extends Keyed { // Paper * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @return Biome at the given coordinates diff --git a/patches/api/Add-moon-phase-API.patch b/patches/api/Add-moon-phase-API.patch index cd79cb3937..333c594e3c 100644 --- a/patches/api/Add-moon-phase-API.patch +++ b/patches/api/Add-moon-phase-API.patch @@ -46,20 +46,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return BY_DAY.get(day % 8L); + } +} -diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java +diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/World.java -+++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient - * @return The amount of Players in this world +--- a/src/main/java/org/bukkit/RegionAccessor.java ++++ b/src/main/java/org/bukkit/RegionAccessor.java +@@ -0,0 +0,0 @@ public interface RegionAccessor { */ - int getPlayerCount(); + @NotNull + public T spawn(@NotNull Location location, @NotNull Class clazz, boolean randomizeData, @Nullable Consumer function) throws IllegalArgumentException; + ++ // Paper start + /** + * @return the current moon phase at the current time in the world + */ + @NotNull + io.papermc.paper.world.MoonPhase getMoonPhase(); - // Paper end - - /** ++ // Paper end + } diff --git a/patches/api/Add-more-line-of-sight-methods.patch b/patches/api/Add-more-line-of-sight-methods.patch index e98811937d..70c1a71016 100644 --- a/patches/api/Add-more-line-of-sight-methods.patch +++ b/patches/api/Add-more-line-of-sight-methods.patch @@ -4,14 +4,14 @@ Date: Sat, 29 May 2021 14:33:18 -0500 Subject: [PATCH] Add more line of sight methods -diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java +diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/World.java -+++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient - */ +--- a/src/main/java/org/bukkit/RegionAccessor.java ++++ b/src/main/java/org/bukkit/RegionAccessor.java +@@ -0,0 +0,0 @@ public interface RegionAccessor extends Keyed { // Paper @NotNull - io.papermc.paper.world.MoonPhase getMoonPhase(); + @Override + NamespacedKey getKey(); + + /** + * Tell whether a line of sight exists between the given locations @@ -21,8 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + public boolean lineOfSightExists(@NotNull Location from, @NotNull Location to); // Paper end - - /** + } diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/patches/api/Add-methods-to-get-world-by-key.patch b/patches/api/Expand-world-key-API.patch similarity index 85% rename from patches/api/Add-methods-to-get-world-by-key.patch rename to patches/api/Expand-world-key-API.patch index 6efd82d614..81260cf123 100644 --- a/patches/api/Add-methods-to-get-world-by-key.patch +++ b/patches/api/Expand-world-key-API.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 6 Jan 2021 00:34:10 -0800 -Subject: [PATCH] Add methods to get world by key +Subject: [PATCH] Expand world key API diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java @@ -27,6 +27,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Create a new virtual {@link WorldBorder}. +diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/RegionAccessor.java ++++ b/src/main/java/org/bukkit/RegionAccessor.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * A RegionAccessor gives access to getting, modifying and spawning {@link Biome}, {@link BlockState} and {@link Entity}, + * as well as generating some basic structures. + */ +-public interface RegionAccessor { ++public interface RegionAccessor extends Keyed { // Paper + + /** + * Gets the {@link Biome} at the given {@link Location}. +@@ -0,0 +0,0 @@ public interface RegionAccessor { + */ + @NotNull + io.papermc.paper.world.MoonPhase getMoonPhase(); ++ ++ /** ++ * Get the world's key ++ * ++ * @return the world's key ++ */ ++ @NotNull ++ @Override ++ NamespacedKey getKey(); + // Paper end + } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java diff --git a/patches/server/Add-moon-phase-API.patch b/patches/server/Add-moon-phase-API.patch index eab12ecc82..611f035243 100644 --- a/patches/server/Add-moon-phase-API.patch +++ b/patches/server/Add-moon-phase-API.patch @@ -4,19 +4,19 @@ Date: Sun, 23 Aug 2020 16:32:11 +0200 Subject: [PATCH] Add moon phase API -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - public int getPlayerCount() { - return world.players().size(); +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +@@ -0,0 +0,0 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + + throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName()); } + ++ // Paper start + @Override + public io.papermc.paper.world.MoonPhase getMoonPhase() { -+ return io.papermc.paper.world.MoonPhase.getPhase(getFullTime() / 24000L); ++ return io.papermc.paper.world.MoonPhase.getPhase(this.getHandle().dayTime() / 24000L); + } - // Paper end - - private static final Random rand = new Random(); ++ // Paper end + } diff --git a/patches/server/Add-methods-to-get-world-by-key.patch b/patches/server/Expand-world-key-API.patch similarity index 80% rename from patches/server/Add-methods-to-get-world-by-key.patch rename to patches/server/Expand-world-key-API.patch index 85e91fcea1..ef55aa0252 100644 --- a/patches/server/Add-methods-to-get-world-by-key.patch +++ b/patches/server/Expand-world-key-API.patch @@ -1,9 +1,24 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 6 Jan 2021 00:34:04 -0800 -Subject: [PATCH] Add methods to get world by key +Subject: [PATCH] Expand world key API +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +@@ -0,0 +0,0 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + public io.papermc.paper.world.MoonPhase getMoonPhase() { + return io.papermc.paper.world.MoonPhase.getPhase(this.getHandle().dayTime() / 24000L); + } ++ ++ @Override ++ public org.bukkit.NamespacedKey getKey() { ++ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location()); ++ } + // Paper end + } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch b/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch index 84e39932dd..ca253b106b 100644 --- a/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch +++ b/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch @@ -35,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - return this.getHandle().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)).getType() == HitResult.Type.MISS; + public int getPlayerCount() { + return world.players().size(); } + + @Override diff --git a/patches/server/Line-Of-Sight-Changes.patch b/patches/server/Line-Of-Sight-Changes.patch index dd2ecd7cec..495c400470 100644 --- a/patches/server/Line-Of-Sight-Changes.patch +++ b/patches/server/Line-Of-Sight-Changes.patch @@ -18,29 +18,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - public io.papermc.paper.world.MoonPhase getMoonPhase() { - return io.papermc.paper.world.MoonPhase.getPhase(getFullTime() / 24000L); +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +@@ -0,0 +0,0 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + public org.bukkit.NamespacedKey getKey() { + return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location()); } + -+ @Override + public boolean lineOfSightExists(Location from, Location to) { -+ Validate.notNull(from, "from parameter in lineOfSightExists cannot be null"); -+ Validate.notNull(to, "to parameter in lineOfSightExists cannot be null"); ++ Preconditions.checkArgument(from != null, "from parameter in lineOfSightExists cannot be null"); ++ Preconditions.checkArgument(to != null, "to parameter in lineOfSightExists cannot be null"); + if (from.getWorld() != to.getWorld()) return false; -+ Vec3 vec3d = new Vec3(from.getX(), from.getY(), from.getZ()); -+ Vec3 vec3d1 = new Vec3(to.getX(), to.getY(), to.getZ()); ++ net.minecraft.world.phys.Vec3 vec3d = new net.minecraft.world.phys.Vec3(from.getX(), from.getY(), from.getZ()); ++ net.minecraft.world.phys.Vec3 vec3d1 = new net.minecraft.world.phys.Vec3(to.getX(), to.getY(), to.getZ()); + if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks + -+ return this.getHandle().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)).getType() == HitResult.Type.MISS; ++ return this.getHandle().clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, null)).getType() == net.minecraft.world.phys.HitResult.Type.MISS; + } // Paper end - - private static final Random rand = new Random(); + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java