From 3a0aff9ba97fedf85626d7e951235911c7d9c470 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 16 Jan 2024 19:27:39 +0100 Subject: [PATCH] [ci skip] Minor cleanup and patch merges --- ...sion-moving-velocity-to-VehicleBlock.patch | 49 --------- ...eCollisionEvent-move-HandlerList-up.patch} | 30 +++++- patches/api/Paper-Plugins.patch | 2 +- ...s-to-contain-the-source-jars-in-stac.patch | 2 +- patches/server/Add-EntityToggleSitEvent.patch | 4 +- ...predicate-for-blocks-when-raytracing.patch | 8 +- .../Do-not-run-raytrace-logic-for-AIR.patch | 22 ----- ...d-state-when-raytracing-skip-air-bl.patch} | 12 ++- patches/server/Fix-MC-158900.patch | 25 ----- .../server/Fix-a-bunch-of-vanilla-bugs.patch | 20 +++- ...-for-some-hot-BlockBehavior-and-Flui.patch | 5 +- .../Only-capture-actual-tree-growth.patch | 2 +- ...Prevent-Enderman-from-loading-chunks.patch | 30 ------ ...ent-Mob-AI-Rules-from-Loading-Chunks.patch | 40 -------- .../Prevent-compass-from-loading-chunks.patch | 19 ---- ...Prevent-rayTrace-from-loading-chunks.patch | 29 ------ ...interactions-from-causing-chunk-load.patch | 99 +++++++++++++++++++ ...-source-for-fireworks-from-dispenser.patch | 2 +- ...le-player-info-update-packet-on-join.patch | 2 +- 19 files changed, 166 insertions(+), 236 deletions(-) delete mode 100644 patches/api/Expose-pre-collision-moving-velocity-to-VehicleBlock.patch rename patches/api/{Move-VehicleCollisionEvent-HandlerList-up.patch => Extend-VehicleCollisionEvent-move-HandlerList-up.patch} (80%) delete mode 100644 patches/server/Do-not-run-raytrace-logic-for-AIR.patch rename patches/server/{Don-t-lookup-fluid-state-when-raytracing.patch => Don-t-lookup-fluid-state-when-raytracing-skip-air-bl.patch} (69%) delete mode 100644 patches/server/Fix-MC-158900.patch delete mode 100644 patches/server/Prevent-Enderman-from-loading-chunks.patch delete mode 100644 patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch delete mode 100644 patches/server/Prevent-compass-from-loading-chunks.patch delete mode 100644 patches/server/Prevent-rayTrace-from-loading-chunks.patch create mode 100644 patches/server/Prevent-various-interactions-from-causing-chunk-load.patch diff --git a/patches/api/Expose-pre-collision-moving-velocity-to-VehicleBlock.patch b/patches/api/Expose-pre-collision-moving-velocity-to-VehicleBlock.patch deleted file mode 100644 index 2caf50707d..0000000000 --- a/patches/api/Expose-pre-collision-moving-velocity-to-VehicleBlock.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: SoSeDiK -Date: Tue, 11 Oct 2022 23:30:32 +0300 -Subject: [PATCH] Expose pre-collision moving velocity to - VehicleBlockCollisionEvent - - -diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java -+++ b/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; - public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { - // private static final HandlerList handlers = new HandlerList(); // Paper - move HandlerList to VehicleCollisionEvent - private final Block block; -+ private final org.bukkit.util.Vector velocity; // Paper - -+ // Paper start - Add pre-collision velocity -+ @Deprecated - public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block) { -+ this(vehicle, block, vehicle.getVelocity()); -+ } -+ -+ public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block, @NotNull final org.bukkit.util.Vector velocity) { // Paper - Added velocity - super(vehicle); - this.block = block; -+ this.velocity = velocity; - } -+ // Paper end - - /** - * Gets the block the vehicle collided with -@@ -0,0 +0,0 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { - public Block getBlock() { - return block; - } -+ -+ // Paper start -+ /** -+ * Gets velocity at which the vehicle collided with the block -+ * -+ * @return pre-collision moving velocity -+ */ -+ @NotNull -+ public org.bukkit.util.Vector getVelocity() { -+ return velocity; -+ } -+ // Paper end - } diff --git a/patches/api/Move-VehicleCollisionEvent-HandlerList-up.patch b/patches/api/Extend-VehicleCollisionEvent-move-HandlerList-up.patch similarity index 80% rename from patches/api/Move-VehicleCollisionEvent-HandlerList-up.patch rename to patches/api/Extend-VehicleCollisionEvent-move-HandlerList-up.patch index af1b30cdd3..1f2a9f88d8 100644 --- a/patches/api/Move-VehicleCollisionEvent-HandlerList-up.patch +++ b/patches/api/Extend-VehicleCollisionEvent-move-HandlerList-up.patch @@ -1,8 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 13 Dec 2021 14:35:27 -0800 -Subject: [PATCH] Move VehicleCollisionEvent HandlerList up +Subject: [PATCH] Extend VehicleCollisionEvent, move HandlerList up +Co-authored-by: SoSeDiK diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -13,10 +14,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { - private static final HandlerList handlers = new HandlerList(); -+ // private static final HandlerList handlers = new HandlerList(); // Paper - move HandlerList to VehicleCollisionEvent private final Block block; ++ private final org.bukkit.util.Vector velocity; // Paper ++ // Paper start - Add pre-collision velocity ++ @Deprecated public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block) { ++ this(vehicle, block, vehicle.getVelocity()); ++ } ++ ++ public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block, @NotNull final org.bukkit.util.Vector velocity) { // Paper - Added velocity + super(vehicle); + this.block = block; ++ this.velocity = velocity; ++ } ++ ++ /** ++ * Gets velocity at which the vehicle collided with the block ++ * ++ * @return pre-collision moving velocity ++ */ ++ @NotNull ++ public org.bukkit.util.Vector getVelocity() { ++ return velocity; + } ++ // Paper end + + /** + * Gets the block the vehicle collided with @@ -0,0 +0,0 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { public Block getBlock() { return block; @@ -65,7 +90,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); -+ // private static final HandlerList handlers = new HandlerList(); // Paper - move HandlerList to VehicleCollisionEvent private final Entity entity; private boolean cancelled = false; private boolean cancelledPickup = false; diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index a29a69bb42..7c71b2b317 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -2124,7 +2124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - PluginClassLoader(@NotNull final JavaPluginLoader loader, @Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException { + @org.jetbrains.annotations.ApiStatus.Internal // Paper -+ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider ++ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper - use JarFile provided by SpigotPluginProvider super(new URL[] {file.toURI().toURL()}, parent); - Preconditions.checkArgument(loader != null, "Loader cannot be null"); + this.loader = null; // Paper - pass null into loader field diff --git a/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch index d5327035d0..10c65809ee 100644 --- a/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch +++ b/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm @org.jetbrains.annotations.ApiStatus.Internal // Paper - public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider + public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper - use JarFile provided by SpigotPluginProvider - super(new URL[] {file.toURI().toURL()}, parent); + super(file.getName(), new URL[] {file.toURI().toURL()}, parent); this.loader = null; // Paper - pass null into loader field diff --git a/patches/server/Add-EntityToggleSitEvent.patch b/patches/server/Add-EntityToggleSitEvent.patch index 768f21de6c..c1e5f6a28d 100644 --- a/patches/server/Add-EntityToggleSitEvent.patch +++ b/patches/server/Add-EntityToggleSitEvent.patch @@ -47,12 +47,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void setSitting(boolean sitting) { -+ // Paper start ++ // Paper start - Add EntityToggleSitEvent + this.setSitting(sitting, true); + } + public void setSitting(boolean sitting, boolean fireEvent) { + if (fireEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; -+ // Paper end - Add EntityToggleSitEvent ++ // Paper end - Add EntityToggleSitEvent this.setFlag(1, sitting); } diff --git a/patches/server/Add-predicate-for-blocks-when-raytracing.patch b/patches/server/Add-predicate-for-blocks-when-raytracing.patch index 6dd4a09fd4..ac190fc7ae 100644 --- a/patches/server/Add-predicate-for-blocks-when-raytracing.patch +++ b/patches/server/Add-predicate-for-blocks-when-raytracing.patch @@ -24,10 +24,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); } - // Paper end -- if (iblockdata.isAir()) return null; // Paper - optimise air cases -+ if (iblockdata.isAir() || (canCollide != null && this instanceof LevelAccessor levelAccessor && !canCollide.test(org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, blockposition)))) return null; // Paper - optimise air cases and check canCollide predicate - FluidState fluid = iblockdata.getFluidState(); // Paper - don't need to go to world state again + // Paper end - Prevent raytrace from loading chunks +- if (iblockdata.isAir()) return null; // Paper - Perf: optimise air cases ++ if (iblockdata.isAir() || (canCollide != null && this instanceof LevelAccessor levelAccessor && !canCollide.test(org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, blockposition)))) return null; // Paper - Perf: optimise air cases &g check canCollide predicate + FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: don't need to go to world state again Vec3 vec3d = raytrace1.getFrom(); Vec3 vec3d1 = raytrace1.getTo(); @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { diff --git a/patches/server/Do-not-run-raytrace-logic-for-AIR.patch b/patches/server/Do-not-run-raytrace-logic-for-AIR.patch deleted file mode 100644 index 36060b34da..0000000000 --- a/patches/server/Do-not-run-raytrace-logic-for-AIR.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Sun, 7 Mar 2021 13:15:04 -0800 -Subject: [PATCH] Do not run raytrace logic for AIR - -Saves approx. 5% for the raytrace call, as most (expensive) -raytracing tends to go through air and returning early is an -easy win. The remaining problems with this function -are mostly with the block getting itself. - -diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/BlockGetter.java -+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java -@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { - return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); - } - // Paper end -+ if (iblockdata.isAir()) return null; // Paper - optimise air cases - FluidState fluid = iblockdata.getFluidState(); // Paper - don't need to go to world state again - Vec3 vec3d = raytrace1.getFrom(); - Vec3 vec3d1 = raytrace1.getTo(); diff --git a/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch b/patches/server/Don-t-lookup-fluid-state-when-raytracing-skip-air-bl.patch similarity index 69% rename from patches/server/Don-t-lookup-fluid-state-when-raytracing.patch rename to patches/server/Don-t-lookup-fluid-state-when-raytracing-skip-air-bl.patch index f303ee61a8..8f0158784e 100644 --- a/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch +++ b/patches/server/Don-t-lookup-fluid-state-when-raytracing-skip-air-bl.patch @@ -1,10 +1,15 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 28 Aug 2020 12:33:47 -0700 -Subject: [PATCH] Don't lookup fluid state when raytracing +Subject: [PATCH] Don't lookup fluid state when raytracing, skip air blocks Just use the iblockdata already retrieved, removes a getType call. +Also save approx. 5% for the raytrace call, as most (expensive) +raytracing tends to go through air and returning early is an +easy win. The remaining problems with this function +are mostly with the block getting itself. + diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/BlockGetter.java @@ -12,9 +17,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); } - // Paper end + // Paper end - Prevent raytrace from loading chunks - FluidState fluid = this.getFluidState(blockposition); -+ FluidState fluid = iblockdata.getFluidState(); // Paper - don't need to go to world state again ++ if (iblockdata.isAir()) return null; // Paper - Perf: optimise air cases ++ FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: don't need to go to world state again Vec3 vec3d = raytrace1.getFrom(); Vec3 vec3d1 = raytrace1.getTo(); VoxelShape voxelshape = raytrace1.getBlockShape(iblockdata, this, blockposition); diff --git a/patches/server/Fix-MC-158900.patch b/patches/server/Fix-MC-158900.patch deleted file mode 100644 index d4893ae672..0000000000 --- a/patches/server/Fix-MC-158900.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Tue, 13 Aug 2019 06:35:17 -0700 -Subject: [PATCH] Fix MC-158900 - -The problem was we were checking isExpired() on the entry, but if it -was expired at that point, then it would be null. - -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -0,0 +0,0 @@ public abstract class PlayerList { - Player player = entity.getBukkitEntity(); - PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.channel.remoteAddress()).getAddress()); - -- if (this.getBans().isBanned(gameprofile) && !this.getBans().get(gameprofile).hasExpired()) { -- UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile); -+ // Paper start - Fix MC-158900 -+ UserBanListEntry gameprofilebanentry; -+ if (getBans().isBanned(gameprofile) && (gameprofilebanentry = getBans().get(gameprofile)) != null) { -+ // Paper end - - ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); - if (gameprofilebanentry.getExpires() != null) { diff --git a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch index 06fa5ca9f9..1a364d471f 100644 --- a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch @@ -41,11 +41,9 @@ https://bugs.mojang.com/browse/MC-263999 Fix mobs breaking doors not spawning block break particles https://bugs.mojang.com/browse/MC-210802 - by: BillyGalbreath Fixes sheep eating blocks outside of ticking range https://bugs.mojang.com/browse/MC-123848 - by: BillyGalbreath Fixes item frames dropping items above when pointing down https://bugs.mojang.com/browse/MC-84789 @@ -70,6 +68,7 @@ https://bugs.mojang.com/browse/MC-200092 public net/minecraft/world/entity/Mob leashInfoTag Co-authored-by: William Blake Galbreath +Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -170,6 +169,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.player.onUpdateAbilities(); this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit this.level.updateSleepingPlayerList(); +diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/players/PlayerList.java ++++ b/src/main/java/net/minecraft/server/players/PlayerList.java +@@ -0,0 +0,0 @@ public abstract class PlayerList { + Player player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.channel.remoteAddress()).getAddress()); + +- if (this.getBans().isBanned(gameprofile) && !this.getBans().get(gameprofile).hasExpired()) { +- UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile); ++ // Paper start - Fix MC-158900 ++ UserBanListEntry gameprofilebanentry; ++ if (getBans().isBanned(gameprofile) && (gameprofilebanentry = getBans().get(gameprofile)) != null) { ++ // Paper end - Fix MC-158900 + + ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); + if (gameprofilebanentry.getExpires() != null) { diff --git a/src/main/java/net/minecraft/world/entity/Saddleable.java b/src/main/java/net/minecraft/world/entity/Saddleable.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Saddleable.java diff --git a/patches/server/Improve-inlining-for-some-hot-BlockBehavior-and-Flui.patch b/patches/server/Improve-inlining-for-some-hot-BlockBehavior-and-Flui.patch index 80737fe71d..1a3e8aff67 100644 --- a/patches/server/Improve-inlining-for-some-hot-BlockBehavior-and-Flui.patch +++ b/patches/server/Improve-inlining-for-some-hot-BlockBehavior-and-Flui.patch @@ -56,12 +56,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/material/FluidState.java +++ b/src/main/java/net/minecraft/world/level/material/FluidState.java @@ -0,0 +0,0 @@ public final class FluidState extends StateHolder { + public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; ++ protected final boolean isEmpty; // Paper - Perf: moved from isEmpty() -+ // Paper start - Perf: moved from isEmpty() -+ protected final boolean isEmpty; -+ // Paper end - Perf: moved from isEmpty() public FluidState(Fluid fluid, ImmutableMap, Comparable> propertiesMap, MapCodec codec) { super(fluid, propertiesMap, codec); + this.isEmpty = fluid.isEmpty(); // Paper - Perf: moved from isEmpty() diff --git a/patches/server/Only-capture-actual-tree-growth.patch b/patches/server/Only-capture-actual-tree-growth.patch index dcc13f51b8..2948f2da99 100644 --- a/patches/server/Only-capture-actual-tree-growth.patch +++ b/patches/server/Only-capture-actual-tree-growth.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) + // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the + // tree grew or not -+ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // Paper - Fix silent equipment change ++ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); + } + } diff --git a/patches/server/Prevent-Enderman-from-loading-chunks.patch b/patches/server/Prevent-Enderman-from-loading-chunks.patch deleted file mode 100644 index 4574060fea..0000000000 --- a/patches/server/Prevent-Enderman-from-loading-chunks.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shane Freeder -Date: Tue, 18 Dec 2018 02:15:08 +0000 -Subject: [PATCH] Prevent Enderman from loading chunks - - -diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob { - int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D); - int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D); - BlockPos blockposition = new BlockPos(i, j, k); -- BlockState iblockdata = world.getBlockState(blockposition); -+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper -+ if (iblockdata == null) return; // Paper - BlockPos blockposition1 = blockposition.below(); - BlockState iblockdata1 = world.getBlockState(blockposition1); - BlockState iblockdata2 = this.enderman.getCarriedBlock(); -@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob { - int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D); - int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D); - BlockPos blockposition = new BlockPos(i, j, k); -- BlockState iblockdata = world.getBlockState(blockposition); -+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper -+ if (iblockdata == null) return; // Paper - Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D); - Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D); - BlockHitResult movingobjectpositionblock = world.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman)); diff --git a/patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch b/patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch deleted file mode 100644 index c2f17fad31..0000000000 --- a/patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Mon, 10 Sep 2018 23:56:36 -0400 -Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks - - -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { - - @Nullable - private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) { -- if (world.getBlockState(pos).is(this.blockToRemove)) { -+ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper -+ if (block == null) return null; // Paper -+ if (block.is(this.blockToRemove)) { // Paper - return pos; - } else { - BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; -@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { - for (int j = 0; j < i; ++j) { - BlockPos blockposition1 = ablockposition1[j]; - -- if (world.getBlockState(blockposition1).is(this.blockToRemove)) { -+ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper -+ if (block2 != null && block2.is(this.blockToRemove)) { // Paper - return blockposition1; - } - } -@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { - - @Override - protected boolean isValidTarget(LevelReader world, BlockPos pos) { -- ChunkAccess ichunkaccess = world.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false); -+ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper - - return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir(); - } diff --git a/patches/server/Prevent-compass-from-loading-chunks.patch b/patches/server/Prevent-compass-from-loading-chunks.patch deleted file mode 100644 index 2be1910754..0000000000 --- a/patches/server/Prevent-compass-from-loading-chunks.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shane Freeder -Date: Sun, 6 Nov 2022 22:35:51 +0000 -Subject: [PATCH] Prevent compass from loading chunks - - -diff --git a/src/main/java/net/minecraft/world/item/CompassItem.java b/src/main/java/net/minecraft/world/item/CompassItem.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/CompassItem.java -+++ b/src/main/java/net/minecraft/world/item/CompassItem.java -@@ -0,0 +0,0 @@ public class CompassItem extends Item implements Vanishable { - Optional> optional = getLodestoneDimension(compoundTag); - if (optional.isPresent() && optional.get() == world.dimension() && compoundTag.contains("LodestonePos")) { - BlockPos blockPos = NbtUtils.readBlockPos(compoundTag.getCompound("LodestonePos")); -- if (!world.isInWorldBounds(blockPos) || !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) { -+ if (!world.isInWorldBounds(blockPos) || (world.hasChunkAt(blockPos) && !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos))) { // Paper - Prevent compass from loading chunks - compoundTag.remove("LodestonePos"); - } - } diff --git a/patches/server/Prevent-rayTrace-from-loading-chunks.patch b/patches/server/Prevent-rayTrace-from-loading-chunks.patch deleted file mode 100644 index dc072eaeaa..0000000000 --- a/patches/server/Prevent-rayTrace-from-loading-chunks.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Mon, 26 Nov 2018 19:21:58 -0500 -Subject: [PATCH] Prevent rayTrace from loading chunks - -ray tracing into an unloaded chunk should be treated as a miss -this saves a ton of lag for when AI tries to raytrace near unloaded chunks. - -diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/BlockGetter.java -+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java -@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { - - // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace - default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { -- BlockState iblockdata = this.getBlockState(blockposition); -+ // Paper start - Prevent raytrace from loading chunks -+ BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); -+ if (iblockdata == null) { -+ // copied the last function parameter (listed below) -+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); -+ -+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); -+ } -+ // Paper end - FluidState fluid = this.getFluidState(blockposition); - Vec3 vec3d = raytrace1.getFrom(); - Vec3 vec3d1 = raytrace1.getTo(); diff --git a/patches/server/Prevent-various-interactions-from-causing-chunk-load.patch b/patches/server/Prevent-various-interactions-from-causing-chunk-load.patch new file mode 100644 index 0000000000..ab00c967ff --- /dev/null +++ b/patches/server/Prevent-various-interactions-from-causing-chunk-load.patch @@ -0,0 +1,99 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 10 Sep 2018 23:56:36 -0400 +Subject: [PATCH] Prevent various interactions from causing chunk loads + +Co-authored-by: Shane Freeder + +diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java ++++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { + + @Nullable + private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) { +- if (world.getBlockState(pos).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks ++ if (block == null) return null; // Paper - Prevent AI rules from loading chunks ++ if (block.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return pos; + } else { + BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; +@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { + for (int j = 0; j < i; ++j) { + BlockPos blockposition1 = ablockposition1[j]; + +- if (world.getBlockState(blockposition1).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent AI rules from loading chunks ++ if (block2 != null && block2.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return blockposition1; + } + } +@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal { + + @Override + protected boolean isValidTarget(LevelReader world, BlockPos pos) { +- ChunkAccess ichunkaccess = world.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false); ++ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper - Prevent AI rules from loading chunks + + return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir(); + } +diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java ++++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob { + int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D); + int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D); + BlockPos blockposition = new BlockPos(i, j, k); +- BlockState iblockdata = world.getBlockState(blockposition); ++ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks ++ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks + BlockPos blockposition1 = blockposition.below(); + BlockState iblockdata1 = world.getBlockState(blockposition1); + BlockState iblockdata2 = this.enderman.getCarriedBlock(); +@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob { + int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D); + int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D); + BlockPos blockposition = new BlockPos(i, j, k); +- BlockState iblockdata = world.getBlockState(blockposition); ++ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks ++ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks + Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D); + Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D); + BlockHitResult movingobjectpositionblock = world.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman)); +diff --git a/src/main/java/net/minecraft/world/item/CompassItem.java b/src/main/java/net/minecraft/world/item/CompassItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/CompassItem.java ++++ b/src/main/java/net/minecraft/world/item/CompassItem.java +@@ -0,0 +0,0 @@ public class CompassItem extends Item implements Vanishable { + Optional> optional = getLodestoneDimension(compoundTag); + if (optional.isPresent() && optional.get() == world.dimension() && compoundTag.contains("LodestonePos")) { + BlockPos blockPos = NbtUtils.readBlockPos(compoundTag.getCompound("LodestonePos")); +- if (!world.isInWorldBounds(blockPos) || !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) { ++ if (!world.isInWorldBounds(blockPos) || (world.hasChunkAt(blockPos) && !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos))) { // Paper - Prevent compass from loading chunks + compoundTag.remove("LodestonePos"); + } + } +diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/BlockGetter.java ++++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { + + // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace + default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { +- BlockState iblockdata = this.getBlockState(blockposition); ++ // Paper start - Prevent raytrace from loading chunks ++ BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); ++ if (iblockdata == null) { ++ // copied the last function parameter (listed below) ++ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); ++ ++ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); ++ } ++ // Paper end - Prevent raytrace from loading chunks + FluidState fluid = this.getFluidState(blockposition); + Vec3 vec3d = raytrace1.getFrom(); + Vec3 vec3d1 = raytrace1.getTo(); diff --git a/patches/server/Track-projectile-source-for-fireworks-from-dispenser.patch b/patches/server/Track-projectile-source-for-fireworks-from-dispenser.patch index c6c3f1f1d6..8720878d21 100644 --- a/patches/server/Track-projectile-source-for-fireworks-from-dispenser.patch +++ b/patches/server/Track-projectile-source-for-fireworks-from-dispenser.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); Vec3 vec3d = DispenseItemBehavior.getEntityPokingOutOfBlockPos(pointer, EntityType.FIREWORK_ROCKET, enumdirection); FireworkRocketEntity entityfireworks = new FireworkRocketEntity(pointer.level(), itemstack1, vec3d.x(), vec3d.y(), vec3d.z(), true); // Paper - GH-2871 - fix last firework in stack having no effects when dispensed -+ entityfireworks.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); // PaperTrack projectile source for fireworks from dispensers ++ entityfireworks.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); // Paper - Track projectile source for fireworks from dispensers entityfireworks.shoot((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), 0.5F, 1.0F); pointer.level().addFreshEntity(entityfireworks); diff --git a/patches/server/Use-single-player-info-update-packet-on-join.patch b/patches/server/Use-single-player-info-update-packet-on-join.patch index 5e4668f2a7..d1e1688957 100644 --- a/patches/server/Use-single-player-info-update-packet-on-join.patch +++ b/patches/server/Use-single-player-info-update-packet-on-join.patch @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1))); -+ onlinePlayers.add(entityplayer1); // Pape - Use single player info update packet on join ++ onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join } + // Paper start - Use single player info update packet on join + if (!onlinePlayers.isEmpty()) {