From 0ec8b900ba88fa2236114c34a3f9cf520d1c2071 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sat, 12 Jun 2021 12:26:21 +0200 Subject: [PATCH] More work --- ...pstream-javadoc-warnings-and-errors.patch} | 2 +- .../0053-Item-canEntityPickup.patch} | 0 ...layerPickupItemEvent-setFlyAtPlayer.patch} | 6 +- ...leAppender-for-console-improvements.patch} | 144 ++++++++---------- ...rable-option-to-disable-creeper-lin.patch} | 4 +- .../0139-Item-canEntityPickup.patch} | 18 ++- ...layerPickupItemEvent-setFlyAtPlayer.patch} | 16 +- 7 files changed, 84 insertions(+), 106 deletions(-) rename patches/{api-unmapped/0051-Fix-upstream-javadoc-warnings-and-errors.patch => api/0052-Fix-upstream-javadoc-warnings-and-errors.patch} (95%) rename patches/{api-unmapped/0052-Item-canEntityPickup.patch => api/0053-Item-canEntityPickup.patch} (100%) rename patches/{api-unmapped/0053-PlayerPickupItemEvent-setFlyAtPlayer.patch => api/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch} (99%) rename patches/{server-remapped/0148-Use-TerminalConsoleAppender-for-console-improvements.patch => server/0137-Use-TerminalConsoleAppender-for-console-improvements.patch} (83%) rename patches/{server-remapped/0149-provide-a-configurable-option-to-disable-creeper-lin.patch => server/0138-provide-a-configurable-option-to-disable-creeper-lin.patch} (91%) rename patches/{server-remapped/0150-Item-canEntityPickup.patch => server/0139-Item-canEntityPickup.patch} (73%) rename patches/{server-remapped/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch => server/0140-PlayerPickupItemEvent-setFlyAtPlayer.patch} (76%) diff --git a/patches/api-unmapped/0051-Fix-upstream-javadoc-warnings-and-errors.patch b/patches/api/0052-Fix-upstream-javadoc-warnings-and-errors.patch similarity index 95% rename from patches/api-unmapped/0051-Fix-upstream-javadoc-warnings-and-errors.patch rename to patches/api/0052-Fix-upstream-javadoc-warnings-and-errors.patch index 083596bdd2..ad9ec8b241 100644 --- a/patches/api-unmapped/0051-Fix-upstream-javadoc-warnings-and-errors.patch +++ b/patches/api/0052-Fix-upstream-javadoc-warnings-and-errors.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fix upstream javadoc warnings and errors Upstream still refuses to use Java 8 with the API so they are likely unaware these are even issues. diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 3f68baef538098d9ce66b91195b6fa17f26f0d78..e71b048e53ee2db4e768eea2ddf19b00a14d2484 100644 +index 6bb0bb8052c12c5a215abf4bd9602fbefc769523..22cfa703e4f543c26151b33fe9ee1ab445d1c4fe 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -634,7 +634,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM diff --git a/patches/api-unmapped/0052-Item-canEntityPickup.patch b/patches/api/0053-Item-canEntityPickup.patch similarity index 100% rename from patches/api-unmapped/0052-Item-canEntityPickup.patch rename to patches/api/0053-Item-canEntityPickup.patch diff --git a/patches/api-unmapped/0053-PlayerPickupItemEvent-setFlyAtPlayer.patch b/patches/api/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch similarity index 99% rename from patches/api-unmapped/0053-PlayerPickupItemEvent-setFlyAtPlayer.patch rename to patches/api/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch index 353d395911..fbc15c2f8c 100644 --- a/patches/api-unmapped/0053-PlayerPickupItemEvent-setFlyAtPlayer.patch +++ b/patches/api/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch @@ -15,11 +15,11 @@ index 951ea2cc763973655beedcba3c75332d3f297313..18d82c111f30e0279c10a174a51bac01 + private boolean flyAtPlayer = true; // Paper private boolean cancel = false; private final int remaining; - + @@ -45,6 +46,27 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { return remaining; } - + + // Paper Start + /** + * Set if the item will fly at the player @@ -50,5 +50,5 @@ index 951ea2cc763973655beedcba3c75332d3f297313..18d82c111f30e0279c10a174a51bac01 this.cancel = cancel; + this.flyAtPlayer = !cancel; // Paper } - + @NotNull diff --git a/patches/server-remapped/0148-Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/0137-Use-TerminalConsoleAppender-for-console-improvements.patch similarity index 83% rename from patches/server-remapped/0148-Use-TerminalConsoleAppender-for-console-improvements.patch rename to patches/server/0137-Use-TerminalConsoleAppender-for-console-improvements.patch index d43b61bcff..8ae1556c29 100644 --- a/patches/server-remapped/0148-Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/0137-Use-TerminalConsoleAppender-for-console-improvements.patch @@ -18,60 +18,29 @@ Other changes: - Server starts 1-2 seconds faster thanks to optimizations in Log4j configuration -diff --git a/pom.xml b/pom.xml -index a5d87d22cb1588d15e08da3b37e51c5e261c7799..3841fe3630c090f8a468333d43caeb2b5841329d 100644 ---- a/pom.xml -+++ b/pom.xml -@@ -57,10 +57,26 @@ - compile - - -- jline -- jline -- 2.12.1 -- compile -+ net.minecrell -+ terminalconsoleappender -+ 1.2.0 -+ -+ -+ org.jline -+ jline-terminal-jansi -+ 3.12.1 -+ runtime -+ -+ -+ -+ org.apache.logging.log4j -+ log4j-core -+ runtime - - - org.apache.logging.log4j -@@ -334,10 +350,18 @@ - - META-INF/services/java.sql.Driver - -+ - - - - -+ -+ -+ com.github.edwgiz -+ maven-shade-plugin.log4j2-cachefile-transformer -+ 2.13.1 -+ -+ - - - org.apache.maven.plugins ++ */ ++ runtimeOnly("org.apache.logging.log4j:log4j-core:2.14.1") ++ // Paper end + implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper + implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper + implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.14.1") // Paper diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java new file mode 100644 index 0000000000000000000000000000000000000000..a4070b59e261f0f1ac4beec47b11492f4724bf27 @@ -143,7 +112,7 @@ index 0000000000000000000000000000000000000000..685deaa0e5d1ddc13e3a7c0471b1cfcf + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f41d79c6630fd8daae28476ffc854f7e65d841e6..4b3341877629c7065496fb0f0b4d509f5a48db6d 100644 +index 1617c59bf689e5f67c2af5c3a22ce5791d47b408..fb4385333ef8dd4fa22275753606df3020000539 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -12,6 +12,7 @@ import com.mojang.datafixers.DataFixer; @@ -152,9 +121,9 @@ index f41d79c6630fd8daae28476ffc854f7e65d841e6..4b3341877629c7065496fb0f0b4d509f import io.netty.buffer.Unpooled; +import io.papermc.paper.adventure.PaperAdventure; // Paper import it.unimi.dsi.fastutil.longs.LongIterator; + import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; - import java.io.BufferedWriter; -@@ -161,7 +162,7 @@ import org.apache.logging.log4j.Logger; +@@ -172,7 +173,7 @@ import org.apache.logging.log4j.Logger; import com.mojang.serialization.DynamicOps; import com.mojang.serialization.Lifecycle; import com.google.common.collect.ImmutableSet; @@ -163,7 +132,7 @@ index f41d79c6630fd8daae28476ffc854f7e65d841e6..4b3341877629c7065496fb0f0b4d509f import joptsimple.OptionSet; import net.minecraft.resources.RegistryReadOps; import net.minecraft.server.bossevents.CustomBossEvents; -@@ -253,7 +254,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; -@@ -322,7 +323,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { // Trim to filter lines which are just spaces @@ -232,7 +201,7 @@ index 77616b5dd3d79221d3460b1db4d90ad37c0f85aa..883e05ba87c3bdec9a0d4bbd035b90c7 } // CraftBukkit end } -@@ -138,6 +141,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -147,6 +150,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.error("Exception handling console input", ioexception); } @@ -241,7 +210,7 @@ index 77616b5dd3d79221d3460b1db4d90ad37c0f85aa..883e05ba87c3bdec9a0d4bbd035b90c7 } }; -@@ -149,6 +154,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -158,6 +163,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler()); @@ -251,7 +220,7 @@ index 77616b5dd3d79221d3460b1db4d90ad37c0f85aa..883e05ba87c3bdec9a0d4bbd035b90c7 final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) { if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) { -@@ -157,6 +165,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -166,6 +174,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start(); @@ -261,10 +230,10 @@ index 77616b5dd3d79221d3460b1db4d90ad37c0f85aa..883e05ba87c3bdec9a0d4bbd035b90c7 System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream()); System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream()); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index d750bef20312cc97e3446bbb2d2dc03f90d47f1c..7d6256f65d369fcbcfe1fffe7ac264788a38540b 100644 +index 79ebb15bed6eec80c12c1020b2b6b07c758332aa..bf6c3ac7ae37067f345568fb6656cf6b4d864be2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -146,8 +146,7 @@ public abstract class PlayerList { +@@ -151,8 +151,7 @@ public abstract class PlayerList { public PlayerList(MinecraftServer server, RegistryAccess.RegistryHolder registryManager, PlayerDataStorage saveHandler, int maxPlayers) { this.cserver = server.server = new CraftServer((DedicatedServer) server, this); @@ -275,7 +244,7 @@ index d750bef20312cc97e3446bbb2d2dc03f90d47f1c..7d6256f65d369fcbcfe1fffe7ac26478 this.bans = new UserBanList(PlayerList.USERBANLIST_FILE); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index d198dad80e0fb41a5bde66944d0e41509a9c1c43..7b2ece40c09ba336a0c2a84321401619801c64c8 100644 +index 654ad4a6a92b11fbed84b091ca4b6e99131b4a20..dcc1a3856560ab0eb4de45a358e189134adeac17 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -46,7 +46,6 @@ import java.util.function.Consumer; @@ -295,7 +264,7 @@ index d198dad80e0fb41a5bde66944d0e41509a9c1c43..7b2ece40c09ba336a0c2a84321401619 import net.minecraft.server.bossevents.CustomBossEvent; import net.minecraft.server.commands.ReloadCommand; @@ -1204,9 +1204,13 @@ public final class CraftServer implements Server { - return logger; + return this.logger; } + // Paper start - JLine update @@ -309,7 +278,7 @@ index d198dad80e0fb41a5bde66944d0e41509a9c1c43..7b2ece40c09ba336a0c2a84321401619 @Override public PluginCommand getPluginCommand(String name) { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index b849b2afd009da433fe6cea5837b3ee9bb5c52b4..60d9980ccca6f1ac55b70f7684b917ddceac380a 100644 +index 6985e8dc3d520eb65ae7d885138be81836452c01..b4bcd34123968b3930bb330f7c2abd9b5518fa31 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -12,7 +12,7 @@ import java.util.logging.Level; @@ -321,7 +290,7 @@ index b849b2afd009da433fe6cea5837b3ee9bb5c52b4..60d9980ccca6f1ac55b70f7684b917dd public class Main { public static boolean useJline = true; -@@ -185,6 +185,8 @@ public class Main { +@@ -189,6 +189,8 @@ public class Main { } try { @@ -330,7 +299,7 @@ index b849b2afd009da433fe6cea5837b3ee9bb5c52b4..60d9980ccca6f1ac55b70f7684b917dd // This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals String jline_UnsupportedTerminal = new String(new char[]{'j', 'l', 'i', 'n', 'e', '.', 'U', 'n', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', 'T', 'e', 'r', 'm', 'i', 'n', 'a', 'l'}); String jline_terminal = new String(new char[]{'j', 'l', 'i', 'n', 'e', '.', 't', 'e', 'r', 'm', 'i', 'n', 'a', 'l'}); -@@ -202,9 +204,18 @@ public class Main { +@@ -206,9 +208,18 @@ public class Main { // This ensures the terminal literal will always match the jline implementation System.setProperty(jline.TerminalFactory.JLINE_TERMINAL, jline.UnsupportedTerminal.class.getName()); } @@ -343,13 +312,13 @@ index b849b2afd009da433fe6cea5837b3ee9bb5c52b4..60d9980ccca6f1ac55b70f7684b917dd + // Paper end if (options.has("noconsole")) { - useConsole = false; + Main.useConsole = false; + useJline = false; // Paper + System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { -@@ -232,7 +243,7 @@ public class Main { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { +@@ -236,7 +247,7 @@ public class Main { System.out.println("Unable to read system info"); } // Paper end @@ -359,7 +328,7 @@ index b849b2afd009da433fe6cea5837b3ee9bb5c52b4..60d9980ccca6f1ac55b70f7684b917dd net.minecraft.server.Main.main(options); } catch (Throwable t) { diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java -index 4580642e0ee79e6d9c9bef0344e643bbc551205c..829c62b6d55cb5706be3ce6bdc758d6b204844ee 100644 +index 76fb1ecd47cb86b50486effe8cc7fe4abf8e311c..21f889ddec72b40f5954eec07417e08d192b4661 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java @@ -5,15 +5,13 @@ import java.util.EnumMap; @@ -388,10 +357,10 @@ index 4580642e0ee79e6d9c9bef0344e643bbc551205c..829c62b6d55cb5706be3ce6bdc758d6b + }*/ // Paper } diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java -index befcc19f9b56df9096b98a23b0020f1db793ea5b..a957695457cf3252848ce6ef37069692841b8e28 100644 +index 0b4c62387c1093652ac15b64a8703249de4cf088..b996fde481cebbbcce80a6c267591136db7cc0bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java -@@ -4,20 +4,31 @@ import java.util.Collections; +@@ -4,50 +4,73 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.logging.Level; @@ -427,7 +396,14 @@ index befcc19f9b56df9096b98a23b0020f1db793ea5b..a957695457cf3252848ce6ef37069692 Waitable> waitable = new Waitable>() { @Override protected List evaluate() { -@@ -29,25 +40,37 @@ public class ConsoleCommandCompleter implements Completer { +- List offers = ConsoleCommandCompleter.this.server.getCommandMap().tabComplete(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer); ++ List offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - fix remap + +- TabCompleteEvent tabEvent = new TabCompleteEvent(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); +- ConsoleCommandCompleter.this.server.getPluginManager().callEvent(tabEvent); ++ TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); // Paper - fix remap ++ server.getPluginManager().callEvent(tabEvent); // Paper - fix remap + return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); } }; @@ -471,11 +447,11 @@ index befcc19f9b56df9096b98a23b0020f1db793ea5b..a957695457cf3252848ce6ef37069692 } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java -index 70f8d42992aa348ef7b2d03d22cdd59d7c73f0fe..449e99d1b673870ed6892f6ab2c715a2db35c35d 100644 +index 6a073a9dc44d93eba296a0e18a9c7be8a7881725..b4a19d80bbf71591f25729fd0e98590350cb31d0 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java +++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java @@ -17,7 +17,7 @@ public class ServerShutdownThread extends Thread { - server.close(); + this.server.close(); } finally { try { - server.reader.getTerminal().restore(); @@ -484,7 +460,7 @@ index 70f8d42992aa348ef7b2d03d22cdd59d7c73f0fe..449e99d1b673870ed6892f6ab2c715a2 } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java -index 99564fed7ce77e29dbdc591bcfe656af741acf8a..9a2da548b8860b496e396564b2c8f6383f020193 100644 +index 5b63604aeae9a54e2c61cc4a22115a72f34a56bd..fc07f6bd45712ec0f1aec5fe820034e6d54b39c1 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java +++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java @@ -5,12 +5,12 @@ import java.io.IOException; diff --git a/patches/server-remapped/0149-provide-a-configurable-option-to-disable-creeper-lin.patch b/patches/server/0138-provide-a-configurable-option-to-disable-creeper-lin.patch similarity index 91% rename from patches/server-remapped/0149-provide-a-configurable-option-to-disable-creeper-lin.patch rename to patches/server/0138-provide-a-configurable-option-to-disable-creeper-lin.patch index a511c4d919..38f524ba3b 100644 --- a/patches/server-remapped/0149-provide-a-configurable-option-to-disable-creeper-lin.patch +++ b/patches/server/0138-provide-a-configurable-option-to-disable-creeper-lin.patch @@ -21,10 +21,10 @@ index 9d1cddc6038f0fd0286e4a32013ae98ff0b00dd1..90ca51dfdbb3045dd528450225cba96f + } } diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java -index bb3226310158139c9fcfe204554caffcbb62798c..8f8d0a23d011936150854a0606be3d63b18c57af 100644 +index e758c112662f65646fc2966e21bf631d8953a3e1..ddc48d37f962b6743f3f356745c9ebe6a06f79f1 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java -@@ -261,7 +261,7 @@ public class Creeper extends Monster { +@@ -281,7 +281,7 @@ public class Creeper extends Monster implements PowerableMob { private void spawnLingeringCloud() { Collection collection = this.getActiveEffects(); diff --git a/patches/server-remapped/0150-Item-canEntityPickup.patch b/patches/server/0139-Item-canEntityPickup.patch similarity index 73% rename from patches/server-remapped/0150-Item-canEntityPickup.patch rename to patches/server/0139-Item-canEntityPickup.patch index 569a928f31..6f930c25fa 100644 --- a/patches/server-remapped/0150-Item-canEntityPickup.patch +++ b/patches/server/0139-Item-canEntityPickup.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Item#canEntityPickup diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 46f0ebfc99352ec8b64bdff2c6bb8d17ecfeb619..eb35c69bb777ba8d83b2304ff9f862512643e745 100644 +index b13774873f795b149c15fddb8053d9419f1841ca..2ed756c73b0cfddb559126d85316f37c3f958c0c 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -605,6 +605,11 @@ public abstract class Mob extends LivingEntity { +@@ -614,6 +614,11 @@ public abstract class Mob extends LivingEntity { ItemEntity entityitem = (ItemEntity) iterator.next(); - if (!entityitem.removed && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) { + if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) { + // Paper Start + if (!entityitem.canMobPickup) { + continue; @@ -21,10 +21,10 @@ index 46f0ebfc99352ec8b64bdff2c6bb8d17ecfeb619..eb35c69bb777ba8d83b2304ff9f86251 } } diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 78dc5ac986afaba04176f64afbb035442cd41d38..7aba507e171f34e213b3c034e345e7397a44d2b5 100644 +index bf6daeefef5a60ebc612c0347eb34d581fb8851a..9611388a6aeebb86b19d89c526f53dfed4d3ed27 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -46,6 +46,7 @@ public class ItemEntity extends Entity { +@@ -51,6 +51,7 @@ public class ItemEntity extends Entity { private UUID owner; public final float bobOffs; private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit @@ -33,18 +33,20 @@ index 78dc5ac986afaba04176f64afbb035442cd41d38..7aba507e171f34e213b3c034e345e739 public ItemEntity(EntityType type, Level world) { super(type, world); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java -index 6e394ce6ea4177e1758e27074a4fd54d716edc3d..9a410f557988d737c3b930a79ef2ccb2b5c8b406 100644 +index b9044654d22a47cfa952dcf25754ad0d87fc0844..0d262c99c7e9ef06e297612b1802c493700f64ae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java -@@ -49,6 +49,16 @@ public class CraftItem extends CraftEntity implements Item { +@@ -49,6 +49,18 @@ public class CraftItem extends CraftEntity implements Item { item.age = value; } + // Paper Start ++ @Override + public boolean canMobPickup() { + return item.canMobPickup; + } + ++ @Override + public void setCanMobPickup(boolean canMobPickup) { + item.canMobPickup = canMobPickup; + } @@ -52,4 +54,4 @@ index 6e394ce6ea4177e1758e27074a4fd54d716edc3d..9a410f557988d737c3b930a79ef2ccb2 + @Override public void setOwner(UUID uuid) { - item.setOwner(uuid); + this.item.setOwner(uuid); diff --git a/patches/server-remapped/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch b/patches/server/0140-PlayerPickupItemEvent-setFlyAtPlayer.patch similarity index 76% rename from patches/server-remapped/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch rename to patches/server/0140-PlayerPickupItemEvent-setFlyAtPlayer.patch index a5081735fc..fd524d8436 100644 --- a/patches/server-remapped/0151-PlayerPickupItemEvent-setFlyAtPlayer.patch +++ b/patches/server/0140-PlayerPickupItemEvent-setFlyAtPlayer.patch @@ -5,20 +5,20 @@ Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 7aba507e171f34e213b3c034e345e7397a44d2b5..72d1e83ac5e4ae3c943ca5ec1058f0d7ad2903cd 100644 +index 9611388a6aeebb86b19d89c526f53dfed4d3ed27..d17af2ec8f72bf0cbe5928e7a83c06ba5ad4503d 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -362,6 +362,7 @@ public class ItemEntity extends Entity { +@@ -379,6 +379,7 @@ public class ItemEntity extends Entity { // CraftBukkit start - fire PlayerPickupItemEvent - int canHold = player.inventory.canHold(itemstack); + int canHold = player.getInventory().canHold(itemstack); int remaining = i - canHold; + boolean flyAtPlayer = false; // Paper if (this.pickupDelay <= 0 && canHold > 0) { itemstack.setCount(canHold); -@@ -369,8 +370,14 @@ public class ItemEntity extends Entity { +@@ -386,8 +387,14 @@ public class ItemEntity extends Entity { PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); - playerEvent.setCancelled(!player.canPickUpLoot); + playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems()); this.level.getCraftServer().getPluginManager().callEvent(playerEvent); + flyAtPlayer = playerEvent.getFlyAtPlayer(); // Paper if (playerEvent.isCancelled()) { @@ -31,10 +31,10 @@ index 7aba507e171f34e213b3c034e345e7397a44d2b5..72d1e83ac5e4ae3c943ca5ec1058f0d7 return; } -@@ -400,7 +407,11 @@ public class ItemEntity extends Entity { +@@ -417,7 +424,11 @@ public class ItemEntity extends Entity { // CraftBukkit end - if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(player.getUUID())) && player.inventory.add(itemstack)) { + if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(player.getUUID())) && player.getInventory().add(itemstack)) { - player.take(this, i); + // Paper Start + if (flyAtPlayer) { @@ -42,5 +42,5 @@ index 7aba507e171f34e213b3c034e345e7397a44d2b5..72d1e83ac5e4ae3c943ca5ec1058f0d7 + } + // Paper End if (itemstack.isEmpty()) { - this.remove(); + this.discard(); itemstack.setCount(i);