diff --git a/build.gradle.kts b/build.gradle.kts index bf83d142a..c82c5ab69 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ subprojects { tasks { withType().configureEach { + options.compilerArgs.add("--add-modules=jdk.incubator.vector") options.encoding = "UTF-8" options.release.set(17) } diff --git a/gradle.properties b/gradle.properties index 616875058..37e3dd762 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group = org.plazmamc.plazma -version = 1.20.1-R0.1-SNAPSHOT +version = 1.20.2-R0.1-SNAPSHOT -paperCommit = 773dd724469bae89d0c2075edc3d1ddc8d5b0b18 +paperCommit = fe54a13b1301312304d9c1e46ad91b039657120b org.gradle.caching = true org.gradle.parallel = true diff --git a/patches/api/0001-Pufferfish-API-Changes.patch b/patches/api/0001-Pufferfish-API-Changes.patch index 822eacdc2..15cb12422 100644 --- a/patches/api/0001-Pufferfish-API-Changes.patch +++ b/patches/api/0001-Pufferfish-API-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 23 Sep 2023 10:20:55 +0000 +From: Kevin Raneri +Date: Wed, 27 Sep 2023 05:21:18 +0000 Subject: [PATCH] Pufferfish API Changes Original: Kevin Raneri @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/build.gradle.kts b/build.gradle.kts -index aed834334385ff3038ae69f3f34d129ad2507960..1ae1907f94a19c37b5820cfb3e9df3bd6bb1a49d 100644 +index 639651972fddce4dff63a0f0a7e566a15b9e2dd6..6c0df825238ca037abeb2ba619983b6f554180ea 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,6 +46,7 @@ dependencies { @@ -31,26 +31,21 @@ index aed834334385ff3038ae69f3f34d129ad2507960..1ae1907f94a19c37b5820cfb3e9df3bd implementation("org.ow2.asm:asm:9.4") implementation("org.ow2.asm:asm-commons:9.4") -@@ -89,6 +90,13 @@ val generateApiVersioningFile by tasks.registering { - } - } +@@ -102,6 +103,8 @@ tasks.jar { -+// Pufferfish Start -+tasks.withType { -+ val compilerArgs = options.compilerArgs -+ compilerArgs.add("--add-modules=jdk.incubator.vector") -+} -+// Pufferfish End -+ - tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") + tasks.withType { + val options = options as StandardJavadocDocletOptions ++ options.addStringOption("-add-modules", "jdk.incubator.vector") // Pufferfish ++ options.addStringOption("Xdoclint:none", "-quiet") // Pufferfish + options.overview = "src/main/javadoc/overview.html" + options.use() + options.isDocFilesSubDirs = true diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java new file mode 100644 -index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8eb08fb68a +index 0000000000000000000000000000000000000000..ff42019da93c365ea1365e2e0f7c51b196a10948 --- /dev/null +++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java -@@ -0,0 +1,161 @@ +@@ -0,0 +1,162 @@ +package gg.pufferfish.pufferfish.sentry; + +import com.google.gson.Gson; @@ -66,6 +61,7 @@ index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8e +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredListener; ++import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class SentryContext { @@ -98,7 +94,7 @@ index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8e + ThreadContext.remove("pufferfishsentry_playerid"); + } + -+ public static void setEventContext(Event event, RegisteredListener registration) { ++ public static void setEventContext(@NotNull Event event, @NotNull RegisteredListener registration) { + setPluginContext(registration.getPlugin()); + + try { @@ -171,43 +167,43 @@ index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8e + private Event event; + private RegisteredListener registeredListener; + -+ public Plugin getPlugin() { ++ public @Nullable Plugin getPlugin() { + return plugin; + } + -+ public void setPlugin(Plugin plugin) { ++ public void setPlugin(@Nullable Plugin plugin) { + this.plugin = plugin; + } + -+ public Command getCommand() { ++ public @Nullable Command getCommand() { + return command; + } + -+ public void setCommand(Command command) { ++ public void setCommand(@Nullable Command command) { + this.command = command; + } + -+ public String getCommandLine() { ++ public @Nullable String getCommandLine() { + return commandLine; + } + -+ public void setCommandLine(String commandLine) { ++ public void setCommandLine(@Nullable String commandLine) { + this.commandLine = commandLine; + } + -+ public Event getEvent() { ++ public @Nullable Event getEvent() { + return event; + } + -+ public void setEvent(Event event) { ++ public void setEvent(@Nullable Event event) { + this.event = event; + } + -+ public RegisteredListener getRegisteredListener() { ++ public @Nullable RegisteredListener getRegisteredListener() { + return registeredListener; + } + -+ public void setRegisteredListener(RegisteredListener registeredListener) { ++ public void setRegisteredListener(@Nullable RegisteredListener registeredListener) { + this.registeredListener = registeredListener; + } + } diff --git a/patches/api/0002-Purpur-API-Changes.patch b/patches/api/0002-Purpur-API-Changes.patch index 919044dec..82cd8684d 100644 --- a/patches/api/0002-Purpur-API-Changes.patch +++ b/patches/api/0002-Purpur-API-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 23 Sep 2023 10:28:31 +0000 +From: William Blake Galbreath +Date: Wed, 27 Sep 2023 05:28:53 +0000 Subject: [PATCH] Purpur API Changes Original: PurpurMC @@ -24,19 +24,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/build.gradle.kts b/build.gradle.kts -index 1ae1907f94a19c37b5820cfb3e9df3bd6bb1a49d..dfb989a18ab17fec3b8f0cf90ce2fc1048215265 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -109,6 +109,8 @@ tasks.jar { - } - - tasks.withType { -+ (options as StandardJavadocDocletOptions).addStringOption("-add-modules", "jdk.incubator.vector") // Purpur - our javadocs need this for pufferfish's SIMD patch -+ (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") // Purpur - silence Paper's bajillion javadoc warnings - val options = options as StandardJavadocDocletOptions - options.overview = "src/main/javadoc/overview.html" - options.use() diff --git a/src/main/java/co/aikar/timings/TimedEventExecutor.java b/src/main/java/co/aikar/timings/TimedEventExecutor.java index 8f29c1561ba5916cb5634392edd8bd2a5a294a51..6fbc64e0f214d0c8e5afcbe385e414a4e1fe1c72 100644 --- a/src/main/java/co/aikar/timings/TimedEventExecutor.java @@ -169,10 +156,10 @@ index e801e79fa57c44b2e5d359647c920f88064826f1..1abfcee0f6d632f4cd8d74b4994a90c9 new ArrayList(TIMINGS_SUBCOMMANDS.size())); } diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java -index b7a2cecb334ce39fa09d8ab949a29eedbdc44c36..b1f35c68373edfe666ca05b50f0ec022a1859ce9 100644 +index 0c4dbb9ef63fa8575b5546239443cb2bd91ba847..b347224c223569297ee67ac630a710fdf28748ea 100644 --- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java -@@ -201,6 +201,18 @@ public interface VanillaGoal extends Goal { +@@ -198,6 +198,18 @@ public interface VanillaGoal extends Goal { GoalKey CLIMB_ON_TOP_OF_POWDER_SNOW = GoalKey.of(Mob.class, NamespacedKey.minecraft("climb_on_top_of_powder_snow")); GoalKey WOLF_PANIC = GoalKey.of(Wolf.class, NamespacedKey.minecraft("wolf_panic")); @@ -189,7 +176,7 @@ index b7a2cecb334ce39fa09d8ab949a29eedbdc44c36..b1f35c68373edfe666ca05b50f0ec022 + // Purpur end + /** - * @deprecated removed in 1.16 + * @deprecated removed in 1.20.2 */ diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java index a736d7bcdc5861a01b66ba36158db1c716339346..22fc165fd9c95f0f3ae1be7a0857e48cc50fad5b 100644 @@ -431,10 +418,10 @@ index 918a045165cdcde264bc24082b7afebb407271de..687d11619379aead7f665d4a5f8f8bcc + // Purpur end } diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java -index 03b47012447430a350e152920f754d993d4023db..3ad843d519e239430c5f4f5754a8da3026ed0f8e 100644 +index 060a77008871682cc2deac72833a3641031408de..865512385d08c6f93c30e1eb83f604e354b60d9b 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -11047,4 +11047,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla +@@ -11050,4 +11050,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla public boolean isEnabledByFeature(@NotNull World world) { return Bukkit.getDataPackManager().isEnabledByFeature(this, world); } @@ -724,7 +711,7 @@ index 8d8fe04e6b09d2a5b1cc05002073df5c58cdcb96..aaef58468a3c31f35e5067ed4263e9dd + // Purpur end } diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index b8b97df069b28fa3cf32f1ad1f01f586a0cfbc78..63bf1d70cce9176f47a158a4a767b1bf38d60dbd 100644 +index da524a71af74b02515b037f7fe09ba6988e2c8bf..3679c3b8d31ab8de08ecabd56bf92ffc062f971c 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java @@ -4008,6 +4008,86 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1200,10 +1187,10 @@ index bc84b892cae5fe7019a3ad481e9da79956efa1fe..48eb5b00c460cccde29d327cef1d63fc + // Purpur end } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index f59cbc92334c7b7b20e593a58232fb3c4434f12b..d3d5d2c78cc4ee36beaa355ef7e61ef13332abab 100644 +index 20fa1024f9ad8f478a347be5c554b5e45b398a1c..0df709ed758401f04b3f565dc1f6492a55f5363c 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -3273,4 +3273,143 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -3278,4 +3278,122 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Override Spigot spigot(); // Spigot end @@ -1236,27 +1223,6 @@ index f59cbc92334c7b7b20e593a58232fb3c4434f12b..d3d5d2c78cc4ee36beaa355ef7e61ef1 + void resetIdleTimer(); + + /** -+ * Check if player is invulnerable from recently spawning or accepting a resource pack -+ * -+ * @return True if invulnerable -+ */ -+ boolean isSpawnInvulnerable(); -+ -+ /** -+ * Get invulnerable ticks remaining -+ * -+ * @return Invulnerable ticks -+ */ -+ int getSpawnInvulnerableTicks(); -+ -+ /** -+ * Set invulnerable ticks remaining -+ * -+ * @param invulnerableTicks Invulnerable ticks remaining -+ */ -+ void setSpawnInvulnerableTicks(int invulnerableTicks); -+ -+ /** + * Creates debug block highlight on specified block location and show it to this player. + *

+ * Clients may be inconsistent in displaying it. @@ -2266,18 +2232,10 @@ index e4b6f278a811acbb0070e311c5c3bdaff7b00474..ee83ecb054099cb85168a9499dfe967a { java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix diff --git a/src/main/java/org/bukkit/potion/PotionEffect.java b/src/main/java/org/bukkit/potion/PotionEffect.java -index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f026703cb80 100644 +index 037af5fd6d71a526c0e6620f2db0cd6df9625261..939ed1931492854c5854cab06730cf235eba7e89 100644 --- a/src/main/java/org/bukkit/potion/PotionEffect.java +++ b/src/main/java/org/bukkit/potion/PotionEffect.java -@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableMap; - import java.util.Map; - import java.util.NoSuchElementException; - import org.bukkit.Color; -+import org.bukkit.NamespacedKey; - import org.bukkit.configuration.serialization.ConfigurationSerializable; - import org.bukkit.configuration.serialization.SerializableAs; - import org.bukkit.entity.LivingEntity; -@@ -31,12 +32,14 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -32,12 +32,14 @@ public class PotionEffect implements ConfigurationSerializable { private static final String AMBIENT = "ambient"; private static final String PARTICLES = "has-particles"; private static final String ICON = "has-icon"; @@ -2292,7 +2250,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 /** * Creates a potion effect. -@@ -49,6 +52,36 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -50,6 +52,36 @@ public class PotionEffect implements ConfigurationSerializable { * @param icon the icon status, see {@link PotionEffect#hasIcon()} */ public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon) { @@ -2329,7 +2287,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 Preconditions.checkArgument(type != null, "effect type cannot be null"); this.type = type; this.duration = duration; -@@ -56,6 +89,7 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -57,6 +89,7 @@ public class PotionEffect implements ConfigurationSerializable { this.ambient = ambient; this.particles = particles; this.icon = icon; @@ -2337,7 +2295,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 } /** -@@ -103,36 +137,43 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -104,36 +137,43 @@ public class PotionEffect implements ConfigurationSerializable { * @param map the map to deserialize from */ public PotionEffect(@NotNull Map map) { @@ -2387,8 +2345,8 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 + @NotNull private static PotionEffectType getEffectType(@NotNull Map map) { - int type = getInt(map, TYPE); -@@ -159,17 +200,33 @@ public class PotionEffect implements ConfigurationSerializable { + PotionEffectType effect; +@@ -166,17 +206,33 @@ public class PotionEffect implements ConfigurationSerializable { return def; } @@ -2407,21 +2365,16 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 @NotNull public Map serialize() { - return ImmutableMap.builder() -- .put(TYPE, type.getId()) -- .put(DURATION, duration) -- .put(AMPLIFIER, amplifier) -- .put(AMBIENT, ambient) -- .put(PARTICLES, particles) -- .put(ICON, icon) -- .build(); + // Purpur start - add key, don't serialize if null. + ImmutableMap.Builder builder = ImmutableMap.builder() -+ .put(TYPE, type.getId()) -+ .put(DURATION, duration) -+ .put(AMPLIFIER, amplifier) -+ .put(AMBIENT, ambient) -+ .put(PARTICLES, particles) -+ .put(ICON, icon); + .put(TYPE, type.getKey().toString()) + .put(DURATION, duration) + .put(AMPLIFIER, amplifier) + .put(AMBIENT, ambient) + .put(PARTICLES, particles) +- .put(ICON, icon) +- .build(); ++ .put(ICON, icon); + if(key != null) { + builder.put(KEY, key.toString()); + } @@ -2430,7 +2383,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 } /** -@@ -193,7 +250,7 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -200,7 +256,7 @@ public class PotionEffect implements ConfigurationSerializable { return false; } PotionEffect that = (PotionEffect) obj; @@ -2439,7 +2392,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 } /** -@@ -289,6 +346,24 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -296,6 +352,24 @@ public class PotionEffect implements ConfigurationSerializable { return icon; } @@ -2464,7 +2417,7 @@ index ccdca0d75868135dc7b96daeff2236b225c4add1..cad9f4ddc6be23c595e79419872f8f02 @Override public int hashCode() { int hash = 1; -@@ -303,6 +378,6 @@ public class PotionEffect implements ConfigurationSerializable { +@@ -310,6 +384,6 @@ public class PotionEffect implements ConfigurationSerializable { @Override public String toString() { @@ -4128,18 +4081,3 @@ index 12946bd55fcf7c40d39081779a7fa30049ee6165..9c2d605c50cbf9aefa56ec209df9f6ce + public void stopTiming() { /*handler.stopTiming();*/ } // Purpur } -diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java -index 06e96e5c98f1a7a68c8b4b5e527314c1aa774e38..49bba9a7a02b9cf3a552583315eff2b7dbe060c0 100644 ---- a/src/test/java/org/bukkit/AnnotationTest.java -+++ b/src/test/java/org/bukkit/AnnotationTest.java -@@ -47,6 +47,10 @@ public class AnnotationTest { - "org/bukkit/plugin/java/PluginClassLoader", - // Generic functional interface - "org/bukkit/util/Consumer", -+ // Purpur start -+ "gg/pufferfish/pufferfish/sentry/SentryContext", -+ "gg/pufferfish/pufferfish/sentry/SentryContext$State", -+ // Purpur end - // Paper start - "io/papermc/paper/util/TransformingRandomAccessList", - "io/papermc/paper/util/TransformingRandomAccessList$TransformedListIterator", diff --git a/patches/api/0004-Publish-Packages.patch b/patches/api/0004-Publish-Packages.patch index 23a537fa4..0cbaa8269 100644 --- a/patches/api/0004-Publish-Packages.patch +++ b/patches/api/0004-Publish-Packages.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Publish-Packages diff --git a/build.gradle.kts b/build.gradle.kts -index dfb989a18ab17fec3b8f0cf90ce2fc1048215265..bfcb6cf6cf29fec6e22a89cc6045c7030262bb1c 100644 +index 6c0df825238ca037abeb2ba619983b6f554180ea..54da0cab8681daac2dd9fbf0eb94de471819d4c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -168,3 +168,22 @@ tasks.check { +@@ -171,3 +171,22 @@ tasks.check { dependsOn(scanJar) } // Paper end diff --git a/patches/server/0001-Pufferfish-Server-Changes.patch b/patches/server/0001-Pufferfish-Server-Changes.patch index 6b303e5ad..18d3caf62 100644 --- a/patches/server/0001-Pufferfish-Server-Changes.patch +++ b/patches/server/0001-Pufferfish-Server-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 23 Sep 2023 10:20:55 +0000 +From: Kevin Raneri +Date: Wed, 27 Sep 2023 05:21:18 +0000 Subject: [PATCH] Pufferfish Server Changes Original: Kevin Raneri @@ -20,10 +20,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/build.gradle.kts b/build.gradle.kts -index 7e0580bbd0a557c7bb269507a99d25db07bf31f1..4d89c46c7ee559acf986ff5081a42fe91cb5a257 100644 +index 683159586641dd9aa42ae96fa51602469755723f..de0a05602389ebb005bb7fd3c8d78da045d55bbe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -13,8 +13,13 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { @@ -34,40 +34,26 @@ index 7e0580bbd0a557c7bb269507a99d25db07bf31f1..4d89c46c7ee559acf986ff5081a42fe9 + implementation("io.papermc.paper:paper-mojangapi:1.19.2-R0.1-SNAPSHOT") { + exclude("io.papermc.paper", "paper-api") + } ++ implementation("com.github.technove:Flare:34637f3f87") // flare + // Pufferfish end // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -52,6 +56,13 @@ dependencies { +@@ -52,6 +57,13 @@ dependencies { runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3") runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3") + // Pufferfish start + implementation("org.yaml:snakeyaml:1.32") -+ implementation ("com.github.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { ++ implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { + exclude(group="org.yaml", module="snakeyaml") + } + // Pufferfish end + testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test - testImplementation("junit:junit:4.13.2") - testImplementation("org.hamcrest:hamcrest-library:1.3") -@@ -60,6 +71,14 @@ dependencies { - } - - val craftbukkitPackageVersion = "1_20_R1" // Paper -+ -+// Pufferfish Start -+tasks.withType { -+ val compilerArgs = options.compilerArgs -+ compilerArgs.add("--add-modules=jdk.incubator.vector") -+} -+// Pufferfish End -+ - tasks.jar { - archiveClassifier.set("dev") - -@@ -72,7 +91,7 @@ tasks.jar { + testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") + testImplementation("org.hamcrest:hamcrest:2.2") +@@ -72,7 +84,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -295,126 +281,6 @@ index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7 + this.entries[toRemovePos] = new FluidDirectionEntry(data, flag); + } +} -diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java -new file mode 100644 -index 0000000000000000000000000000000000000000..1b7a4ee47f4445d7f2ac91d3a73ae113edbdddb2 ---- /dev/null -+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java -@@ -0,0 +1,114 @@ -+package gg.airplane.structs; -+ -+import net.minecraft.core.NonNullList; -+import net.minecraft.world.item.ItemStack; -+import org.apache.commons.lang.Validate; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.AbstractList; -+import java.util.Arrays; -+import java.util.List; -+ -+public class ItemListWithBitset extends AbstractList { -+ public static ItemListWithBitset fromList(List list) { -+ if (list instanceof ItemListWithBitset ours) { -+ return ours; -+ } -+ return new ItemListWithBitset(list); -+ } -+ -+ private static ItemStack[] createArray(int size) { -+ ItemStack[] array = new ItemStack[size]; -+ Arrays.fill(array, ItemStack.EMPTY); -+ return array; -+ } -+ -+ private final ItemStack[] items; -+ -+ private long bitSet = 0; -+ private final long allBits; -+ -+ private static class OurNonNullList extends NonNullList { -+ protected OurNonNullList(List delegate) { -+ super(delegate, ItemStack.EMPTY); -+ } -+ } -+ -+ public final NonNullList nonNullList = new OurNonNullList(this); -+ -+ private ItemListWithBitset(List list) { -+ this(list.size()); -+ -+ for (int i = 0; i < list.size(); i++) { -+ this.set(i, list.get(i)); -+ } -+ } -+ -+ public ItemListWithBitset(int size) { -+ Validate.isTrue(size < Long.BYTES * 8, "size is too large"); -+ -+ this.items = createArray(size); -+ this.allBits = ((1L << size) - 1); -+ } -+ -+ public boolean isCompletelyEmpty() { -+ return this.bitSet == 0; -+ } -+ -+ public boolean hasFullStacks() { -+ return (this.bitSet & this.allBits) == allBits; -+ } -+ -+ @Override -+ public ItemStack set(int index, @NotNull ItemStack itemStack) { -+ ItemStack existing = this.items[index]; -+ -+ this.items[index] = itemStack; -+ -+ if (itemStack == ItemStack.EMPTY) { -+ this.bitSet &= ~(1L << index); -+ } else { -+ this.bitSet |= 1L << index; -+ } -+ -+ return existing; -+ } -+ -+ @NotNull -+ @Override -+ public ItemStack get(int var0) { -+ return this.items[var0]; -+ } -+ -+ @Override -+ public int size() { -+ return this.items.length; -+ } -+ -+ @Override -+ public void clear() { -+ Arrays.fill(this.items, ItemStack.EMPTY); -+ } -+ -+ // these are unsupported for block inventories which have a static size -+ @Override -+ public void add(int var0, ItemStack var1) { -+ throw new UnsupportedOperationException(); -+ } -+ -+ @Override -+ public ItemStack remove(int var0) { -+ throw new UnsupportedOperationException(); -+ } -+ -+ @Override -+ public String toString() { -+ return "ItemListWithBitset{" + -+ "items=" + Arrays.toString(items) + -+ ", bitSet=" + Long.toString(bitSet, 2) + -+ ", allBits=" + Long.toString(allBits, 2) + -+ ", size=" + this.items.length + -+ '}'; -+ } -+} diff --git a/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java new file mode 100644 index 0000000000000000000000000000000000000000..a7f297ebb569f7c1f205e967ca485be70013a714 @@ -616,10 +482,10 @@ index 0000000000000000000000000000000000000000..020368da69b9a492155f6de6297f7473 +} diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..95d1a8a5b349f7849c040026bfa3469d03d92bfd +index 0000000000000000000000000000000000000000..7b091c1258c3f33933ec30a15d963e9d5f069ba7 --- /dev/null +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -@@ -0,0 +1,295 @@ +@@ -0,0 +1,328 @@ +package gg.pufferfish.pufferfish; + +import gg.pufferfish.pufferfish.simd.SIMDDetection; @@ -637,6 +503,7 @@ index 0000000000000000000000000000000000000000..95d1a8a5b349f7849c040026bfa3469d +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.List; ++import gg.pufferfish.pufferfish.flare.FlareCommand; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.Level; +import org.bukkit.configuration.ConfigurationSection; @@ -645,6 +512,13 @@ index 0000000000000000000000000000000000000000..95d1a8a5b349f7849c040026bfa3469d +import org.simpleyaml.configuration.comments.CommentType; +import org.simpleyaml.configuration.file.YamlFile; +import org.simpleyaml.exceptions.InvalidConfigurationException; ++import org.bukkit.command.SimpleCommandMap; ++ ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.List; ++import java.net.URI; ++import java.util.Collections; + +public class PufferfishConfig { + @@ -904,6 +778,31 @@ index 0000000000000000000000000000000000000000..95d1a8a5b349f7849c040026bfa3469d + "the ender dragon whenever a player places an end crystal."); + } + ++ public static URI profileWebUrl; ++ private static void profilerOptions() { ++ profileWebUrl = URI.create(getString("flare.url", "https://flare.airplane.gg", "Sets the server to use for profiles.")); ++ ++ setComment("flare", "Configures Flare, the built-in profiler"); ++ } ++ ++ ++ public static String accessToken; ++ private static void airplaneWebServices() { ++ accessToken = getString("web-services.token", ""); ++ // todo lookup token (off-thread) and let users know if their token is valid ++ if (accessToken.length() > 0) { ++ gg.pufferfish.pufferfish.flare.FlareSetup.init(); // Pufferfish ++ SimpleCommandMap commandMap = MinecraftServer.getServer().server.getCommandMap(); ++ if (commandMap.getCommand("flare") == null) { ++ commandMap.register("flare", "Pufferfish", new FlareCommand()); ++ } ++ } ++ ++ setComment("web-services", "Options for connecting to Pufferfish/Airplane's online utilities"); ++ ++ } ++ ++ + public static boolean disableMethodProfiler; + public static boolean disableOutOfOrderChat; + public static boolean suppressNullIdDisconnections; @@ -1079,7 +978,700 @@ index 0000000000000000000000000000000000000000..893d8c0946ef71a0561221dd76bffff0 + return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC); + } +} -\ No newline at end of file +\ No newline at end of file +diff --git a/src/main/java/gg/pufferfish/pufferfish/compat/ServerConfigurations.java b/src/main/java/gg/pufferfish/pufferfish/compat/ServerConfigurations.java +new file mode 100644 +index 0000000000000000000000000000000000000000..4ad189d52b27560424ddb311d0817a334637dc95 +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/compat/ServerConfigurations.java +@@ -0,0 +1,78 @@ ++package gg.pufferfish.pufferfish.compat; ++ ++import co.aikar.timings.TimingsManager; ++import com.google.common.io.Files; ++import org.bukkit.configuration.InvalidConfigurationException; ++import org.bukkit.configuration.file.YamlConfiguration; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.File; ++import java.io.FileInputStream; ++import java.io.IOException; ++import java.nio.charset.StandardCharsets; ++import java.util.Arrays; ++import java.util.HashMap; ++import java.util.List; ++import java.util.Map; ++import java.util.Properties; ++import java.util.stream.Collectors; ++ ++public class ServerConfigurations { ++ ++ public static final String[] configurationFiles = new String[]{ ++ "server.properties", ++ "bukkit.yml", ++ "spigot.yml", ++ // "paper.yml", // TODO: Figure out what to do with this. ++ "pufferfish.yml" ++ }; ++ ++ public static Map getCleanCopies() throws IOException { ++ Map files = new HashMap<>(configurationFiles.length); ++ for (String file : configurationFiles) { ++ files.put(file, getCleanCopy(file)); ++ } ++ return files; ++ } ++ ++ public static String getCleanCopy(String configName) throws IOException { ++ File file = new File(configName); ++ List hiddenConfigs = TimingsManager.hiddenConfigs; ++ ++ switch (Files.getFileExtension(configName)) { ++ case "properties": { ++ Properties properties = new Properties(); ++ try (FileInputStream inputStream = new FileInputStream(file)) { ++ properties.load(inputStream); ++ } ++ for (String hiddenConfig : hiddenConfigs) { ++ properties.remove(hiddenConfig); ++ } ++ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ++ properties.store(outputStream, ""); ++ return Arrays.stream(outputStream.toString() ++ .split("\n")) ++ .filter(line -> !line.startsWith("#")) ++ .collect(Collectors.joining("\n")); ++ } ++ case "yml": { ++ YamlConfiguration configuration = new YamlConfiguration(); ++ try { ++ configuration.load(file); ++ } catch (InvalidConfigurationException e) { ++ throw new IOException(e); ++ } ++ configuration.options().header(null); ++ for (String key : configuration.getKeys(true)) { ++ if (hiddenConfigs.contains(key)) { ++ configuration.set(key, null); ++ } ++ } ++ return configuration.saveToString(); ++ } ++ default: ++ throw new IllegalArgumentException("Bad file type " + configName); ++ } ++ } ++ ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/CustomCategories.java b/src/main/java/gg/pufferfish/pufferfish/flare/CustomCategories.java +new file mode 100644 +index 0000000000000000000000000000000000000000..401b42e29bccb5251684062f10b2e0f8b091bc95 +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/CustomCategories.java +@@ -0,0 +1,8 @@ ++package gg.pufferfish.pufferfish.flare; ++ ++import co.technove.flare.live.category.GraphCategory; ++ ++public class CustomCategories { ++ public static final GraphCategory MC_PERF = new GraphCategory("MC Performance"); ++ public static final GraphCategory ENTITIES_AND_CHUNKS = new GraphCategory("Entities & Chunks"); ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java b/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3785d1512eb650f91d58903672c059e7449598fc +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java +@@ -0,0 +1,136 @@ ++package gg.pufferfish.pufferfish.flare; ++ ++import co.technove.flare.exceptions.UserReportableException; ++import co.technove.flare.internal.profiling.ProfileType; ++import gg.pufferfish.pufferfish.PufferfishConfig; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.event.ClickEvent; ++import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.format.TextColor; ++import net.kyori.adventure.text.format.TextDecoration; ++import net.minecraft.server.MinecraftServer; ++import org.apache.logging.log4j.Level; ++import org.bukkit.Bukkit; ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import org.bukkit.command.ConsoleCommandSender; ++import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; ++import org.bukkit.util.StringUtil; ++import org.jetbrains.annotations.NotNull; ++ ++import java.time.Duration; ++import java.util.ArrayList; ++import java.util.Collections; ++import java.util.List; ++ ++public class FlareCommand extends Command { ++ ++ private static final String BASE_URL = "https://blog.airplane.gg/flare-tutorial/#setting-the-access-token"; ++ private static final TextColor HEX = TextColor.fromHexString("#e3eaea"); ++ private static final Component PREFIX = Component.text() ++ .append(Component.text("Flare ✈") ++ .color(TextColor.fromHexString("#6a7eda")) ++ .decoration(TextDecoration.BOLD, true) ++ .append(Component.text(" ", HEX) ++ .decoration(TextDecoration.BOLD, false))) ++ .asComponent(); ++ ++ public FlareCommand() { ++ super("flare", "Profile your server with Flare", "/flare", Collections.singletonList("profile")); ++ this.setPermission("airplane.flare"); ++ } ++ ++ @Override ++ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String @NotNull [] args) { ++ if (!testPermission(sender)) return true; ++ if (PufferfishConfig.accessToken.length() == 0) { ++ Component clickable = Component.text(BASE_URL, HEX, TextDecoration.UNDERLINED).clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, BASE_URL)); ++ ++ sender.sendMessage(PREFIX.append(Component.text("Flare currently requires an access token to use. To learn more, visit ").color(HEX).append(clickable))); ++ return true; ++ } ++ ++ if (!FlareSetup.isSupported()) { ++ sender.sendMessage(PREFIX.append( ++ Component.text("Profiling is not supported in this environment, check your startup logs for the error.", NamedTextColor.RED))); ++ return true; ++ } ++ if (ProfilingManager.isProfiling()) { ++ if (args.length == 1 && args[0].equalsIgnoreCase("status")) { ++ sender.sendMessage(PREFIX.append(Component.text("Current profile has been ran for " + ProfilingManager.getTimeRan().toString(), HEX))); ++ return true; ++ } ++ if (ProfilingManager.stop()) { ++ if (!(sender instanceof ConsoleCommandSender)) { ++ sender.sendMessage(PREFIX.append(Component.text("Profiling has been stopped.", HEX))); ++ } ++ } else { ++ sender.sendMessage(PREFIX.append(Component.text("Profiling has already been stopped.", HEX))); ++ } ++ } else { ++ ProfileType profileType = ProfileType.ITIMER; ++ if (args.length > 0) { ++ try { ++ profileType = ProfileType.valueOf(args[0].toUpperCase()); ++ } catch (Exception e) { ++ sender.sendMessage(PREFIX.append(Component ++ .text("Invalid profile type ", HEX) ++ .append(Component.text(args[0], HEX, TextDecoration.BOLD) ++ .append(Component.text("!", HEX))) ++ )); ++ } ++ } ++ ProfileType finalProfileType = profileType; ++ Bukkit.getScheduler().runTaskAsynchronously(new MinecraftInternalPlugin(), () -> { ++ try { ++ if (ProfilingManager.start(finalProfileType)) { ++ if (!(sender instanceof ConsoleCommandSender)) { ++ sender.sendMessage(PREFIX.append(Component ++ .text("Flare has been started: " + ProfilingManager.getProfilingUri(), HEX) ++ .clickEvent(ClickEvent.openUrl(ProfilingManager.getProfilingUri())) ++ )); ++ sender.sendMessage(PREFIX.append(Component.text(" Run /" + commandLabel + " to stop the Flare.", HEX))); ++ } ++ } else { ++ sender.sendMessage(PREFIX.append(Component ++ .text("Flare has already been started: " + ProfilingManager.getProfilingUri(), HEX) ++ .clickEvent(ClickEvent.openUrl(ProfilingManager.getProfilingUri())) ++ )); ++ } ++ } catch (UserReportableException e) { ++ sender.sendMessage(Component.text("Flare failed to start: " + e.getUserError(), NamedTextColor.RED)); ++ if (e.getCause() != null) { ++ MinecraftServer.LOGGER.warn("Flare failed to start", e); ++ } ++ } ++ }); ++ } ++ return true; ++ } ++ ++ @Override ++ public @NotNull List tabComplete(@NotNull CommandSender sender, @NotNull String alias, String @NotNull [] args) throws IllegalArgumentException { ++ List list = new ArrayList<>(); ++ if (ProfilingManager.isProfiling()) { ++ if (args.length == 1) { ++ String lastWord = args[0]; ++ if (StringUtil.startsWithIgnoreCase("status", lastWord)) { ++ list.add("status"); ++ } ++ if (StringUtil.startsWithIgnoreCase("stop", lastWord)) { ++ list.add("stop"); ++ } ++ } ++ } else { ++ if (args.length <= 1) { ++ String lastWord = args.length == 0 ? "" : args[0]; ++ for (ProfileType value : ProfileType.values()) { ++ if (StringUtil.startsWithIgnoreCase(value.getInternalName(), lastWord)) { ++ list.add(value.name().toLowerCase()); ++ } ++ } ++ } ++ } ++ return list; ++ } ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/FlareSetup.java b/src/main/java/gg/pufferfish/pufferfish/flare/FlareSetup.java +new file mode 100644 +index 0000000000000000000000000000000000000000..cd22e4dcc8b7b57b10a95ef084637249a98e524f +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/FlareSetup.java +@@ -0,0 +1,33 @@ ++package gg.pufferfish.pufferfish.flare; ++ ++import co.technove.flare.FlareInitializer; ++import co.technove.flare.internal.profiling.InitializationException; ++import net.minecraft.server.MinecraftServer; ++import org.apache.logging.log4j.Level; ++ ++public class FlareSetup { ++ ++ private static boolean initialized = false; ++ private static boolean supported = false; ++ ++ public static void init() { ++ if (initialized) { ++ return; ++ } ++ ++ initialized = true; ++ try { ++ for (String warning : FlareInitializer.initialize()) { ++ MinecraftServer.LOGGER.warn("Flare warning: " + warning); ++ } ++ supported = true; ++ } catch (InitializationException e) { ++ MinecraftServer.LOGGER.warn("Failed to enable Flare:", e); ++ } ++ } ++ ++ public static boolean isSupported() { ++ return supported; ++ } ++ ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/PluginLookup.java b/src/main/java/gg/pufferfish/pufferfish/flare/PluginLookup.java +new file mode 100644 +index 0000000000000000000000000000000000000000..74aab5eb4b54ffbaf19b8976ffb8ca4a64584006 +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/PluginLookup.java +@@ -0,0 +1,44 @@ ++package gg.pufferfish.pufferfish.flare; ++ ++import com.google.common.cache.Cache; ++import com.google.common.cache.CacheBuilder; ++import org.bukkit.Bukkit; ++import org.bukkit.plugin.Plugin; ++import org.bukkit.plugin.java.PluginClassLoader; ++ ++import java.util.Optional; ++import java.util.concurrent.TimeUnit; ++ ++public class PluginLookup { ++ private static final Cache pluginNameCache = CacheBuilder.newBuilder() ++ .expireAfterAccess(1, TimeUnit.MINUTES) ++ .maximumSize(1024) ++ .build(); ++ ++ public static Optional getPluginForClass(String name) { ++ if (name.startsWith("net.minecraft") || name.startsWith("java.") || name.startsWith("com.mojang") || ++ name.startsWith("com.google") || name.startsWith("it.unimi") || name.startsWith("sun")) { ++ return Optional.empty(); ++ } ++ ++ String existing = pluginNameCache.getIfPresent(name); ++ if (existing != null) { ++ return Optional.ofNullable(existing.isEmpty() ? null : existing); ++ } ++ ++ String newValue = ""; ++ ++ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { ++ ClassLoader classLoader = plugin.getClass().getClassLoader(); ++ if (classLoader instanceof PluginClassLoader) { ++ if (((PluginClassLoader) classLoader)._airplane_hasClass(name)) { ++ newValue = plugin.getName(); ++ break; ++ } ++ } ++ } ++ ++ pluginNameCache.put(name, newValue); ++ return Optional.ofNullable(newValue.isEmpty() ? null : newValue); ++ } ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java b/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java +new file mode 100644 +index 0000000000000000000000000000000000000000..e3f76eb11a261c3347f0cd89b5da309bc2dc82f9 +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java +@@ -0,0 +1,151 @@ ++package gg.pufferfish.pufferfish.flare; ++ ++import co.technove.flare.Flare; ++import co.technove.flare.FlareAuth; ++import co.technove.flare.FlareBuilder; ++import co.technove.flare.exceptions.UserReportableException; ++import co.technove.flare.internal.profiling.ProfileType; ++import gg.pufferfish.pufferfish.PufferfishConfig; ++import gg.pufferfish.pufferfish.PufferfishLogger; ++import gg.pufferfish.pufferfish.compat.ServerConfigurations; ++import gg.pufferfish.pufferfish.flare.collectors.GCEventCollector; ++import gg.pufferfish.pufferfish.flare.collectors.StatCollector; ++import gg.pufferfish.pufferfish.flare.collectors.TPSCollector; ++import gg.pufferfish.pufferfish.flare.collectors.WorldCountCollector; ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; ++import org.bukkit.scheduler.BukkitTask; ++import oshi.SystemInfo; ++import oshi.hardware.CentralProcessor; ++import oshi.hardware.GlobalMemory; ++import oshi.hardware.HardwareAbstractionLayer; ++import oshi.hardware.VirtualMemory; ++import oshi.software.os.OperatingSystem; ++ ++import java.io.IOException; ++import java.net.URI; ++import java.time.Duration; ++import java.util.Objects; ++import java.util.logging.Level; ++ ++public class ProfilingManager { ++ ++ private static Flare currentFlare; ++ private static BukkitTask currentTask = null; ++ ++ public static synchronized boolean isProfiling() { ++ return currentFlare != null && currentFlare.isRunning(); ++ } ++ ++ public static synchronized String getProfilingUri() { ++ return Objects.requireNonNull(currentFlare).getURI().map(URI::toString).orElse("Flare is not running"); ++ } ++ ++ public static Duration getTimeRan() { ++ Flare flare = currentFlare; // copy reference so no need to sync ++ if (flare == null) { ++ return Duration.ofMillis(0); ++ } ++ return flare.getCurrentDuration(); ++ } ++ ++ public static synchronized boolean start(ProfileType profileType) throws UserReportableException { ++ if (currentFlare != null && !currentFlare.isRunning()) { ++ currentFlare = null; // errored out ++ } ++ if (isProfiling()) { ++ return false; ++ } ++ if (Bukkit.isPrimaryThread()) { ++ throw new UserReportableException("Profiles should be started off-thread"); ++ } ++ ++ try { ++ OperatingSystem os = new SystemInfo().getOperatingSystem(); ++ ++ SystemInfo systemInfo = new SystemInfo(); ++ HardwareAbstractionLayer hardware = systemInfo.getHardware(); ++ ++ CentralProcessor processor = hardware.getProcessor(); ++ CentralProcessor.ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier(); ++ ++ GlobalMemory memory = hardware.getMemory(); ++ VirtualMemory virtualMemory = memory.getVirtualMemory(); ++ ++ FlareBuilder builder = new FlareBuilder() ++ .withProfileType(profileType) ++ .withMemoryProfiling(true) ++ .withAuth(FlareAuth.fromTokenAndUrl(PufferfishConfig.accessToken, PufferfishConfig.profileWebUrl)) ++ ++ .withFiles(ServerConfigurations.getCleanCopies()) ++ .withVersion("Primary Version", Bukkit.getVersion()) ++ .withVersion("Bukkit Version", Bukkit.getBukkitVersion()) ++ .withVersion("Minecraft Version", Bukkit.getMinecraftVersion()) ++ ++ .withGraphCategories(CustomCategories.ENTITIES_AND_CHUNKS, CustomCategories.MC_PERF) ++ .withCollectors(new TPSCollector(), new WorldCountCollector(), new GCEventCollector(), new StatCollector()) ++ .withClassIdentifier(PluginLookup::getPluginForClass) ++ ++ .withHardware(new FlareBuilder.HardwareBuilder() ++ .setCoreCount(processor.getPhysicalProcessorCount()) ++ .setThreadCount(processor.getLogicalProcessorCount()) ++ .setCpuModel(processorIdentifier.getName()) ++ .setCpuFrequency(processor.getMaxFreq()) ++ ++ .setTotalMemory(memory.getTotal()) ++ .setTotalSwap(virtualMemory.getSwapTotal()) ++ .setTotalVirtual(virtualMemory.getVirtualMax()) ++ ) ++ ++ .withOperatingSystem(new FlareBuilder.OperatingSystemBuilder() ++ .setManufacturer(os.getManufacturer()) ++ .setFamily(os.getFamily()) ++ .setVersion(os.getVersionInfo().toString()) ++ .setBitness(os.getBitness()) ++ ); ++ ++ currentFlare = builder.build(); ++ } catch (IOException e) { ++ PufferfishLogger.LOGGER.log(Level.WARNING, "Failed to read configuration files:", e); ++ throw new UserReportableException("Failed to load configuration files, check logs for further details."); ++ } ++ ++ try { ++ currentFlare.start(); ++ } catch (IllegalStateException e) { ++ PufferfishLogger.LOGGER.log(Level.WARNING, "Error starting Flare:", e); ++ throw new UserReportableException("Failed to start Flare, check logs for further details."); ++ } ++ ++ currentTask = Bukkit.getScheduler().runTaskLater(new MinecraftInternalPlugin(), ProfilingManager::stop, 20 * 60 * 15); ++ PufferfishLogger.LOGGER.log(Level.INFO, "Flare has been started: " + getProfilingUri()); ++ return true; ++ } ++ ++ public static synchronized boolean stop() { ++ if (!isProfiling()) { ++ return false; ++ } ++ if (!currentFlare.isRunning()) { ++ currentFlare = null; ++ return true; ++ } ++ PufferfishLogger.LOGGER.log(Level.INFO, "Flare has been stopped: " + getProfilingUri()); ++ try { ++ currentFlare.stop(); ++ } catch (IllegalStateException e) { ++ PufferfishLogger.LOGGER.log(Level.WARNING, "Error occurred stopping Flare", e); ++ } ++ currentFlare = null; ++ ++ try { ++ currentTask.cancel(); ++ } catch (Throwable t) { ++ PufferfishLogger.LOGGER.log(Level.WARNING, "Error occurred stopping Flare", t); ++ } ++ ++ currentTask = null; ++ return true; ++ } ++ ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/GCEventCollector.java b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/GCEventCollector.java +new file mode 100644 +index 0000000000000000000000000000000000000000..d426575c669020f369960107da1e2de2f11f082f +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/GCEventCollector.java +@@ -0,0 +1,66 @@ ++package gg.pufferfish.pufferfish.flare.collectors; ++ ++import co.technove.flare.Flare; ++import co.technove.flare.internal.FlareInternal; ++import co.technove.flare.live.CollectorData; ++import co.technove.flare.live.EventCollector; ++import co.technove.flare.live.LiveEvent; ++import co.technove.flare.live.category.GraphCategory; ++import co.technove.flare.live.formatter.DataFormatter; ++import com.google.common.collect.ImmutableMap; ++import com.sun.management.GarbageCollectionNotificationInfo; ++ ++import javax.management.ListenerNotFoundException; ++import javax.management.Notification; ++import javax.management.NotificationEmitter; ++import javax.management.NotificationListener; ++import javax.management.openmbean.CompositeData; ++import java.lang.management.GarbageCollectorMXBean; ++import java.lang.management.ManagementFactory; ++ ++public class GCEventCollector extends EventCollector implements NotificationListener { ++ ++ private static final CollectorData MINOR_GC = new CollectorData("builtin:gc:minor", "Minor GC", "A small pause in the program to allow Garbage Collection to run.", DataFormatter.MILLISECONDS, GraphCategory.SYSTEM); ++ private static final CollectorData MAJOR_GC = new CollectorData("builtin:gc:major", "Major GC", "A large pause in the program to allow Garbage Collection to run.", DataFormatter.MILLISECONDS, GraphCategory.SYSTEM); ++ private static final CollectorData UNKNOWN_GC = new CollectorData("builtin:gc:generic", "Major GC", "A run of the Garbage Collection.", DataFormatter.MILLISECONDS, GraphCategory.SYSTEM); ++ ++ public GCEventCollector() { ++ super(MINOR_GC, MAJOR_GC, UNKNOWN_GC); ++ } ++ ++ private static CollectorData fromString(String string) { ++ if (string.endsWith("minor GC")) { ++ return MINOR_GC; ++ } else if (string.endsWith("major GC")) { ++ return MAJOR_GC; ++ } ++ return UNKNOWN_GC; ++ } ++ ++ @Override ++ public void start(Flare flare) { ++ for (GarbageCollectorMXBean garbageCollectorBean : ManagementFactory.getGarbageCollectorMXBeans()) { ++ NotificationEmitter notificationEmitter = (NotificationEmitter) garbageCollectorBean; ++ notificationEmitter.addNotificationListener(this, null, null); ++ } ++ } ++ ++ @Override ++ public void stop(Flare flare) { ++ for (GarbageCollectorMXBean garbageCollectorBean : ManagementFactory.getGarbageCollectorMXBeans()) { ++ NotificationEmitter notificationEmitter = (NotificationEmitter) garbageCollectorBean; ++ try { ++ notificationEmitter.removeNotificationListener(this); ++ } catch (ListenerNotFoundException e) { ++ } ++ } ++ } ++ ++ @Override ++ public void handleNotification(Notification notification, Object o) { ++ if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { ++ GarbageCollectionNotificationInfo gcInfo = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData()); ++ reportEvent(new LiveEvent(fromString(gcInfo.getGcAction()), System.currentTimeMillis(), (int) gcInfo.getGcInfo().getDuration(), ImmutableMap.of())); ++ } ++ } ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/StatCollector.java b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/StatCollector.java +new file mode 100644 +index 0000000000000000000000000000000000000000..a22c6dbae53667e4c72464fa27153aee30c7946e +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/StatCollector.java +@@ -0,0 +1,41 @@ ++package gg.pufferfish.pufferfish.flare.collectors; ++ ++import co.technove.flare.live.CollectorData; ++import co.technove.flare.live.LiveCollector; ++import co.technove.flare.live.category.GraphCategory; ++import co.technove.flare.live.formatter.DataFormatter; ++import com.sun.management.OperatingSystemMXBean; ++import oshi.SystemInfo; ++import oshi.hardware.CentralProcessor; ++ ++import java.lang.management.ManagementFactory; ++import java.time.Duration; ++ ++public class StatCollector extends LiveCollector { ++ ++ private static final CollectorData CPU = new CollectorData("builtin:stat:cpu", "CPU Load", "The total amount of CPU usage across all cores.", DataFormatter.PERCENT, GraphCategory.SYSTEM); ++ private static final CollectorData CPU_PROCESS = new CollectorData("builtin:stat:cpu_process", "Process CPU", "The amount of CPU being used by this process.", DataFormatter.PERCENT, GraphCategory.SYSTEM); ++ private static final CollectorData MEMORY = new CollectorData("builtin:stat:memory_used", "Memory", "The amount of memory being used currently.", DataFormatter.BYTES, GraphCategory.SYSTEM); ++ private static final CollectorData MEMORY_TOTAL = new CollectorData("builtin:stat:memory_total", "Memory Total", "The total amount of memory allocated.", DataFormatter.BYTES, GraphCategory.SYSTEM); ++ ++ private final OperatingSystemMXBean bean; ++ private final CentralProcessor processor; ++ ++ public StatCollector() { ++ super(CPU, CPU_PROCESS, MEMORY, MEMORY_TOTAL); ++ this.interval = Duration.ofSeconds(5); ++ ++ this.bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); ++ this.processor = new SystemInfo().getHardware().getProcessor(); ++ } ++ ++ @Override ++ public void run() { ++ Runtime runtime = Runtime.getRuntime(); ++ ++ this.report(CPU, this.processor.getSystemLoadAverage(1)[0] / 100); // percentage ++ this.report(CPU_PROCESS, this.bean.getProcessCpuLoad()); ++ this.report(MEMORY, runtime.totalMemory() - runtime.freeMemory()); ++ this.report(MEMORY_TOTAL, runtime.totalMemory()); ++ } ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java +new file mode 100644 +index 0000000000000000000000000000000000000000..40447d00aefb5ffedb8a2ee87155a04088f0649f +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java +@@ -0,0 +1,31 @@ ++package gg.pufferfish.pufferfish.flare.collectors; ++ ++import co.technove.flare.live.CollectorData; ++import co.technove.flare.live.LiveCollector; ++import co.technove.flare.live.formatter.SuffixFormatter; ++import gg.pufferfish.pufferfish.flare.CustomCategories; ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.Bukkit; ++ ++import java.time.Duration; ++import java.util.Arrays; ++ ++public class TPSCollector extends LiveCollector { ++ private static final CollectorData TPS = new CollectorData("airplane:tps", "TPS", "Ticks per second, or how fast the server updates. For a smooth server this should be a constant 20TPS.", SuffixFormatter.of("TPS"), CustomCategories.MC_PERF); ++ private static final CollectorData MSPT = new CollectorData("airplane:mspt", "MSPT", "Milliseconds per tick, which can show how well your server is performing. This value should always be under 50mspt.", SuffixFormatter.of("mspt"), CustomCategories.MC_PERF); ++ ++ public TPSCollector() { ++ super(TPS, MSPT); ++ ++ this.interval = Duration.ofSeconds(5); ++ } ++ ++ @Override ++ public void run() { ++ long[] times = MinecraftServer.getServer().tickTimes5s.getTimes(); ++ double mspt = ((double) Arrays.stream(times).sum() / (double) times.length) * 1.0E-6D; ++ ++ this.report(TPS, Math.min(20D, Math.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d)); ++ this.report(MSPT, (double) Math.round(mspt * 100d) / 100d); ++ } ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/WorldCountCollector.java b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/WorldCountCollector.java +new file mode 100644 +index 0000000000000000000000000000000000000000..029d840e28d67d26d3c0dd6785e25dbf15f9226c +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/WorldCountCollector.java +@@ -0,0 +1,45 @@ ++package gg.pufferfish.pufferfish.flare.collectors; ++ ++import co.technove.flare.live.CollectorData; ++import co.technove.flare.live.LiveCollector; ++import co.technove.flare.live.formatter.SuffixFormatter; ++import gg.pufferfish.pufferfish.flare.CustomCategories; ++import org.bukkit.Bukkit; ++import org.bukkit.World; ++ ++import java.time.Duration; ++ ++public class WorldCountCollector extends LiveCollector { ++ ++ private static final CollectorData PLAYER_COUNT = new CollectorData("airplane:world:playercount", "Player Count", "The number of players currently on the server.", new SuffixFormatter(" Player", " Players"), CustomCategories.ENTITIES_AND_CHUNKS); ++ private static final CollectorData ENTITY_COUNT = new CollectorData("airplane:world:entitycount", "Entity Count", "The number of entities in all worlds", new SuffixFormatter(" Entity", " Entities"), CustomCategories.ENTITIES_AND_CHUNKS); ++ private static final CollectorData CHUNK_COUNT = new CollectorData("airplane:world:chunkcount", "Chunk Count", "The number of chunks currently loaded.", new SuffixFormatter(" Chunk", " Chunks"), CustomCategories.ENTITIES_AND_CHUNKS); ++ private static final CollectorData TILE_ENTITY_COUNT = new CollectorData("airplane:world:blockentitycount", "Block Entity Count", "The number of block entities currently loaded.", new SuffixFormatter(" Block Entity", " Block Entities"), CustomCategories.ENTITIES_AND_CHUNKS); ++ ++ public WorldCountCollector() { ++ super(PLAYER_COUNT, ENTITY_COUNT, CHUNK_COUNT, TILE_ENTITY_COUNT); ++ ++ this.interval = Duration.ofSeconds(5); ++ } ++ ++ @Override ++ public void run() { ++ if (true) return; // This doesn't work, and it's not worth fixing at the moment. ++ int entities = 0; ++ int chunkCount = 0; ++ int tileEntityCount = 0; ++ ++ if (!Bukkit.isStopping()) { ++ for (World world : Bukkit.getWorlds()) { ++ world.getEntityCount(); ++ chunkCount += world.getChunkCount(); ++ tileEntityCount += world.getTileEntityCount(); ++ } ++ } ++ ++ this.report(PLAYER_COUNT, Bukkit.getOnlinePlayers().size()); ++ this.report(ENTITY_COUNT, entities); ++ this.report(CHUNK_COUNT, chunkCount); ++ this.report(TILE_ENTITY_COUNT, tileEntityCount); ++ } ++} diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java new file mode 100644 index 0000000000000000000000000000000000000000..731ef11c7a025ae95ed8a757b530d834733d0621 @@ -1455,11 +2047,54 @@ index 0000000000000000000000000000000000000000..facd55463d44cb7e3d2ca6892982f549 + return backingMap.size(); + } +} +diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +index 97a9ce438afc9094dca4a44cb25b37d5f88dcf43..c69892a5f31895b85e530beadd8864ac32470ba7 100644 +--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java ++++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +@@ -8,6 +8,7 @@ import net.kyori.adventure.text.Component; + import net.kyori.adventure.text.format.NamedTextColor; + import net.minecraft.network.protocol.Packet; + import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket; ++import org.bukkit.Bukkit; // Pufferfish + import org.checkerframework.checker.nullness.qual.Nullable; + import org.spongepowered.configurate.objectmapping.ConfigSerializable; + import org.spongepowered.configurate.objectmapping.meta.Comment; +@@ -17,6 +18,7 @@ import org.spongepowered.configurate.objectmapping.meta.Setting; + import java.util.List; + import java.util.Map; + import java.util.Objects; ++import java.util.logging.Level; // Pufferfish + + @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) + public class GlobalConfiguration extends ConfigurationPart { +@@ -91,6 +93,7 @@ public class GlobalConfiguration extends ConfigurationPart { + + public class Timings extends ConfigurationPart.Post { + public boolean enabled = true; ++ public boolean reallyEnabled = false; + public boolean verbose = true; + public String url = "https://timings.aikar.co/"; + public boolean serverNamePrivacy = false; +@@ -104,6 +107,14 @@ public class GlobalConfiguration extends ConfigurationPart { + + @Override + public void postProcess() { ++ // Pufferfish start ++ if (enabled && !reallyEnabled) { ++ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] To improve performance, timings have been disabled by default"); ++ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] You can still use timings by using /timings on, but they will not start on server startup unless you set timings.really-enabled to true in paper.yml"); ++ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] If you would like to disable this message, either set timings.really-enabled to true or timings.enabled to false."); ++ } ++ enabled = reallyEnabled; ++ // Pufferfish end + MinecraftTimings.processConfig(this); + } + } diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index c69088a2ec374b2d236fec61e267f42afa2967b1..5dffe28f93925d4c45c9b5c4f7565b00b1aa8dd2 100644 +index d02546b18cb689724887b4e85e8d32a18828a4ad..91eaff58bb422ba188e6cfaa9c20b45bec211edd 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -215,7 +215,7 @@ public final class MCUtil { +@@ -213,7 +213,7 @@ public final class MCUtil { } public static long getCoordinateKey(final Entity entity) { @@ -1468,20 +2103,31 @@ index c69088a2ec374b2d236fec61e267f42afa2967b1..5dffe28f93925d4c45c9b5c4f7565b00 } public static long getCoordinateKey(final ChunkPos pair) { +diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java +index ec268189b19b6fa5c4521f96ce211a531db35ec5..27a238cc56702297c88fde0f379178222ccf6c5b 100644 +--- a/src/main/java/net/minecraft/server/Main.java ++++ b/src/main/java/net/minecraft/server/Main.java +@@ -166,6 +166,7 @@ public class Main { + + // Spigot Start + boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ); ++ eulaAgreed = eulaAgreed || Boolean.getBoolean("Paper.isRunDev"); + if ( eulaAgreed ) + { + System.err.println( "You have used the Spigot command line EULA agreement flag." ); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 67ee3a4ca8a6cdeb275653d492a1fea8037c51fb..67cba5cf510e4a602121e10c015a491650127752 100644 +index 97745f0bab8d82d397c6c2a5775aed92bca0a034..87cacb46fb2b07482d3d608019d65a74b3854800 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -310,6 +310,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); -@@ -1692,7 +1694,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop needsChangeBroadcasting = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); +- public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets); ++ public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap = new gg.pufferfish.pufferfish.util.AsyncPlayerAreaMap(this.pooledLinkedPlayerHashSets); // Pufferfish + // Paper end - optimise chunk tick iteration + + public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, int viewDistance, boolean dsync) { +@@ -1330,8 +1330,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); } @@ -1561,7 +2208,7 @@ index fb6cbcc4839aef7dc4bd4a49613f892b07aab353..d60ae9f8d3afe3e996a66331ee510cfa Iterator iterator = this.entity.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -1609,6 +1629,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1343,6 +1363,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider i = j; } } @@ -1572,31 +2219,22 @@ index fb6cbcc4839aef7dc4bd4a49613f892b07aab353..d60ae9f8d3afe3e996a66331ee510cfa return this.scaledRange(i); } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index acbcdc8cb1523044b1657e03a141fae6389a3686..fe1a9c646b09d11e7fa2186afbeb70b680ad2b57 100644 +index 17b6925b46f8386dcfc561483693de516465ec12..390e5a4e9cead6f217de7689a47b8c3b4b042990 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -76,6 +76,9 @@ public class ServerChunkCache extends ChunkSource { +@@ -75,6 +75,8 @@ public class ServerChunkCache extends ChunkSource { final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f); private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4]; -+ + public boolean firstRunSpawnCounts = true; // Pufferfish + public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs private static int getChunkCacheKey(int x, int z) { return x & 3 | ((z & 3) << 2); -@@ -553,6 +556,7 @@ public class ServerChunkCache extends ChunkSource { - ProfilerFiller gameprofilerfiller = this.level.getProfiler(); - - gameprofilerfiller.push("pollingChunks"); -+ this.level.resetIceAndSnowTick(); // Pufferfish - reset ice & snow tick random - int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - -@@ -562,28 +566,35 @@ public class ServerChunkCache extends ChunkSource { +@@ -530,28 +532,35 @@ public class ServerChunkCache extends ChunkSource { // Paper start - per player mob spawning NaturalSpawner.SpawnState spawnercreature_d; // moved down - if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't count mobs when animals and monsters are disabled + if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled - // re-set mob counts - for (ServerPlayer player : this.level.players) { - // Paper start - per player mob spawning backoff @@ -1629,9 +2267,9 @@ index acbcdc8cb1523044b1657e03a141fae6389a3686..fe1a9c646b09d11e7fa2186afbeb70b6 - spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true); + // Pufferfish end } else { -- spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, this.chunkMap.playerMobDistanceMap == null ? new LocalMobCapCalculator(this.chunkMap) : null, false); +- spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); + // Pufferfish start - this is only implemented for per-player mob spawning so this makes everything work if this setting is disabled. -+ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, this.chunkMap.playerMobDistanceMap == null ? new LocalMobCapCalculator(this.chunkMap) : null, false); ++ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); + _pufferfish_spawnCountsReady.set(true); + // Pufferfish end } @@ -1641,24 +2279,24 @@ index acbcdc8cb1523044b1657e03a141fae6389a3686..fe1a9c646b09d11e7fa2186afbeb70b6 - this.lastSpawnState = spawnercreature_d; + //this.lastSpawnState = spawnercreature_d; // Pufferfish - this is managed asynchronously gameprofilerfiller.popPush("filteringLoadedChunks"); - // Paper - moved down - this.level.timings.chunkTicks.startTiming(); // Paper -@@ -622,8 +633,8 @@ public class ServerChunkCache extends ChunkSource { - - if ((true || this.level.isNaturalSpawningAllowed(chunkcoordintpair)) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, false)) { // Paper - optimise anyPlayerCloseEnoughForSpawning // Paper - the chunk is known ticking + // Paper - optimise chunk tick iteration + // Paper - optimise chunk tick iteration +@@ -644,8 +653,8 @@ public class ServerChunkCache extends ChunkSource { + // Paper end - optimise chunk tick iteration + if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { // Paper - optimise chunk tick iteration chunk1.incrementInhabitedTime(j); -- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration +- if (spawn && flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration - NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); -+ if (flag2 && (!gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning || _pufferfish_spawnCountsReady.get()) && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration ++ if (spawn && flag2 && (!gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning || _pufferfish_spawnCountsReady.get()) && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration // Pufferfish + NaturalSpawner.spawnForChunk(this.level, chunk1, lastSpawnState, this.spawnFriendlies, this.spawnEnemies, flag1); // Pufferfish } - if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - the chunk is known ticking -@@ -685,6 +696,40 @@ public class ServerChunkCache extends ChunkSource { - } - // Paper end - controlled flush for entity tracker packets + if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration +@@ -691,6 +700,40 @@ public class ServerChunkCache extends ChunkSource { + gameprofilerfiller.pop(); + this.chunkMap.tick(); } -+ ++ + // Pufferfish start - optimize mob spawning + if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) { + for (ServerPlayer player : this.level.players) { @@ -1678,7 +2316,7 @@ index acbcdc8cb1523044b1657e03a141fae6389a3686..fe1a9c646b09d11e7fa2186afbeb70b6 + firstRunSpawnCounts = false; + _pufferfish_spawnCountsReady.set(true); + } -+ if (chunkMap.playerMobDistanceMap != null && _pufferfish_spawnCountsReady.getAndSet(false)) { ++ if (chunkMap.playerMobSpawnMap != null && _pufferfish_spawnCountsReady.getAndSet(false)) { + net.minecraft.server.MinecraftServer.getServer().mobSpawnExecutor.submit(() -> { + int mapped = distanceManager.getNaturalSpawnChunkCount(); + io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator objectiterator = @@ -1696,10 +2334,10 @@ index acbcdc8cb1523044b1657e03a141fae6389a3686..fe1a9c646b09d11e7fa2186afbeb70b6 private void getFullChunk(long pos, Consumer chunkConsumer) { diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 196280f54e397c69d32bd4d1f6ae666efdd93773..8ab959dd588b5154b63e133b2e937fa2d0ab8e52 100644 +index 892a334d1b1c0784ed6838d1aa066403998b9a9f..b7f2bf1fbc0217e2968805521c108cb27c178dad 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -180,7 +180,8 @@ public class ServerEntity { +@@ -177,7 +177,8 @@ public class ServerEntity { long i1 = this.positionCodec.encodeZ(vec3d); boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; @@ -1709,7 +2347,7 @@ index 196280f54e397c69d32bd4d1f6ae666efdd93773..8ab959dd588b5154b63e133b2e937fa2 if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) { if (flag2) { packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround()); -@@ -194,6 +195,7 @@ public class ServerEntity { +@@ -191,6 +192,7 @@ public class ServerEntity { flag4 = true; flag5 = true; } @@ -1718,10 +2356,10 @@ index 196280f54e397c69d32bd4d1f6ae666efdd93773..8ab959dd588b5154b63e133b2e937fa2 this.wasOnGround = this.entity.onGround(); this.teleportDelay = 0; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 18aac3da3c88f33b1a71a5920a8daa27e9723913..eac31c3fcc9161711328588ac852fcae1116d8ef 100644 +index 868951dc21aff541765b1f58f08cdf3c47446d25..48402dc3008d1d1d513f0486c0a120719a9fd441 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -850,6 +850,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -878,6 +878,7 @@ public class ServerLevel extends Level implements WorldGenLevel { org.spigotmc.ActivationRange.activateEntities(this); // Spigot timings.entityTick.startTiming(); // Spigot this.entityTickList.forEach((entity) -> { @@ -1729,7 +2367,7 @@ index 18aac3da3c88f33b1a71a5920a8daa27e9723913..eac31c3fcc9161711328588ac852fcae if (!entity.isRemoved()) { if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed entity.discard(); -@@ -869,7 +870,20 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -897,7 +898,20 @@ public class ServerLevel extends Level implements WorldGenLevel { } gameprofilerfiller.push("tick"); @@ -1751,42 +2389,19 @@ index 18aac3da3c88f33b1a71a5920a8daa27e9723913..eac31c3fcc9161711328588ac852fcae gameprofilerfiller.pop(); } } -@@ -934,9 +948,11 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - // Paper start - optimise random block ticking +@@ -964,6 +978,7 @@ public class ServerLevel extends Level implements WorldGenLevel { private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos(); -- private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); -+ // private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(); // Pufferfish - moved to super + private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Paper end ++ public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish -+ private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Pufferfish -+ public void tickChunk(LevelChunk chunk, int randomTickSpeed) { ChunkPos chunkcoordintpair = chunk.getPos(); - boolean flag = this.isRaining(); -@@ -947,7 +963,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - gameprofilerfiller.push("thunder"); - final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - -- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder -+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Pufferfish - replace random with shouldDoLightning - blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper - if (this.isRainingAt(blockposition)) { - DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition); -@@ -978,7 +994,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - int l; - int i1; - -- if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow -+ if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking // Pufferfish - optimize further random ticking - // Paper start - optimise chunk ticking - this.getRandomBlockPosition(j, 0, k, 15, blockposition); - int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition.getX() & 15, blockposition.getZ() & 15) + 1; diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ab58827001b3b42e44d7f701c390480fed1fa1f1..6cafc20ce006872bedd28a34db11204c3c1fef58 100644 +index 8bd243a8d5a4be54f907af2b02e96ea833cee62f..501cb7450cd28ca487c1522ada4a571e74d3258c 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1233,6 +1233,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1118,6 +1118,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -1794,7 +2409,7 @@ index ab58827001b3b42e44d7f701c390480fed1fa1f1..6cafc20ce006872bedd28a34db11204c // Paper start if (!this.cserver.isPrimaryThread()) { List pageList = packet.getPages(); -@@ -2420,6 +2421,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2273,6 +2274,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } private boolean updateChatOrder(Instant timestamp) { @@ -1803,134 +2418,22 @@ index ab58827001b3b42e44d7f701c390480fed1fa1f1..6cafc20ce006872bedd28a34db11204c do { diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 2ff578e4a953ffcf5176815ba8e3f06f73499989..878001928327d92423d5f7f6d5ce8772d6fa477f 100644 +index ff2dd53e9e943aa929188fd9d4c35498b78c497a..0c57a06b785dc024ee05ac1291a56f08624e1e56 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -204,6 +204,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -126,6 +126,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void onDisconnect(Component reason) { -+ if (gg.pufferfish.pufferfish.PufferfishConfig.suppressNullIdDisconnections && this.gameProfile != null && this.gameProfile.getId() == null && "Disconnected".equals(reason.getString())) return; // Pufferfish ++ if (gg.pufferfish.pufferfish.PufferfishConfig.suppressNullIdDisconnections && this.authenticatedProfile != null && this.authenticatedProfile.getId() == null && "Disconnected".equals(reason.getString())) return; // Pufferfish ServerLoginPacketListenerImpl.LOGGER.info("{} lost connection: {}", this.getUserName(), reason.getString()); } -diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java -index 241fec02e6869c638d3a160819b32173a081467b..6a8f9e8f5bf108674c47018def28906e2d0a729c 100644 ---- a/src/main/java/net/minecraft/world/CompoundContainer.java -+++ b/src/main/java/net/minecraft/world/CompoundContainer.java -@@ -1,5 +1,6 @@ - package net.minecraft.world; - -+import net.minecraft.core.Direction; // Pufferfish - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; - -@@ -64,6 +65,23 @@ public class CompoundContainer implements Container { - this.container2 = second; - } - -+ // Pufferfish start -+ @Override -+ public boolean hasEmptySlot(Direction enumdirection) { -+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null); -+ } -+ -+ @Override -+ public boolean isCompletelyFull(Direction enumdirection) { -+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null); -+ } -+ -+ @Override -+ public boolean isCompletelyEmpty(Direction enumdirection) { -+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null); -+ } -+ // Pufferfish end -+ - @Override - public int getContainerSize() { - return this.container1.getContainerSize() + this.container2.getContainerSize(); -diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java -index aee02acd4b2f2fdcb574c37c077fb57013ccb596..5a1c2d62c0e55c5bf16ca3e208dc486bf3b064b2 100644 ---- a/src/main/java/net/minecraft/world/Container.java -+++ b/src/main/java/net/minecraft/world/Container.java -@@ -3,6 +3,8 @@ package net.minecraft.world; - import java.util.Set; - import java.util.function.Predicate; - import net.minecraft.core.BlockPos; -+ -+import net.minecraft.core.Direction; // Pufferfish - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.Item; - import net.minecraft.world.item.ItemStack; -@@ -13,6 +15,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity; - // CraftBukkit end - - public interface Container extends Clearable { -+ // Pufferfish start - allow the inventory to override and optimize these frequent calls -+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable Direction enumdirection) { // there is a slot with 0 items in it -+ if (this instanceof WorldlyContainer worldlyContainer) { -+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) { -+ if (this.getItem(i).isEmpty()) { -+ return true; -+ } -+ } -+ } else { -+ int size = this.getContainerSize(); -+ for (int i = 0; i < size; i++) { -+ if (this.getItem(i).isEmpty()) { -+ return true; -+ } -+ } -+ } -+ return false; -+ } -+ -+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable Direction enumdirection) { // every stack is maxed -+ if (this instanceof WorldlyContainer worldlyContainer) { -+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) { -+ ItemStack itemStack = this.getItem(i); -+ if (itemStack.getCount() < itemStack.getMaxStackSize()) { -+ return false; -+ } -+ } -+ } else { -+ int size = this.getContainerSize(); -+ for (int i = 0; i < size; i++) { -+ ItemStack itemStack = this.getItem(i); -+ if (itemStack.getCount() < itemStack.getMaxStackSize()) { -+ return false; -+ } -+ } -+ } -+ return true; -+ } -+ -+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable Direction enumdirection) { -+ if (this instanceof WorldlyContainer worldlyContainer) { -+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) { -+ if (!this.getItem(i).isEmpty()) { -+ return false; -+ } -+ } -+ } else { -+ int size = this.getContainerSize(); -+ for (int i = 0; i < size; i++) { -+ if (!this.getItem(i).isEmpty()) { -+ return false; -+ } -+ } -+ } -+ return true; -+ } -+ // Pufferfish end - - int LARGE_MAX_STACK_SIZE = 64; - int DEFAULT_DISTANCE_LIMIT = 8; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391ae13c64e4 100644 +index f20ae9153b7098980ce6c0e75fcbbb4da652661b..b2b1e34af626fad2586dcc12596c761560d2dfad 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -306,7 +306,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -305,7 +305,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public double yo; public double zo; private Vec3 position; @@ -1939,7 +2442,7 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a private ChunkPos chunkPosition; private Vec3 deltaMovement; private float yRot; -@@ -434,6 +434,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -433,6 +433,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.originWorld; } // Paper end @@ -1948,59 +2451,10 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a + public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // golf score + public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // used where needed + // Pufferfish end -+ public float getBukkitYaw() { return this.yRot; } -@@ -508,17 +514,36 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - this.isLegacyTrackingEntity = isLegacyTrackingEntity; - } - -+ private org.spigotmc.TrackingRange.TrackingRangeType getFurthestEntity(Entity entity, net.minecraft.server.level.ChunkMap chunkMap, org.spigotmc.TrackingRange.TrackingRangeType type, int range) { -+ List passengers = entity.getPassengers(); -+ for (int i = 0, size = passengers.size(); i < size; i++) { -+ Entity passenger = passengers.get(i); -+ org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType; -+ int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal()); -+ if (passengerRange > range) { -+ type = passengerType; -+ range = passengerRange; -+ } -+ -+ type = this.getFurthestEntity(passenger, chunkMap, type, range); -+ } -+ -+ return type; -+ } -+ - public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getPlayersInTrackRange() { - // determine highest range of passengers - if (this.passengers.isEmpty()) { - return ((ServerLevel)this.level).getChunkSource().chunkMap.playerEntityTrackerTrackMaps[this.trackingRangeType.ordinal()] - .getObjectsInRange(MCUtil.getCoordinateKey(this)); - } -- Iterable passengers = this.getIndirectPassengers(); -+ //Iterable passengers = this.getIndirectPassengers(); // Pufferfish - net.minecraft.server.level.ChunkMap chunkMap = ((ServerLevel)this.level).getChunkSource().chunkMap; - org.spigotmc.TrackingRange.TrackingRangeType type = this.trackingRangeType; - int range = chunkMap.getEntityTrackerRange(type.ordinal()); - -+ // Pufferfish start - use getFurthestEntity to skip getIndirectPassengers -+ /* - for (Entity passenger : passengers) { - org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType; - int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal()); -@@ -527,6 +552,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - range = passengerRange; - } - } -+ */ -+ type = this.getFurthestEntity(this, chunkMap, type, range); -+ // Pufferfish end - - return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this)); - } -@@ -798,6 +826,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -765,6 +770,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void tick() { @@ -2013,7 +2467,7 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a this.baseTick(); } -@@ -4283,16 +4317,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4324,16 +4335,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -2039,7 +2493,7 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a double d1 = 0.0D; boolean flag = this.isPushedByFluid(); boolean flag1 = false; -@@ -4300,14 +4336,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4341,14 +4354,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); @@ -2107,7 +2561,7 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a if (d2 >= axisalignedbb.minY) { flag1 = true; -@@ -4329,9 +4412,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4370,9 +4430,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit end } } @@ -2121,10 +2575,10 @@ index e8485fb900b25e911a858678a833852731cb2ace..36795968f4c296f680f79cc5a795391a if (vec3d.length() > 0.0D) { if (k1 > 0) { diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..aa5cec6d56d7a8e80861aa4c9b4a74ca3e64be8c 100644 +index 73871f456a85bda1e51f54986d0e61fb629822e8..2561e74ffdf595a9b6ae13dcd738662c772db442 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -300,6 +300,8 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -301,6 +301,8 @@ public class EntityType implements FeatureElement, EntityTypeT private final boolean canSpawnFarFromPlayer; private final int clientTrackingRange; private final int updateInterval; @@ -2134,7 +2588,7 @@ index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..aa5cec6d56d7a8e80861aa4c9b4a74ca private String descriptionId; @Nullable diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 78c98f38bc263664ea4cd344670243a7d372885c..d265a32bd273beed0e65e224e1c5f9c0bca7b3fb 100644 +index c039c77d0dd6ec1d336948ca6b5351d6fae1d8bb..6806aadd18696832a8d6ada3db0cee89047acb60 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -142,7 +142,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; @@ -2154,7 +2608,7 @@ index 78c98f38bc263664ea4cd344670243a7d372885c..d265a32bd273beed0e65e224e1c5f9c0 this.hurt(this.damageSources().inWall(), 1.0F); } else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) { double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); -@@ -1369,6 +1368,19 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1401,6 +1400,19 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.getHealth() <= 0.0F; } @@ -2174,7 +2628,7 @@ index 78c98f38bc263664ea4cd344670243a7d372885c..d265a32bd273beed0e65e224e1c5f9c0 @Override public boolean hurt(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { -@@ -1965,6 +1977,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1999,6 +2011,20 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -2196,10 +2650,10 @@ index 78c98f38bc263664ea4cd344670243a7d372885c..d265a32bd273beed0e65e224e1c5f9c0 if (this.isSpectator()) { return false; diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index a99d737f71277ea3082816c7a7fc47ab3a201d30..7e453b4c49975bb06cb080f3626545286b947ddc 100644 +index d28c477171c1b6888a45175075017d960464b5cd..4cb836dfa7cbd2e634d4a3a567da0305aac0da4d 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -218,14 +218,16 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -220,14 +220,16 @@ public abstract class Mob extends LivingEntity implements Targeting { return this.lookControl; } @@ -2218,7 +2672,7 @@ index a99d737f71277ea3082816c7a7fc47ab3a201d30..7e453b4c49975bb06cb080f362654528 this.targetSelector.tick(); } } -@@ -910,16 +912,20 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -913,16 +915,20 @@ public abstract class Mob extends LivingEntity implements Targeting { if (i % 2 != 0 && this.tickCount > 1) { this.level().getProfiler().push("targetSelector"); @@ -2240,32 +2694,29 @@ index a99d737f71277ea3082816c7a7fc47ab3a201d30..7e453b4c49975bb06cb080f362654528 this.level().getProfiler().pop(); } diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index dd1102d5291ef6f18e82400a6d8a0a376cc071e9..e283eb57c25f7de222f9d09dca851169f5f6e488 100644 +index 7204b973c3ad9239e82355513f6d538107102e48..d8bb16f74fdd8d5a50bd384249e0eac9640cd498 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -23,9 +23,11 @@ public class AttributeMap { private final Map attributes = Maps.newHashMap(); private final Set dirtyAttributes = Sets.newHashSet(); private final AttributeSupplier supplier; -+ private final java.util.function.Function createInstance; // Pufferfish ++ private final java.util.function.Function createdInstance; // Pufferfish public AttributeMap(AttributeSupplier defaultAttributes) { this.supplier = defaultAttributes; -+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish ++ this.createdInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish } private void onAttributeModified(AttributeInstance instance) { -@@ -45,11 +47,10 @@ public class AttributeMap { - }).collect(Collectors.toList()); - } +@@ -47,9 +49,7 @@ public class AttributeMap { -+ @Nullable public AttributeInstance getInstance(Attribute attribute) { - return this.attributes.computeIfAbsent(attribute, (attributex) -> { - return this.supplier.createInstance(this::onAttributeModified, attributex); - }); -+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyways ++ return this.attributes.computeIfAbsent(attribute, this.createdInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyway } @Nullable @@ -2318,7 +2769,7 @@ index 34f319ad09276c6f68dde449c79351de0d7d86f5..a719af0b512d9ef243d0d54f3b744b1b this.blockPos = mutableBlockPos; setTargetPosition(mutableBlockPos.immutable()); // Paper diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index 58422f00c7d64dbd1cf6d7211c9838875cbe7778..d25307ae8bbdf10ae067ec70fc2cb957b852a0eb 100644 +index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152cac963b8 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -75,9 +75,18 @@ public class TargetingConditions { @@ -2371,10 +2822,10 @@ index 5beaa849a250ea005733250ad3edfa8382224667..2c91fe46355c9a201507de5577f693ed @Override protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) { diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 339c70f101d026a100a801e66cf514b3329a89d2..1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a 100644 +index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cfac7f6e54 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -222,9 +222,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -221,9 +221,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS return 0.4F; } @@ -2387,10 +2838,10 @@ index 339c70f101d026a100a801e66cf514b3329a89d2..1a0eee3b766a5ce5623c32ed9c023a0f this.level().getProfiler().pop(); this.level().getProfiler().push("allayActivityUpdate"); diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 2682a49cd3948e0f80e2d7e58abcd3e6d8f7ac4e..42e22a4b9cb6841de04862cc81454da3232aa65a 100644 +index aa850cfaa0534d57e83f37360724da2428a48a18..eb1e850f11ed1cd8d2f1f2eb1af55b7fe6352ed4 100644 --- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -285,9 +285,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder { +@@ -164,9 +164,11 @@ public class Frog extends Animal implements VariantHolder { return true; } @@ -2435,10 +2886,10 @@ index 4aeab90e778629c355189dfe79c39c4b21f5f5ac..6ed4ac06c76b8d0d6e8db778cade15db this.level().getProfiler().pop(); this.level().getProfiler().push("tadpoleActivityUpdate"); diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -index 247aca0b612f5079a0596350e8311c385df8ab1c..7f21d1d400c8a5615ed1a787dcb0680338f8c28d 100644 +index 111a244087e24f25ba8524a46a228da10cd9498a..ff12ba2b79cb2e7e0bfd0e3b58ff6cb9e770092b 100644 --- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java +++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -@@ -189,9 +189,11 @@ public class Goat extends Animal { +@@ -191,9 +191,11 @@ public class Goat extends Animal { return (Brain) super.getBrain(); // CraftBukkit - decompile error } @@ -2469,10 +2920,10 @@ index 1e07febcf7a3dfb281728cc5e3e4f15dd776d7e0..c65ab566c6241dd6a44bd11a449ef0c4 protected SoundEvent getAmbientSound() { return SoundEvents.WITHER_AMBIENT; 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 b62457313a1e30aad0c5313d608667b5d3811455..410f10ad93935d1c078447a4596023f367a8e9b7 100644 +index b0a97679157a18a3c623ce3b2ae315789772c254..9fc3db543a0c9df502df5fb85012c6aa590e887d 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -326,11 +326,17 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -333,11 +333,17 @@ public class EnderMan extends Monster implements NeutralMob { private boolean teleport(double x, double y, double z) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z); @@ -2493,10 +2944,10 @@ index b62457313a1e30aad0c5313d608667b5d3811455..410f10ad93935d1c078447a4596023f3 boolean flag1 = iblockdata.getFluidState().is(FluidTags.WATER); diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -index e8f6c34ea789136d63c0aa88aec90203ef6282b5..d6d61b91096d28eea1e5af69ea1c07890820ee7f 100644 +index 4257f2282152aee09533c9a2e53018d3e49effa4..e703320717ff620a19ff76d1c10066117c9895d5 100644 --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -126,9 +126,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { +@@ -128,9 +128,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { return (Brain) super.getBrain(); // Paper - decompile fix } @@ -2509,10 +2960,10 @@ index e8f6c34ea789136d63c0aa88aec90203ef6282b5..d6d61b91096d28eea1e5af69ea1c0789 this.level().getProfiler().pop(); HoglinAi.updateActivity(this); diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -index 27d9145693a772cd1b5d171da303c934101f3be8..e235cc9d1b3ce59ab662ef3cf3ce0267ca78536d 100644 +index 6407ddef8442fce4f310ac4babf3e3de0dd5fc9a..cfdc1650783d6855e0d4f33ec68aab48dbee09f0 100644 --- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -305,9 +305,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -300,9 +300,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento return !this.cannotHunt; } @@ -2525,10 +2976,10 @@ index 27d9145693a772cd1b5d171da303c934101f3be8..e235cc9d1b3ce59ab662ef3cf3ce0267 this.level().getProfiler().pop(); PiglinAi.updateActivity(this); diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 97b763431bc5015448ee7a26a340635a932c950b..71db8bd6885377d55cfc571fccc21df6d8a57b54 100644 +index b2bc3a832c310448046ccde37a04918aa6d63197..5e43912708f9074dee1bb351efa737a7e6796fc3 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -271,11 +271,13 @@ public class Warden extends Monster implements VibrationSystem { +@@ -272,11 +272,13 @@ public class Warden extends Monster implements VibrationSystem { } @@ -2543,19 +2994,18 @@ index 97b763431bc5015448ee7a26a340635a932c950b..71db8bd6885377d55cfc571fccc21df6 this.level().getProfiler().pop(); super.customServerAiStep(); diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index e30d5ae3e2900f43d7cafde71b8196f26e872841..c4ddf2661bca728d504918171295e10e307b18b4 100644 +index f555e29c7f9ea4ddb243a018bdc93d2bf1950c3c..1bc082a1fad26e38a8606b633bf3789b5e4d6046 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -141,6 +141,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -141,6 +141,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> { return holder.is(PoiTypes.MEETING); }); - + public long nextGolemPanic = -1; // Pufferfish -+ + public Villager(EntityType entityType, Level world) { this(entityType, world, VillagerType.PLAINS); - } -@@ -244,6 +246,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -245,6 +246,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } // Spigot End @@ -2563,7 +3013,7 @@ index e30d5ae3e2900f43d7cafde71b8196f26e872841..c4ddf2661bca728d504918171295e10e @Override @Deprecated // Paper protected void customServerAiStep() { -@@ -253,7 +256,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -254,7 +256,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler protected void customServerAiStep(final boolean inactive) { // Paper end this.level().getProfiler().push("villagerBrain"); @@ -2649,53 +3099,6 @@ index a90317100d32974e481e14476843f66997a2cf3a..cd0629581bae5f805842157af36c2d83 public void setOwner(@Nullable Entity entity) { if (entity != null) { this.ownerUUID = entity.getUUID(); -diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index 272095d7a09ab41227d741172735f66fd2798ce1..47692d6db44b58bb724c87128279bd0d3e62a398 100644 ---- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -27,7 +27,10 @@ import org.bukkit.inventory.InventoryHolder; - - public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { - -+ // Pufferfish start - private NonNullList itemStacks; -+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized; -+ // Pufferfish end - @Nullable - public ResourceLocation lootTable; - public long lootTableSeed; -@@ -89,12 +92,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme - - protected AbstractMinecartContainer(EntityType type, Level world) { - super(type, world); -- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 -+ // Pufferfish start -+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513 -+ this.itemStacks = this.itemStacksOptimized.nonNullList; -+ // Pufferfish end - } - - protected AbstractMinecartContainer(EntityType type, double x, double y, double z, Level world) { - super(type, world, x, y, z); -- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 -+ // Pufferfish start -+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513 -+ this.itemStacks = this.itemStacksOptimized.nonNullList; -+ // Pufferfish end - } - - @Override -@@ -156,6 +165,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme - protected void readAdditionalSaveData(CompoundTag nbt) { - super.readAdditionalSaveData(nbt); - this.lootableData.loadNbt(nbt); // Paper -+ // Pufferfish start -+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); -+ this.itemStacks = this.itemStacksOptimized.nonNullList; -+ // Pufferfish end - this.readChestVehicleSaveData(nbt); - } - diff --git a/src/main/java/net/minecraft/world/item/EndCrystalItem.java b/src/main/java/net/minecraft/world/item/EndCrystalItem.java index 5a19875cbc603acea95193d969d2e1dc1e0bfd78..3688e9f8c6c6d1239095e3a87060ccca90386d0c 100644 --- a/src/main/java/net/minecraft/world/item/EndCrystalItem.java @@ -2710,24 +3113,26 @@ index 5a19875cbc603acea95193d969d2e1dc1e0bfd78..3688e9f8c6c6d1239095e3a87060ccca } } diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -index 2e60bdc44c33d434bfd9ca5bf8f75de799c6768c..565318c2afaa1661ed9963453a6354dff499f47a 100644 +index 38f7d1ece27ec1a3deda21fb6a6f0e788c8ed718..cf8795e3e91a6ef0dc8c37f17b16480fb4845bff 100644 --- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -27,8 +27,13 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo +@@ -26,8 +26,15 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo final CraftingBookCategory category; final ItemStack result; final NonNullList ingredients; + private final boolean isBukkit; // Pufferfish -+ // Pufferfish start - public ShapelessRecipe(ResourceLocation id, String group, CraftingBookCategory category, ItemStack output, NonNullList input) { -+ this(id, group, category, output, input, false); + public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients) { ++ // Pufferfish start ++ this(group, category, result, ingredients, false); + } -+ public ShapelessRecipe(ResourceLocation id, String group, CraftingBookCategory category, ItemStack output, NonNullList input, boolean isBukkit) { this.isBukkit = isBukkit; // Pufferfish end - this.id = id; ++ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients, boolean isBukkit) { ++ this.isBukkit = isBukkit; ++ // Pufferfish end this.group = group; this.category = category; -@@ -83,6 +88,28 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo + this.result = result; +@@ -77,6 +84,28 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo } public boolean matches(CraftingContainer inventory, Level world) { @@ -2752,47 +3157,15 @@ index 2e60bdc44c33d434bfd9ca5bf8f75de799c6768c..565318c2afaa1661ed9963453a6354df + return ingredients.isEmpty(); + } + // Pufferfish end -+ ++ StackedContents autorecipestackmanager = new StackedContents(); autorecipestackmanager.initialize(this); // Paper - better exact choice recipes int i = 0; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 7d54c79f46f99f5500e9cb1f486037cafb27ee3a..21c11ff8d5ae9bf97dfcf3118cabe678deb4c064 100644 +index ea8a0961190e9aafda4fed6fecd85097c141040a..4b49df79d366e58e1cee245e1aaefbb95f4fdfc0 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -273,6 +273,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - public abstract ResourceKey getTypeKey(); - -+ protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter -+ -+ // Pufferfish start - ensure these get inlined -+ private final int minBuildHeight, minSection, height, maxBuildHeight, maxSection; -+ @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; } -+ @Override public final int getMinSection() { return this.minSection; } -+ @Override public final int getMaxSection() { return this.maxSection; } -+ @Override public final int getMinBuildHeight() { return this.minBuildHeight; } -+ @Override public final int getHeight() { return this.height; } -+ // Pufferfish end -+ - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper -@@ -295,6 +306,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - }); - final DimensionType dimensionmanager = (DimensionType) holder.value(); - -+ // Pufferfish start -+ this.minBuildHeight = dimensionmanager.minY(); -+ this.minSection = SectionPos.blockToSectionCoord(this.minBuildHeight); -+ this.height = dimensionmanager.height(); -+ this.maxBuildHeight = this.minBuildHeight + this.height; -+ this.maxSection = SectionPos.blockToSectionCoord(this.maxBuildHeight - 1) + 1; -+ // Pufferfish end - this.dimension = resourcekey; - this.isClientSide = flag; - if (dimensionmanager.coordinateScale() != 1.0D) { -@@ -1003,13 +1021,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1308,13 +1308,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { try { tickConsumer.accept(entity); MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick @@ -2808,7 +3181,7 @@ index 7d54c79f46f99f5500e9cb1f486037cafb27ee3a..21c11ff8d5ae9bf97dfcf3118cabe678 // Paper end } } -@@ -1464,6 +1482,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1779,6 +1779,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public ProfilerFiller getProfiler() { @@ -2817,20 +3190,20 @@ index 7d54c79f46f99f5500e9cb1f486037cafb27ee3a..21c11ff8d5ae9bf97dfcf3118cabe678 } diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index e85ddf92b4f6f044e2b5834a172f37d78e702ef3..49de1fca183b2c6a0a5399025abfc0e47f314315 100644 +index 3cdddda9c0618e95288b81b975d499c8dd30c05f..27b75fba1b8052a715979f48b28bba0e4be16274 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -431,12 +431,12 @@ public final class NaturalSpawner { +@@ -429,12 +429,12 @@ public final class NaturalSpawner { } } - private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) { -+ private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Pufferfish - accept serverlevel ++ private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Pufferfish - accept serverLevel ChunkPos chunkcoordintpair = chunk.getPos(); - int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16); - int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16); -+ int i = chunkcoordintpair.getMinBlockX() + world.getThreadUnsafeRandom().nextInt(16); // Pufferfish - use thread unsafe random -+ int j = chunkcoordintpair.getMinBlockZ() + world.getThreadUnsafeRandom().nextInt(16); // Pufferfish ++ int i = chunkcoordintpair.getMinBlockX() + world.getThreadUnsafeRandom().nextInt(16); // Pufferfish - use thread unsafe random ++ int j = chunkcoordintpair.getMinBlockZ() + world.getThreadUnsafeRandom().nextInt(16); // Pufferfish int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1; - int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k); + int l = Mth.randomBetweenInclusive(world.getThreadUnsafeRandom(), world.getMinBuildHeight(), k); // Pufferfish @@ -2886,242 +3259,8 @@ index 65012a12e1430956ef55ced56773e6354ac26444..ed439b7e94646141c93a7dd3704d1cde return g; } } -diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f3040b26a 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity; - public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity { - - private static final int EVENT_SET_OPEN_COUNT = 1; -+ // Pufferfish start - private NonNullList items; -+ private gg.airplane.structs.ItemListWithBitset optimizedItems; -+ // Pufferfish end - public final ContainerOpenersCounter openersCounter; - private final ChestLidController chestLidController; - -@@ -65,9 +68,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement - } - // CraftBukkit end - -+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Pufferfish - protected ChestBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { - super(type, pos, state); -- this.items = NonNullList.withSize(27, ItemStack.EMPTY); -+ // Pufferfish start -+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(27); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - this.openersCounter = new ContainerOpenersCounter() { - @Override - protected void onOpen(Level world, BlockPos pos, BlockState state) { -@@ -98,6 +105,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement - this.chestLidController = new ChestLidController(); - } - -+ // Pufferfish start -+ @Override -+ public boolean hasEmptySlot(Direction enumdirection) { -+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection); -+ } -+ -+ @Override -+ public boolean isCompletelyFull(Direction enumdirection) { -+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection); -+ } -+ -+ @Override -+ public boolean isCompletelyEmpty(Direction enumdirection) { -+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection); -+ } -+ // Pufferfish end -+ - public ChestBlockEntity(BlockPos pos, BlockState state) { - this(BlockEntityType.CHEST, pos, state); - } -@@ -115,7 +139,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement - @Override - public void load(CompoundTag nbt) { - super.load(nbt); -- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); -+ // Pufferfish start -+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - if (!this.tryLoadLootTable(nbt)) { - ContainerHelper.loadAllItems(nbt, this.items); - } -@@ -187,7 +214,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement - - @Override - protected void setItems(NonNullList list) { -- this.items = list; -+ // Pufferfish start -+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index b11f51762ca289d99eaa49e66e31e58595bcea4e..f03608a133338b0f5522a07239e06fd2245db1e5 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - - public static final int MOVE_ITEM_SPEED = 8; - public static final int HOPPER_CONTAINER_SIZE = 5; -+ // Pufferfish start - private NonNullList items; -+ private gg.airplane.structs.ItemListWithBitset optimizedItems; // Pufferfish -+ // Pufferfish end - private int cooldownTime; - private long tickedGameTime; - -@@ -83,14 +86,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - - public HopperBlockEntity(BlockPos pos, BlockState state) { - super(BlockEntityType.HOPPER, pos, state); -- this.items = NonNullList.withSize(5, ItemStack.EMPTY); -+ // Pufferfish start -+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(5); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - this.cooldownTime = -1; - } - -+ // Pufferfish start -+ @Override -+ public boolean hasEmptySlot(Direction enumdirection) { -+ return !this.optimizedItems.hasFullStacks(); -+ } -+ -+ @Override -+ public boolean isCompletelyFull(Direction enumdirection) { -+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection); -+ } -+ -+ @Override -+ public boolean isCompletelyEmpty(Direction enumdirection) { -+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection); -+ } -+ // Pufferfish end -+ - @Override - public void load(CompoundTag nbt) { - super.load(nbt); -- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); -+ // Pufferfish start -+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - if (!this.tryLoadLootTable(nbt)) { - ContainerHelper.loadAllItems(nbt, this.items); - } -@@ -162,7 +188,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - flag = HopperBlockEntity.ejectItems(world, pos, state, (Container) blockEntity, blockEntity); // CraftBukkit - } - -- if (!blockEntity.inventoryFull()) { -+ if (!blockEntity.optimizedItems.hasFullStacks() || !blockEntity.inventoryFull()) { // Pufferfish - use bitset first - flag |= booleansupplier.getAsBoolean(); - } - -@@ -452,11 +478,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - } - - private static boolean isFullContainer(Container inventory, Direction direction) { -- return allMatch(inventory, direction, STACK_SIZE_TEST); // Paper - no streams -+ // Pufferfish start - use bitsets -+ //return allMatch(inventory, direction, STACK_SIZE_TEST); // Paper - no streams -+ return inventory.isCompletelyFull(direction); -+ // Pufferfish end - } - - private static boolean isEmptyContainer(Container inv, Direction facing) { -- return allMatch(inv, facing, IS_EMPTY_TEST); -+ // Paper start -+ // Pufferfish start - use bitsets -+ //return allMatch(inv, facing, IS_EMPTY_TEST); -+ return inv.isCompletelyEmpty(facing); -+ // Pufferfish end - } - - public static boolean suckInItems(Level world, Hopper hopper) { -@@ -637,7 +670,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - - if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) { - boolean flag = false; -- boolean flag1 = to.isEmpty(); -+ boolean flag1 = to.isCompletelyEmpty(side); // Pufferfish - - if (itemstack1.isEmpty()) { - // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem -@@ -832,7 +865,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - - @Override - protected void setItems(NonNullList list) { -- this.items = list; -+ // Pufferfish start -+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list); -+ this.items = this.optimizedItems.nonNullList; -+ // Pufferfish end - } - - public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) { -diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 081691f9710ff1115e4308f79ed49fbc38941193..765ee7f78532a363813286ef7db2a7e48605cb06 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -96,12 +96,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - public boolean isEmpty() { - this.unpackLootTable((Player)null); - // Paper start -- for (final ItemStack itemStack : this.getItems()) { -- if (!itemStack.isEmpty()) { -- return false; -- } -- } -- return true; -+ return this.isCompletelyEmpty(null); // Pufferfish - use super - // Paper end - } - -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 4ff0d2fc9fd76e92e64abd69f2c9e299aa08ac32..3eeb1f0eac76efe9b7c24f6d5787018c7842d07a 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -85,6 +85,18 @@ public class LevelChunk extends ChunkAccess { - private final LevelChunkTicks blockTicks; - private final LevelChunkTicks fluidTicks; - -+ // Pufferfish start - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively -+ private int lightningTick; -+ // shouldDoLightning compiles down to 29 bytes, which with the default of 35 byte inlining should guarantee an inline -+ public final boolean shouldDoLightning(net.minecraft.util.RandomSource random) { -+ if (this.lightningTick-- <= 0) { -+ this.lightningTick = random.nextInt(this.level.spigotConfig.thunderChance) << 1; -+ return true; -+ } -+ return false; -+ } -+ // Pufferfish end -+ - public LevelChunk(Level world, ChunkPos pos) { - this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); - } -@@ -112,6 +124,8 @@ public class LevelChunk extends ChunkAccess { - this.postLoad = entityLoader; - this.blockTicks = blockTickScheduler; - this.fluidTicks = fluidTickScheduler; -+ -+ this.lightningTick = this.level.getThreadUnsafeRandom().nextInt(100000) << 1; // Pufferfish - initialize lightning tick - } - - // CraftBukkit start diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index d4477b0dda6a1ef7bd8323c0d11b636bd071d18e..5d3dd6a61366ae2c185b62bc9198440ef6227927 100644 +index f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb522646b5ee1c2 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -25,6 +25,7 @@ public class LevelChunkSection { @@ -3130,9 +3269,9 @@ index d4477b0dda6a1ef7bd8323c0d11b636bd071d18e..5d3dd6a61366ae2c185b62bc9198440e private PalettedContainer> biomes; + public short fluidStateCount; // Pufferfish public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper - - public LevelChunkSection(PalettedContainer datapaletteblock, PalettedContainer> palettedcontainerro) { -@@ -190,6 +191,7 @@ public class LevelChunkSection { + // Paper start - optimise collisions + private int specialCollidingBlocks; +@@ -102,6 +103,7 @@ public class LevelChunkSection { if (!fluid.isEmpty()) { --this.tickingFluidCount; @@ -3140,22 +3279,22 @@ index d4477b0dda6a1ef7bd8323c0d11b636bd071d18e..5d3dd6a61366ae2c185b62bc9198440e } if (!state.isAir()) { -@@ -204,6 +206,7 @@ public class LevelChunkSection { +@@ -116,6 +118,7 @@ public class LevelChunkSection { if (!fluid1.isEmpty()) { ++this.tickingFluidCount; + ++this.fluidStateCount; // Pufferfish } - this.updateKnownBlockInfo(x | (z << 4) | (y << 8), iblockdata1, state); // Paper -@@ -249,6 +252,7 @@ public class LevelChunkSection { + this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions +@@ -161,6 +164,7 @@ public class LevelChunkSection { if (fluid.isRandomlyTicking()) { this.tickingFluidCount = (short) (this.tickingFluidCount + 1); } + this.fluidStateCount++; // Pufferfish } - }); + // Paper start - optimise collisions diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java index 4cdfc433df67afcd455422e9baf56f167dd712ae..57fcf3910f45ce371ac2e237b277b1034caaac4e 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java @@ -3170,10 +3309,10 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..57fcf3910f45ce371ac2e237b277b103 private void ensureActiveIsNotIterated() { // Paper - replace with better logic, do not delay removals diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index 5502ad143fd2575f1346334b5b4fe7846628f54e..7d56693102ee558fe784e3a9b9fdcff4b7ad57b9 100644 +index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..089f42d16b2e279fa0daefb8705867a4e9ed54d7 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -44,6 +44,8 @@ public abstract class FlowingFluid extends Fluid { +@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid { public static final BooleanProperty FALLING = BlockStateProperties.FALLING; public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_FLOWING; private static final int CACHE_SIZE = 200; @@ -3182,12 +3321,11 @@ index 5502ad143fd2575f1346334b5b4fe7846628f54e..7d56693102ee558fe784e3a9b9fdcff4 private static final ThreadLocal> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap(200) { protected void rehash(int i) {} -@@ -52,6 +54,14 @@ public abstract class FlowingFluid extends Fluid { +@@ -53,6 +55,13 @@ public abstract class FlowingFluid extends Fluid { object2bytelinkedopenhashmap.defaultReturnValue((byte) 127); return object2bytelinkedopenhashmap; }); + */ -+ + private static final ThreadLocal> localFluidDirectionCache = ThreadLocal.withInitial(() -> { + // Pufferfish todo - mess with this number for performance + // with 2048 it seems very infrequent on a small world that it has to remove old entries @@ -3197,16 +3335,16 @@ index 5502ad143fd2575f1346334b5b4fe7846628f54e..7d56693102ee558fe784e3a9b9fdcff4 private final Map shapes = Maps.newIdentityHashMap(); public FlowingFluid() {} -@@ -240,6 +250,8 @@ public abstract class FlowingFluid extends Fluid { - } - - private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) { +@@ -252,6 +261,8 @@ public abstract class FlowingFluid extends Fluid { + return false; + } + // Paper end - optimise collisions + // Pufferfish start - modify to use our cache + /* Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -@@ -247,9 +259,16 @@ public abstract class FlowingFluid extends Fluid { +@@ -259,9 +270,16 @@ public abstract class FlowingFluid extends Fluid { } else { object2bytelinkedopenhashmap = null; } @@ -3223,7 +3361,7 @@ index 5502ad143fd2575f1346334b5b4fe7846628f54e..7d56693102ee558fe784e3a9b9fdcff4 if (object2bytelinkedopenhashmap != null) { block_a = new Block.BlockStatePairKey(state, fromState, face); byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a); -@@ -260,11 +279,22 @@ public abstract class FlowingFluid extends Fluid { +@@ -272,11 +290,22 @@ public abstract class FlowingFluid extends Fluid { } else { block_a = null; } @@ -3246,14 +3384,12 @@ index 5502ad143fd2575f1346334b5b4fe7846628f54e..7d56693102ee558fe784e3a9b9fdcff4 if (object2bytelinkedopenhashmap != null) { if (object2bytelinkedopenhashmap.size() == 200) { object2bytelinkedopenhashmap.removeLastByte(); -@@ -272,6 +302,11 @@ public abstract class FlowingFluid extends Fluid { +@@ -284,6 +313,9 @@ public abstract class FlowingFluid extends Fluid { object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0)); } + */ -+ if (cache != null) { -+ cache.putValue(block_a, flag); -+ } ++ if (cache != null) cache.putValue(block_a, flag); + // Pufferfish end return flag; @@ -3362,10 +3498,10 @@ index ebe65474a4a05ff1637d7f37ebcfe690af59def5..42142c512b12e5b269c19f1e821c50e7 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 74d06790de674cbd230a0b14ac9a6b614c9f84ef..0f89716d1131178bd7ac927ef68337357139e2b7 100644 +index fcd5096d64edfaf6bce3ecce8c9b9afb84462786..7f2f4f3d804832e314983ba78fe9c6cc3cfcdb1f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -265,7 +265,7 @@ import javax.annotation.Nullable; // Paper +@@ -267,7 +267,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { @@ -3374,7 +3510,7 @@ index 74d06790de674cbd230a0b14ac9a6b614c9f84ef..0f89716d1131178bd7ac927ef6833735 private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); -@@ -1120,6 +1120,11 @@ public final class CraftServer implements Server { +@@ -1122,6 +1122,11 @@ public final class CraftServer implements Server { plugin.getPluginMeta().getDisplayName(), "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies." )); @@ -3387,22 +3523,59 @@ index 74d06790de674cbd230a0b14ac9a6b614c9f84ef..0f89716d1131178bd7ac927ef6833735 } // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -index f7ea77dd82d978ad307f99c743efacfb34478b3d..009ab06182359862b8f543030ec4fe4e2572c93c 100644 +index acfe2676b840d4edc70507aa139f7db212ed90b7..65971a2da4e947c7ed60c0730827136665bb7674 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe +@@ -45,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe data.set(i, toNMS(ingred.get(i), true)); } -- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data)); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true)); +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); } } +diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java b/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java +index d96399e9bf1a58db5a4a22e58abb99e7660e0694..eb19f679ee498e51d02fe9a961cf02699cf75848 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java ++++ b/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java +@@ -22,7 +22,8 @@ public class MinecraftInternalPlugin extends PluginBase { + private boolean enabled = true; + + private final String pluginName; +- private PluginDescriptionFile pdf; ++ private org.bukkit.plugin.PluginLogger logger; ++ private PluginDescriptionFile pdf; // Pufferfish + + public MinecraftInternalPlugin() { + this.pluginName = "Minecraft"; +@@ -81,7 +82,12 @@ public class MinecraftInternalPlugin extends PluginBase { + + @Override + public PluginLogger getLogger() { +- throw new UnsupportedOperationException("Not supported."); ++ // Pufferfish start ++ if (this.logger == null) { ++ this.logger = new org.bukkit.plugin.PluginLogger(this); // Pufferfish ++ } ++ return this.logger; ++ // Pufferfish end + } + + @Override +@@ -91,7 +97,7 @@ public class MinecraftInternalPlugin extends PluginBase { + + @Override + public Server getServer() { +- throw new UnsupportedOperationException("Not supported."); ++ return org.bukkit.Bukkit.getServer(); // Pufferfish - impl + } + + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 719e7103f7dfdc30f1cefd24a3fa572fa0ac8b1e..2b4581f92543c11f31bcc1417e90d7f90b2aea20 100644 +index 96f6e0554baf5915dd1f5b93f3bcfe7a13393c29..031e5acee0061d7f8050ea3a42f33b42112a3172 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -470,7 +470,7 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -452,7 +452,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { @@ -3411,6 +3584,18 @@ index 719e7103f7dfdc30f1cefd24a3fa572fa0ac8b1e..2b4581f92543c11f31bcc1417e90d7f9 } @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java +index e8e93538dfd71de86515d9405f728db1631e949a..3dff02fd97f001508e2f81192817bf1b0ef92446 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java +@@ -11,6 +11,7 @@ public class ServerShutdownThread extends Thread { + + @Override + public void run() { ++ try { gg.pufferfish.pufferfish.flare.ProfilingManager.stop(); } catch (Throwable t) {} // Pufferfish - shut down Flare if it's running + try { + // Paper start - try to shutdown on main + server.safeShutdown(false, false); diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 774556a62eb240da42e84db4502e2ed43495be17..80553face9c70c2a3d897681e7761df85b22d464 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -3425,7 +3610,7 @@ index 774556a62eb240da42e84db4502e2ed43495be17..80553face9c70c2a3d897681e7761df8 if (stream != null) { diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index eda7f0bb42f7269676d5d2193e1155912ede9920..68557964e27fa1e5ba218178f9bcc0b28e3a78d9 100644 +index 2f9e5a1adf9d67ffe18d95f2822ca3d2288fb27a..acde675a8f1b84b686d53084d66dece3ad5f940e 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings; @@ -3439,9 +3624,9 @@ index eda7f0bb42f7269676d5d2193e1155912ede9920..68557964e27fa1e5ba218178f9bcc0b2 public class ActivationRange { -@@ -217,6 +221,25 @@ public class ActivationRange - for (int i = 0; i < entities.size(); i++) { - Entity entity = entities.get(i); +@@ -222,6 +226,24 @@ public class ActivationRange + } + // Paper end - configurable marker ticking ActivationRange.activateEntity(entity); + + // Pufferfish start @@ -3461,26 +3646,10 @@ index eda7f0bb42f7269676d5d2193e1155912ede9920..68557964e27fa1e5ba218178f9bcc0b2 + entity.activatedPriority = 1; + } + // Pufferfish end -+ } // Paper end } -@@ -233,12 +256,12 @@ public class ActivationRange - if ( MinecraftServer.currentTick > entity.activatedTick ) - { - if ( entity.defaultActivationState ) -- { -+ { // Pufferfish - diff on change - entity.activatedTick = MinecraftServer.currentTick; - return; - } - if ( entity.activationType.boundingBox.intersects( entity.getBoundingBox() ) ) -- { -+ { // Pufferfish - diff on change - entity.activatedTick = MinecraftServer.currentTick; - } - } -@@ -292,7 +315,7 @@ public class ActivationRange +@@ -297,7 +319,7 @@ public class ActivationRange if ( entity instanceof LivingEntity ) { LivingEntity living = (LivingEntity) entity; diff --git a/patches/server/0002-Purpur-Server-Changes.patch b/patches/server/0002-Purpur-Server-Changes.patch index c985bdeee..2b99cc96a 100644 --- a/patches/server/0002-Purpur-Server-Changes.patch +++ b/patches/server/0002-Purpur-Server-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 23 Sep 2023 10:28:30 +0000 +From: William Blake Galbreath +Date: Wed, 27 Sep 2023 05:28:53 +0000 Subject: [PATCH] Purpur Server Changes Original: PurpurMC @@ -25,10 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts -index 4d89c46c7ee559acf986ff5081a42fe91cb5a257..3d5397e2e7edf2ea1e1687c58126fd9a5d5d5736 100644 +index de0a05602389ebb005bb7fd3c8d78da045d55bbe..393dab1ece76e0ca1e0b58c0b2c72d5c1c41a84d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,12 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -13,13 +13,13 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { @@ -40,23 +40,23 @@ index 4d89c46c7ee559acf986ff5081a42fe91cb5a257..3d5397e2e7edf2ea1e1687c58126fd9a + implementation("io.papermc.paper:paper-mojangapi:${project.version}") { exclude("io.papermc.paper", "paper-api") } -- // Pufferfish end + // Purpur end + implementation("com.github.technove:Flare:34637f3f87") // flare +- // Pufferfish end // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -56,6 +56,10 @@ dependencies { - runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3") - runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3") - +@@ -63,6 +63,9 @@ dependencies { + exclude(group="org.yaml", module="snakeyaml") + } + // Pufferfish end + implementation("org.mozilla:rhino-runtime:1.7.14") // Purpur + implementation("org.mozilla:rhino-engine:1.7.14") // Purpur + implementation("dev.omega24:upnp4j:1.0") // Purpur -+ - // Pufferfish start - implementation("org.yaml:snakeyaml:1.32") - implementation ("com.github.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { -@@ -91,7 +95,7 @@ tasks.jar { + + testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test + testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") +@@ -84,7 +87,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -65,7 +65,7 @@ index 4d89c46c7ee559acf986ff5081a42fe91cb5a257..3d5397e2e7edf2ea1e1687c58126fd9a "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -168,7 +172,7 @@ fun TaskContainer.registerRunTask( +@@ -168,7 +171,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -166,7 +166,7 @@ index 0000000000000000000000000000000000000000..15a226e3854d731f7724025ea3459c8a + } +} diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 692c962193cf9fcc6801fc93f3220bdc673d527b..8cde30544e14f8fc2dac32966ae3c21f8cf3a551 100644 +index 692c962193cf9fcc6801fc93f3220bdc673d527b..b0b2cbd8d9db1772d43a285eca9060f3879acab0 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,7 @@ public class Metrics { @@ -178,25 +178,16 @@ index 692c962193cf9fcc6801fc93f3220bdc673d527b..8cde30544e14f8fc2dac32966ae3c21f metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> { String minecraftVersion = Bukkit.getVersion(); -@@ -602,16 +602,8 @@ public class Metrics { +@@ -602,7 +602,8 @@ public class Metrics { })); metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size())); - metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline")); -- final String paperVersion; -- final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion(); -- if (implVersion != null) { -- final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1); -- paperVersion = "git-Pufferfish-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Pufferfish -- } else { -- paperVersion = "unknown"; -- } -- metrics.addCustomChart(new Metrics.SimplePie("pufferfish_version", () -> paperVersion)); // Pufferfish + metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur + metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur - - metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { - Map> map = new HashMap<>(); + final String paperVersion; + final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion(); + if (implVersion != null) { diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..462a6eed350fd660ddaf25d567bb6e97b77d0b2b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -342,18 +333,18 @@ index fa56cd09102a89692b42f1d14257990508c5c720..f9251183df72ddc56662fd3f02acf216 setListData(vector); } diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -index 95d1a8a5b349f7849c040026bfa3469d03d92bfd..3e36958365bc136516bafbaad0c168f7956406f1 100644 +index 7b091c1258c3f33933ec30a15d963e9d5f069ba7..5f223856b06e901b100fcca8e6dd968e0b2e3a8e 100644 --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -@@ -28,6 +28,7 @@ public class PufferfishConfig { +@@ -36,6 +36,7 @@ public class PufferfishConfig { private static final YamlFile config = new YamlFile(); private static int updates = 0; -+ public static File pufferfishFile; // Purpur ++ public static File pufferfishFile; // Purpur private static ConfigurationSection convertToBukkit(org.simpleyaml.configuration.ConfigurationSection section) { ConfigurationSection newSection = new MemoryConfiguration(); -@@ -50,7 +51,7 @@ public class PufferfishConfig { +@@ -58,7 +59,7 @@ public class PufferfishConfig { } public static void load() throws IOException { @@ -362,7 +353,7 @@ index 95d1a8a5b349f7849c040026bfa3469d03d92bfd..3e36958365bc136516bafbaad0c168f7 if (configFile.exists()) { try { -@@ -224,7 +225,7 @@ public class PufferfishConfig { +@@ -232,7 +233,7 @@ public class PufferfishConfig { public static int activationDistanceMod; private static void dynamicActivationOfBrains() throws IOException { @@ -371,7 +362,7 @@ index 95d1a8a5b349f7849c040026bfa3469d03d92bfd..3e36958365bc136516bafbaad0c168f7 startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12, "This value determines how far away an entity has to be", "from the player to start being effected by DEAR."); -@@ -268,7 +269,7 @@ public class PufferfishConfig { +@@ -276,7 +277,7 @@ public class PufferfishConfig { public static boolean throttleInactiveGoalSelectorTick; private static void inactiveGoalSelectorThrottle() { @@ -397,7 +388,7 @@ index abd0217cf0bff183c8e262edc173a53403797c1a..2519ad2884b6c09b312432b933c31476 private static final ThreadLocal> CURRENT_TICKET_UPDATE_SCHEDULING = new ThreadLocal<>(); diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -index 51304c5cf4b0ac7646693ef97ef4a3847d3342b5..535ab99585cd4463d051334681bc80b5d20df7c0 100644 +index b66a7d4aab887309579154815a0d4abf9de506b0..e6f56bc5b129699bab60db9c97c7f73b6ede2351 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java @@ -1779,7 +1779,7 @@ public final class NewChunkHolder { @@ -678,7 +669,7 @@ index 0000000000000000000000000000000000000000..a7d1ae53eac94bc2dcf8bc78ef1da0d3 + } +} diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java -index abe37c7c3c6f5ab73afd738ec78f06d7e4d2ed96..b5b6657e52e4f7a630229bd3ba433438af293e22 100644 +index 1d714d3eff11ed14f218656008190017494d4830..ed3527612315e6e0649182ce4e1ae2834b0918a9 100644 --- a/src/main/java/net/minecraft/CrashReport.java +++ b/src/main/java/net/minecraft/CrashReport.java @@ -123,6 +123,10 @@ public class CrashReport { @@ -693,10 +684,10 @@ index abe37c7c3c6f5ab73afd738ec78f06d7e4d2ed96..b5b6657e52e4f7a630229bd3ba433438 stringbuilder.append(CrashReport.getErrorComment()); stringbuilder.append("\n\n"); diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 0de2eae2d448ac9e269a4edf48406d5ea8af8059..873659dcf8c8431f21bd2b23b8d7bdb4ea7e03e8 100644 +index 56ae02aab93b9a698e9d2f07a0448aa4767169d9..106b27d507b16297a0a88b3b5beaaf3d0ef7e2c6 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java -@@ -227,6 +227,19 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy +@@ -223,6 +223,19 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy } // CraftBukkit end @@ -716,7 +707,7 @@ index 0de2eae2d448ac9e269a4edf48406d5ea8af8059..873659dcf8c8431f21bd2b23b8d7bdb4 public Vec3 getPosition() { return this.worldPosition; } -@@ -336,6 +349,30 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy +@@ -332,6 +345,30 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy } } @@ -748,10 +739,10 @@ index 0de2eae2d448ac9e269a4edf48406d5ea8af8059..873659dcf8c8431f21bd2b23b8d7bdb4 boolean flag1 = this.source.acceptsSuccess() && !this.silent; boolean flag2 = broadcastToOps && this.source.shouldInformAdmins() && !this.silent; diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e970a0533 100644 +index 3eec879bf3975636739b2491cc05b8177032d16d..2fd376789bb24b14101e289733631a9a4b68fa1c 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -150,7 +150,7 @@ public class Commands { +@@ -152,7 +152,7 @@ public class Commands { DamageCommand.register(this.dispatcher, commandRegistryAccess); DataCommands.register(this.dispatcher); DataPackCommand.register(this.dispatcher); @@ -760,7 +751,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e DefaultGameModeCommands.register(this.dispatcher); DifficultyCommand.register(this.dispatcher); EffectCommands.register(this.dispatcher, commandRegistryAccess); -@@ -224,6 +224,14 @@ public class Commands { +@@ -230,6 +230,14 @@ public class Commands { SetPlayerIdleTimeoutCommand.register(this.dispatcher); StopCommand.register(this.dispatcher); WhitelistCommand.register(this.dispatcher); @@ -775,7 +766,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e } if (environment.includeIntegrated) { -@@ -311,9 +319,9 @@ public class Commands { +@@ -317,9 +325,9 @@ public class Commands { public int performCommand(ParseResults parseresults, String s, String label) { // CraftBukkit CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); @@ -787,7 +778,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e byte b0; -@@ -396,7 +404,7 @@ public class Commands { +@@ -402,7 +410,7 @@ public class Commands { b0 = 0; } } finally { @@ -796,7 +787,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e } return b0; -@@ -456,6 +464,7 @@ public class Commands { +@@ -462,6 +470,7 @@ public class Commands { private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { // Paper end - Async command map building new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper @@ -804,7 +795,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -466,6 +475,7 @@ public class Commands { +@@ -472,6 +481,7 @@ public class Commands { } } // CraftBukkit end @@ -813,7 +804,7 @@ index 80c2c8d565f03ae0ea24fbdecdbe2bc5b9aa4b82..5c0085589b08f199c75ceeab8d0cf25e } diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..7e66aaa960ce7b6dda7c064d4c6856cc4b368b58 100644 +index 73c15a0c56a103ba4e62f0a51af8d42566b07245..d630c5a1aed706265d1e077da540c0bf723b838d 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -200,10 +200,10 @@ public class EntitySelector { @@ -829,8 +820,8 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..7e66aaa960ce7b6dda7c064d4c6856cc } else { Vec3 vec3d = (Vec3) this.position.apply(source.getPosition()); Predicate predicate = this.getPredicate(vec3d); -@@ -213,7 +213,7 @@ public class EntitySelector { - ServerPlayer entityplayer1 = (ServerPlayer) source.getEntity(); +@@ -215,7 +215,7 @@ public class EntitySelector { + ServerPlayer entityplayer1 = (ServerPlayer) entity; if (predicate.test(entityplayer1)) { - return Lists.newArrayList(new ServerPlayer[]{entityplayer1}); @@ -838,7 +829,7 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..7e66aaa960ce7b6dda7c064d4c6856cc } } -@@ -224,6 +224,7 @@ public class EntitySelector { +@@ -226,6 +226,7 @@ public class EntitySelector { if (this.isWorldLimited()) { object = source.getLevel().getPlayers(predicate, i); @@ -846,7 +837,7 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..7e66aaa960ce7b6dda7c064d4c6856cc } else { object = Lists.newArrayList(); Iterator iterator = source.getServer().getPlayerList().getPlayers().iterator(); -@@ -231,7 +232,7 @@ public class EntitySelector { +@@ -233,7 +234,7 @@ public class EntitySelector { while (iterator.hasNext()) { ServerPlayer entityplayer2 = (ServerPlayer) iterator.next(); @@ -855,7 +846,7 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..7e66aaa960ce7b6dda7c064d4c6856cc ((List) object).add(entityplayer2); if (((List) object).size() >= i) { return (List) object; -@@ -276,4 +277,10 @@ public class EntitySelector { +@@ -278,4 +279,10 @@ public class EntitySelector { public static Component joinNames(List entities) { return ComponentUtils.formatList(entities, Entity::getDisplayName); } @@ -884,10 +875,10 @@ index 83cab746d1d6fe25c043c8aee28c39412b90c127..ec6b58dae525c81bbb1c0e2d96fbded6 super(x, y, z); } diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java -index d0a8092bf57a29ab7c00ec0ddf52a9fdb2a33267..defe5951938ce3a7b7f83017d4af36bb49ff5be0 100644 +index 392406722b0a040c1d41fdc1154d75d39f6e9c86..b805e57d5a67d77d226cd8154e970050e2e8ef4a 100644 --- a/src/main/java/net/minecraft/core/Direction.java +++ b/src/main/java/net/minecraft/core/Direction.java -@@ -238,6 +238,12 @@ public enum Direction implements StringRepresentable { +@@ -253,6 +253,12 @@ public enum Direction implements StringRepresentable { case EAST: var10000 = SOUTH; break; @@ -900,7 +891,7 @@ index d0a8092bf57a29ab7c00ec0ddf52a9fdb2a33267..defe5951938ce3a7b7f83017d4af36bb default: throw new IllegalStateException("Unable to get Y-rotated facing of " + this); } -@@ -350,6 +356,12 @@ public enum Direction implements StringRepresentable { +@@ -365,6 +371,12 @@ public enum Direction implements StringRepresentable { case EAST: var10000 = NORTH; break; @@ -914,10 +905,10 @@ index d0a8092bf57a29ab7c00ec0ddf52a9fdb2a33267..defe5951938ce3a7b7f83017d4af36bb throw new IllegalStateException("Unable to get CCW facing of " + this); } diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 8c2750de3be202122ccf9923a9fa32fcb8bdb743..7961a69d3e70a8ae1d74c732cd97a9cbd824a8d0 100644 +index a0c7c6208314d981e8577ad69ef1c5193290a085..603eac94296c32d87dccf2c6b5fd7183864346f2 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -1187,6 +1187,23 @@ public interface DispenseItemBehavior { +@@ -1188,6 +1188,23 @@ public interface DispenseItemBehavior { } } }); @@ -925,10 +916,10 @@ index 8c2750de3be202122ccf9923a9fa32fcb8bdb743..7961a69d3e70a8ae1d74c732cd97a9cb + DispenserBlock.registerBehavior(Items.ANVIL, (new OptionalDispenseItemBehavior() { + @Override + public ItemStack execute(BlockSource dispenser, ItemStack stack) { -+ Level level = dispenser.getLevel(); ++ Level level = dispenser.level(); + if (!level.purpurConfig.dispenserPlaceAnvils) return super.execute(dispenser, stack); -+ Direction facing = dispenser.getBlockState().getValue(DispenserBlock.FACING); -+ BlockPos pos = dispenser.getPos().relative(facing); ++ Direction facing = dispenser.blockEntity().getBlockState().getValue(DispenserBlock.FACING); ++ BlockPos pos = dispenser.pos().relative(facing); + BlockState state = level.getBlockState(pos); + if (state.isAir()) { + level.setBlockAndUpdate(pos, Blocks.ANVIL.defaultBlockState().setValue(net.minecraft.world.level.block.AnvilBlock.FACING, facing.getAxis() == Direction.Axis.Y ? Direction.NORTH : facing.getClockWise())); @@ -940,9 +931,9 @@ index 8c2750de3be202122ccf9923a9fa32fcb8bdb743..7961a69d3e70a8ae1d74c732cd97a9cb + // Purpur end } - static void setEntityPokingOutOfBlock(BlockSource pointer, Entity entity, Direction direction) { + static Vec3 getEntityPokingOutOfBlockPos(BlockSource pointer, EntityType entityType, Direction direction) { diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -index 9b0049dfeaec9b688bf276f2ac2b18943b5696b2..d7563904232353cbf3b9255cedfb75920e35220c 100644 +index e17090003988ad2c890d48666c2234b14d511345..433f1f11b8b92c7d48352416f79ab5a394c33287 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java @@ -107,7 +107,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { @@ -955,10 +946,10 @@ index 9b0049dfeaec9b688bf276f2ac2b18943b5696b2..d7563904232353cbf3b9255cedfb7592 return true; } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 52cb6476604c98465f81ff9e8d8344d7536a8868..13144ea01bc27db95a13b267d39529b012a4c9c4 100644 +index c0ea20dcee8bb293df96bc6ee019e50ad6b383fd..ff99d6fa919391d43b7737a2819cf9ebb7e134da 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -579,11 +579,20 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -569,11 +569,20 @@ public class Connection extends SimpleChannelInboundHandler> { private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper private static int joinAttemptsThisTick; // Paper private static int currTick; // Paper @@ -980,10 +971,10 @@ index 52cb6476604c98465f81ff9e8d8344d7536a8868..13144ea01bc27db95a13b267d39529b0 } // Paper end diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index 9938bb90bef84cf784f9a1ceb02a1a45aa8b48a1..1f4b64a5f812376c499c98cb4be62469bd0b7dbe 100644 +index 2e395962b555bef0ce1a98e1d768e7738f011535..40f51062624161892c780ddae05e22859e2cd021 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -98,6 +98,8 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -94,6 +94,8 @@ public class FriendlyByteBuf extends ByteBuf { private static final int MAX_PUBLIC_KEY_LENGTH = 512; private static final Gson GSON = new Gson(); @@ -992,7 +983,7 @@ index 9938bb90bef84cf784f9a1ceb02a1a45aa8b48a1..1f4b64a5f812376c499c98cb4be62469 public FriendlyByteBuf(ByteBuf parent) { this.source = parent; } -@@ -679,6 +681,17 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -632,6 +634,17 @@ public class FriendlyByteBuf extends ByteBuf { this.writeBoolean(false); } else { this.writeBoolean(true); @@ -1011,18 +1002,18 @@ index 9938bb90bef84cf784f9a1ceb02a1a45aa8b48a1..1f4b64a5f812376c499c98cb4be62469 this.writeId(BuiltInRegistries.ITEM, item); diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index d2f0a0755317f5fa9a1ccf7db346aa77fd287d80..03852e7d21d9470a4469676367463fefb38acdc6 100644 +index 9a49f5271ec1d9de17632bfffe8309cb1ba0d8b1..0be239c5c78432a6377cd7828cd49f61f8f0ac8f 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -47,7 +47,7 @@ public class PacketUtils { - if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590 - if (listener.isAcceptingMessages()) { +@@ -49,7 +49,7 @@ public class PacketUtils { + if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590 + if (listener.shouldHandleMessage(packet)) { co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings - try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings + try { // Paper - timings // Purpur packet.handle(listener); } catch (Exception exception) { - if (listener.shouldPropagateHandlingExceptions()) { + if (exception instanceof ReportedException) { diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java index 9ec6145fe04ec64bbee8ec6a837719caebdbc6f5..358d610ad020cada1bb83e393deeeaaec05a2791 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTimePacket.java @@ -1037,10 +1028,10 @@ index 9ec6145fe04ec64bbee8ec6a837719caebdbc6f5..358d610ad020cada1bb83e393deeeaae public ClientboundSetTimePacket(long time, long timeOfDay, boolean doDaylightCycle) { this.gameTime = time; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 67cba5cf510e4a602121e10c015a491650127752..e6ddf69ade7ae51640569150f7db10d1afa63691 100644 +index 87cacb46fb2b07482d3d608019d65a74b3854800..8c3942d9ce4f8a102a47bec74af5911760fda4e3 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -293,6 +293,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; public Commands vanillaCommandDispatcher; -@@ -302,15 +303,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { -@@ -337,13 +340,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -+ //this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; // Purpur -+ //this.profiler = this.metricsRecorder.getProfiler(); // Purpur -+ /*this.onMetricsRecordingStopped = (methodprofilerresults) -> { // Purpur - this.stopRecordingMetrics(); -- }; -- this.onMetricsRecordingFinished = (path) -> { -- }; -+ };*/ // Purpur -+ //this.onMetricsRecordingFinished = (path) -> { // Purpur -+ //}; // Purpur ++ /* // Purpur + this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; + this.profiler = this.metricsRecorder.getProfiler(); + this.onMetricsRecordingStopped = (methodprofilerresults) -> { +@@ -341,6 +345,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + }; ++ */ // Purpur this.random = RandomSource.create(); this.port = -1; this.levels = Maps.newLinkedHashMap(); -@@ -922,7 +925,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { return !this.canOversleep(); }); - isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); -+ //isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); // Purpur ++ //isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); // Purpur // Plazma TODO: unmark isOversleep // Paper end new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper -@@ -1403,7 +1428,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; try { this.isSaving = true; -@@ -1418,20 +1443,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + entityplayer.connection.suspendFlushing(); + }); - MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper + //MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper // Purpur this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit @@ -1282,7 +1264,7 @@ index 67cba5cf510e4a602121e10c015a491650127752..e6ddf69ade7ae51640569150f7db10d1 // Paper start - Folia scheduler API ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); getAllLevels().forEach(level -> { -@@ -1495,22 +1520,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper + worldserver.hasRidableMoveEvent = org.purpurmc.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur -- this.profiler.push(() -> { -+ /*this.profiler.push(() -> { // Purpur ++ /* // Purpur + this.profiler.push(() -> { return worldserver + " " + worldserver.dimension().location(); -- }); -+ });*/ // Purpur + }); ++ */ // Purpur /* Drop global time updates if (this.tickCount % 20 == 0) { -- this.profiler.push("timeSync"); -+ //this.profiler.push("timeSync"); // Purpur - this.synchronizeTime(worldserver); -- this.profiler.pop(); -+ //this.profiler.pop(); // Purpur + this.profiler.push("timeSync"); +@@ -1542,17 +1577,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { this.executeBlocking(() -> { - this.saveDebugReport(path.resolve("server")); -@@ -2523,40 +2550,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resultConsumer, Consumer dumpConsumer) { -- this.onMetricsRecordingStopped = (methodprofilerresults) -> { -+ /*this.onMetricsRecordingStopped = (methodprofilerresults) -> { // Purpur ++ /* // Purpur + this.onMetricsRecordingStopped = (methodprofilerresults) -> { this.stopRecordingMetrics(); resultConsumer.accept(methodprofilerresults); }; this.onMetricsRecordingFinished = dumpConsumer; -- this.willStartRecordingMetrics = true; -+ this.willStartRecordingMetrics = true;*/ // Purpur + this.willStartRecordingMetrics = true; ++ */ // Purpur } public void stopRecordingMetrics() { @@ -1514,7 +1497,7 @@ index 67cba5cf510e4a602121e10c015a491650127752..e6ddf69ade7ae51640569150f7db10d1 } public Path getWorldPath(LevelResource worldSavePath) { -@@ -2605,15 +2632,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { final io.papermc.paper.adventure.ChatDecorationProcessor processor = new io.papermc.paper.adventure.ChatDecorationProcessor(this, sender, commandSourceStack, message); -@@ -2779,7 +2815,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + // Paper start - Add Adventure message to PlayerAdvancementDoneEvent + if (event.message() != null && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { ++ if (org.purpurmc.purpur.PurpurConfig.advancementOnlyBroadcastToAffectedPlayer) this.player.sendMessage(message); else // Purpur + this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false); + // Paper end + } diff --git a/src/main/java/net/minecraft/server/ServerFunctionManager.java b/src/main/java/net/minecraft/server/ServerFunctionManager.java -index 4a610b712acfe0b1b4dcf4988bc22c6a71616050..426ac5faa9344472560fb20bdea8bdc314a97f97 100644 +index d10abd28c522612934aada8124e5bb67a9b4e9da..097ac55028d66ef9ab430ff5dd103db6e3b99fc7 100644 --- a/src/main/java/net/minecraft/server/ServerFunctionManager.java +++ b/src/main/java/net/minecraft/server/ServerFunctionManager.java -@@ -58,10 +58,10 @@ public class ServerFunctionManager { +@@ -60,10 +60,10 @@ public class ServerFunctionManager { } private void executeTagFunctions(Collection functions, ResourceLocation label) { @@ -1604,7 +1587,7 @@ index 4a610b712acfe0b1b4dcf4988bc22c6a71616050..426ac5faa9344472560fb20bdea8bdc3 Iterator iterator = functions.iterator(); while (iterator.hasNext()) { -@@ -70,7 +70,7 @@ public class ServerFunctionManager { +@@ -72,7 +72,7 @@ public class ServerFunctionManager { this.execute(customfunction, this.getGameLoopSender()); } @@ -1613,16 +1596,16 @@ index 4a610b712acfe0b1b4dcf4988bc22c6a71616050..426ac5faa9344472560fb20bdea8bdc3 } public int execute(CommandFunction function, CommandSourceStack source) { -@@ -89,7 +89,7 @@ public class ServerFunctionManager { +@@ -97,7 +97,7 @@ public class ServerFunctionManager { } else { int i; - try (co.aikar.timings.Timing timing = function.getTiming().startTiming()) { // Paper + try /*(co.aikar.timings.Timing timing = function.getTiming().startTiming())*/ { // Paper // Purpur this.context = new ServerFunctionManager.ExecutionContext(tracer); - i = this.context.runTopCommand(function, source); + i = this.context.runTopCommand(customfunction1, source); } finally { -@@ -187,10 +187,10 @@ public class ServerFunctionManager { +@@ -195,10 +195,10 @@ public class ServerFunctionManager { try { ServerFunctionManager.QueuedCommand customfunctiondata_queuedcommand = (ServerFunctionManager.QueuedCommand) this.commandQueue.removeFirst(); @@ -1635,7 +1618,7 @@ index 4a610b712acfe0b1b4dcf4988bc22c6a71616050..426ac5faa9344472560fb20bdea8bdc3 this.depth = customfunctiondata_queuedcommand.depth; customfunctiondata_queuedcommand.execute(ServerFunctionManager.this, this.commandQueue, i, this.tracer); if (this.abortCurrentDepth) { -@@ -209,7 +209,7 @@ public class ServerFunctionManager { +@@ -217,7 +217,7 @@ public class ServerFunctionManager { this.nestedCalls.clear(); } finally { @@ -1702,7 +1685,7 @@ index d601d287e94a59ff93b8a83a44dac02544d211df..0ff3b06a98b2f4514b2d861b92dd70fe itemstack1.setCount(1); entityitem = entityplayer.drop(itemstack1, false, false, false); // SPIGOT-2942: Add boolean to call event diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 10501842887c1ffdb6bb667480682b7174fd89c6..2a70abb9e0af502885593df1e732887cd9d2ce4d 100644 +index 87b7a8c44e3324f57b42b229eaba060d32ea00c9..a9f74eeb5b6300a0b7a940da9c17bd7582b0925d 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -99,6 +99,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -1732,8 +1715,8 @@ index 10501842887c1ffdb6bb667480682b7174fd89c6..2a70abb9e0af502885593df1e732887c + gg.pufferfish.pufferfish.PufferfishConfig.pufferfishFile = (java.io.File) options.valueOf("pufferfish-settings"); // Purpur gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish - -@@ -269,6 +280,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.setPvpAllowed(dedicatedserverproperties.pvp); +@@ -268,6 +279,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?"); return false; } @@ -1764,16 +1747,16 @@ index 10501842887c1ffdb6bb667480682b7174fd89c6..2a70abb9e0af502885593df1e732887c // CraftBukkit start // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up -@@ -341,6 +376,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -340,6 +375,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) mobSpawnExecutor.start(); // Pufferfish + org.purpurmc.purpur.task.BossBarTask.startAll(); // Purpur -+ org.purpurmc.purpur.task.BeehiveTask.instance().register(); // Purpur ++ org.purpurmc.purpur.task.BeehiveTask.instance().register(); return true; } } -@@ -487,7 +524,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -486,7 +523,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } public void handleConsoleInputs() { @@ -1782,7 +1765,7 @@ index 10501842887c1ffdb6bb667480682b7174fd89c6..2a70abb9e0af502885593df1e732887c // Paper start - use proper queue ConsoleInput servercommand; while ((servercommand = this.serverCommandQueue.poll()) != null) { -@@ -504,7 +541,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -503,7 +540,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // CraftBukkit end } @@ -1792,7 +1775,7 @@ index 10501842887c1ffdb6bb667480682b7174fd89c6..2a70abb9e0af502885593df1e732887c @Override diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index 818289e831e3dad29345c43265e2efd7689bc500..1ea3012995c738c67b31e997c138f824f9e69ba1 100644 +index c5598adb8cbcbcf7277c2fd4dd72c243d44d9700..cda4544ae96a4fcb5c6c4483df67a59f1b53fd27 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -58,6 +58,7 @@ public class DedicatedServerProperties extends Settings list = Lists.newArrayList(); List list1 = this.level.players(); ObjectIterator objectiterator = this.entityMap.values().iterator(); @@ -2011,7 +1965,7 @@ index d60ae9f8d3afe3e996a66331ee510cfa5841388c..3a7c694ff0e248df3f4d168a5e2e883c ChunkMap.TrackedEntity playerchunkmap_entitytracker; -@@ -1329,17 +1329,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1115,17 +1115,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider playerchunkmap_entitytracker.serverEntity.sendChanges(); } } @@ -2033,10 +1987,10 @@ index d60ae9f8d3afe3e996a66331ee510cfa5841388c..3a7c694ff0e248df3f4d168a5e2e883c } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c01e7eb383 100644 +index 390e5a4e9cead6f217de7689a47b8c3b4b042990..6255960ae70e14eb11da5043eb003575e300ddf6 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -280,16 +280,16 @@ public class ServerChunkCache extends ChunkSource { +@@ -278,16 +278,16 @@ public class ServerChunkCache extends ChunkSource { return ifLoaded; } // Paper end @@ -2056,7 +2010,7 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 CompletableFuture> completablefuture = this.getChunkFutureMainThread(x, z, leastStatus, create, true); // Paper ServerChunkCache.MainThreadExecutor chunkproviderserver_b = this.mainThreadProcessor; -@@ -299,10 +299,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -297,10 +297,10 @@ public class ServerChunkCache extends ChunkSource { io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system // Paper end com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info @@ -2069,7 +2023,7 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 } // Paper ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; -@@ -451,17 +451,17 @@ public class ServerChunkCache extends ChunkSource { +@@ -449,17 +449,17 @@ public class ServerChunkCache extends ChunkSource { public void save(boolean flush) { this.runDistanceManagerUpdates(); @@ -2091,7 +2045,7 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 } // Paper end -@@ -478,36 +478,36 @@ public class ServerChunkCache extends ChunkSource { +@@ -476,36 +476,36 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - modelled on below public void purgeUnload() { if (true) return; // Paper - tickets will be removed later, this behavior isn't really well accounted for by the chunk system @@ -2141,16 +2095,15 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 this.clearCache(); } -@@ -553,15 +553,15 @@ public class ServerChunkCache extends ChunkSource { - } - // Paper end - optimize isOutisdeRange +@@ -520,14 +520,14 @@ public class ServerChunkCache extends ChunkSource { + this.chunkMap.tick(); + } else { LevelData worlddata = this.level.getLevelData(); - ProfilerFiller gameprofilerfiller = this.level.getProfiler(); + //ProfilerFiller gameprofilerfiller = this.level.getProfiler(); // Purpur - gameprofilerfiller.push("pollingChunks"); + //gameprofilerfiller.push("pollingChunks"); // Purpur - this.level.resetIceAndSnowTick(); // Pufferfish - reset ice & snow tick random int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit @@ -2161,7 +2114,7 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 int l = this.distanceManager.getNaturalSpawnChunkCount(); // Paper start - per player mob spawning NaturalSpawner.SpawnState spawnercreature_d; // moved down -@@ -592,16 +592,16 @@ public class ServerChunkCache extends ChunkSource { +@@ -558,17 +558,17 @@ public class ServerChunkCache extends ChunkSource { // Pufferfish end } // Paper end @@ -2170,19 +2123,20 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 //this.lastSpawnState = spawnercreature_d; // Pufferfish - this is managed asynchronously - gameprofilerfiller.popPush("filteringLoadedChunks"); -+ //gameprofilerfiller.popPush("filteringLoadedChunks"); // Purpur - // Paper - moved down ++ //gameprofilerfiller.popPush("filteringLoadedChunks"); + // Paper - optimise chunk tick iteration + // Paper - optimise chunk tick iteration - this.level.timings.chunkTicks.startTiming(); // Paper + //this.level.timings.chunkTicks.startTiming(); // Paper // Purpur - // Paper - moved down + // Paper - optimise chunk tick iteration - gameprofilerfiller.popPush("spawnAndTick"); + //gameprofilerfiller.popPush("spawnAndTick"); // Purpur boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - // Paper - only shuffle if per-player mob spawning is disabled -@@ -652,17 +652,17 @@ public class ServerChunkCache extends ChunkSource { + // Paper start - optimise chunk tick iteration +@@ -670,17 +670,17 @@ public class ServerChunkCache extends ChunkSource { } } // Paper end - optimise chunk tick iteration @@ -2197,28 +2151,30 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 - } // Paper - timings + //} // Paper - timings // Purpur } -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded + - gameprofilerfiller.popPush("broadcast"); -- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing + //gameprofilerfiller.popPush("broadcast"); // Purpur -+ //this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Purpur + // Paper - optimise chunk tick iteration +- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing ++ //this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Purpur + // Paper start - optimise chunk tick iteration if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { - ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); - this.chunkMap.needsChangeBroadcasting.clear(); -@@ -674,8 +674,8 @@ public class ServerChunkCache extends ChunkSource { - } + it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); +@@ -694,10 +694,10 @@ public class ServerChunkCache extends ChunkSource { } } -- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing + // Paper end - optimise chunk tick iteration +- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing ++ //this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing // Purpur + // Paper - optimise chunk tick iteration - gameprofilerfiller.pop(); -+ //this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing // Purpur +- gameprofilerfiller.pop(); ++ //gameprofilerfiller.pop(); // Purpur + //gameprofilerfiller.pop(); // Purpur - // Paper end - use set of chunks requiring updates, rather than iterating every single one loaded - // Paper start - controlled flush for entity tracker packets - List disabledFlushes = new java.util.ArrayList<>(this.level.players.size()); -@@ -900,7 +900,7 @@ public class ServerChunkCache extends ChunkSource { + this.chunkMap.tick(); + } + +@@ -904,7 +904,7 @@ public class ServerChunkCache extends ChunkSource { @Override protected void doRunTask(Runnable task) { @@ -2228,10 +2184,10 @@ index fe1a9c646b09d11e7fa2186afbeb70b680ad2b57..2d5b0f293bb30243e774bfb62b8100c0 } diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 8ab959dd588b5154b63e133b2e937fa2d0ab8e52..fb11b020d52988360562db23d8568e5ef37e21c8 100644 +index b7f2bf1fbc0217e2968805521c108cb27c178dad..c6d80accdac49564b5386717a92dbd5a10237f06 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -70,7 +70,7 @@ public class ServerEntity { +@@ -73,7 +73,7 @@ public class ServerEntity { @Nullable private List> trackedDataValues; // CraftBukkit start @@ -2241,7 +2197,7 @@ index 8ab959dd588b5154b63e133b2e937fa2d0ab8e52..fb11b020d52988360562db23d8568e5e public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { this.trackedPlayers = trackedPlayers; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda875fae17 100644 +index 48402dc3008d1d1d513f0486c0a120719a9fd441..670d7649d25f7704b071d27157173a3139481207 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -214,6 +214,8 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2261,7 +2217,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda public static Throwable getAddToWorldStackTrace(Entity entity) { final Throwable thr = new Throwable(entity + " Added to world at " + new java.util.Date()); io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thr); -@@ -662,7 +665,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -706,7 +709,24 @@ public class ServerLevel extends Level implements WorldGenLevel { this.dragonParts = new Int2ObjectOpenHashMap(); this.tickTime = flag1; this.server = minecraftserver; @@ -2287,7 +2243,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda this.serverLevelData = iworlddataserver; ChunkGenerator chunkgenerator = worlddimension.generator(); // CraftBukkit start -@@ -732,6 +752,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -768,6 +788,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.chunkTaskScheduler = new io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler(this, io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.workerThreads); // Paper - rewrite chunk system this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system @@ -2295,10 +2251,10 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda } // Paper start -@@ -774,17 +795,17 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - } - // Paper end - optimise checkDespawn +@@ -802,17 +823,17 @@ public class ServerLevel extends Level implements WorldGenLevel { + } + + public void tick(BooleanSupplier shouldKeepTicking) { - ProfilerFiller gameprofilerfiller = this.getProfiler(); + //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur @@ -2317,14 +2273,14 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda // CraftBukkit start j = this.levelData.getDayTime() + 24000L; TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime()); -@@ -806,32 +827,32 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -834,32 +855,32 @@ public class ServerLevel extends Level implements WorldGenLevel { this.updateSkyBrightness(); this.tickTime(); - gameprofilerfiller.popPush("tickPending"); - timings.scheduledBlocks.startTiming(); // Paper + //gameprofilerfiller.popPush("tickPending"); // Purpur -+ //timings.scheduledBlocks.startTiming(); // Paper // Purpur ++ //timings.scheduledBlocks.startTiming(); // Paper // Purpur // Purpur if (!this.isDebug()) { j = this.getGameTime(); - gameprofilerfiller.push("blockTicks"); @@ -2337,7 +2293,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda + //gameprofilerfiller.pop(); // Purpur } - timings.scheduledBlocks.stopTiming(); // Paper -+ //timings.scheduledBlocks.stopTiming(); // Paper // Purpur ++ //timings.scheduledBlocks.stopTiming(); // Paper // Purpur // Purpur - gameprofilerfiller.popPush("raid"); - this.timings.raids.startTiming(); // Paper - timings @@ -2366,7 +2322,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players if (flag) { -@@ -839,25 +860,25 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -867,25 +888,25 @@ public class ServerLevel extends Level implements WorldGenLevel { } if (flag || this.emptyTime++ < 300) { @@ -2399,7 +2355,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda if (true || this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(entity.chunkPosition().toLong())) { // Paper - now always true if in the ticking list Entity entity1 = entity.getVehicle(); -@@ -869,7 +890,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -897,7 +918,7 @@ public class ServerLevel extends Level implements WorldGenLevel { entity.stopRiding(); } @@ -2408,7 +2364,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda // Pufferfish start - copied from this.guardEntityTick try { this.tickNonPassenger(entity); // Pufferfish - changed -@@ -884,20 +905,19 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -912,20 +933,20 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end } // Pufferfish end @@ -2431,10 +2387,11 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda + //gameprofilerfiller.push("entityManagement"); // Purpur //this.entityManager.tick(); // Paper - rewrite chunk system - gameprofilerfiller.pop(); ++ //gameprofilerfiller.pop(); // Purpur } @Override -@@ -915,6 +935,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -943,6 +964,13 @@ public class ServerLevel extends Level implements WorldGenLevel { this.serverLevelData.setGameTime(i); this.serverLevelData.getScheduledEvents().tick(this.server, i); if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { @@ -2448,14 +2405,14 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda this.setDayTime(this.levelData.getDayTime() + 1L); } -@@ -923,7 +950,21 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -951,7 +979,21 @@ public class ServerLevel extends Level implements WorldGenLevel { public void setDayTime(long timeOfDay) { this.serverLevelData.setDayTime(timeOfDay); + // Purpur start + this.preciseTime = timeOfDay; + this.forceTime = false; - } ++ } + public void setDayTime(double i) { + this.serverLevelData.setDayTime((long) i); + this.forceTime = true; @@ -2465,21 +2422,12 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda + // Purpur start + public boolean isForceTime() { + return this.forceTime; -+ } + } + // Purpur end public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) { Iterator iterator = this.customSpawners.iterator(); -@@ -948,7 +989,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - // Paper start - optimise random block ticking - private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos(); -- // private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(); // Pufferfish - moved to super -+ private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - moved to super // Purpur - dont break ABI - // Paper end - - private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Pufferfish -@@ -958,9 +999,9 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -985,9 +1027,9 @@ public class ServerLevel extends Level implements WorldGenLevel { boolean flag = this.isRaining(); int j = chunkcoordintpair.getMinBlockX(); int k = chunkcoordintpair.getMinBlockZ(); @@ -2490,8 +2438,8 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda + //gameprofilerfiller.push("thunder"); // Purpur final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Pufferfish - replace random with shouldDoLightning -@@ -970,10 +1011,18 @@ public class ServerLevel extends Level implements WorldGenLevel { + if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder +@@ -998,10 +1040,18 @@ public class ServerLevel extends Level implements WorldGenLevel { boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01D) && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper if (flag1) { @@ -2512,38 +2460,38 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); this.addFreshEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit -@@ -990,7 +1039,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1018,7 +1068,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } } - gameprofilerfiller.popPush("iceandsnow"); + //gameprofilerfiller.popPush("iceandsnow"); // Purpur - int l; - int i1; -@@ -1042,8 +1091,8 @@ public class ServerLevel extends Level implements WorldGenLevel { - } + if (!this.paperConfig().environment.disableIceAndSnow) { // Paper + for (int l = 0; l < randomTickSpeed; ++l) { +@@ -1030,8 +1080,8 @@ public class ServerLevel extends Level implements WorldGenLevel { + } // Paper // Paper start - optimise random block ticking -- gameprofilerfiller.popPush("randomTick"); +- gameprofilerfiller.popPush("tickBlocks"); - timings.chunkTicksBlocks.startTiming(); // Paper -+ //gameprofilerfiller.popPush("randomTick"); // Purpur ++ //gameprofilerfiller.popPush("tickBlocks"); // Purpur + //timings.chunkTicksBlocks.startTiming(); // Paper // Purpur if (randomTickSpeed > 0) { LevelChunkSection[] sections = chunk.getSections(); - int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); -@@ -1077,8 +1126,8 @@ public class ServerLevel extends Level implements WorldGenLevel { - } + final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); +@@ -1064,8 +1114,8 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper end - optimise random block ticking + - timings.chunkTicksBlocks.stopTiming(); // Paper - gameprofilerfiller.pop(); + //timings.chunkTicksBlocks.stopTiming(); // Paper // Purpur + //gameprofilerfiller.pop(); // Purpur } - public Optional findLightningRod(BlockPos pos) { -@@ -1086,7 +1135,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + private void tickIceAndSnow(boolean raining, BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) { // Paper - optimise chunk ticking +@@ -1118,7 +1168,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return holder.is(PoiTypes.LIGHTNING_ROD); }, (blockposition1) -> { return blockposition1.getY() == this.getHeight(Heightmap.Types.WORLD_SURFACE, blockposition1.getX(), blockposition1.getZ()) - 1; @@ -2552,7 +2500,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda return optional.map((blockposition1) -> { return blockposition1.above(1); -@@ -1135,11 +1184,27 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1167,11 +1217,27 @@ public class ServerLevel extends Level implements WorldGenLevel { if (this.canSleepThroughNights()) { if (!this.getServer().isSingleplayer() || this.getServer().isPublished()) { int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); @@ -2581,7 +2529,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda ichatmutablecomponent = Component.translatable("sleep.players_sleeping", this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(i)); } -@@ -1278,6 +1343,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1310,6 +1376,7 @@ public class ServerLevel extends Level implements WorldGenLevel { private void resetWeatherCycle() { // CraftBukkit start @@ -2589,7 +2537,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night // If we stop due to everyone sleeping we should reset the weather duration to some other random value. // Not that everyone ever manages to get the whole server to sleep at the same time.... -@@ -1285,6 +1351,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1317,6 +1384,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.serverLevelData.setRainTime(0); } // CraftBukkit end @@ -2597,7 +2545,16 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda this.serverLevelData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night // CraftBukkit start // If we stop due to everyone sleeping we should reset the weather duration to some other random value. -@@ -1352,24 +1419,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1373,7 +1441,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + // Paper end - log detailed entity tick information + ++TimingHistory.entityTicks; // Paper - timings + // Spigot start +- co.aikar.timings.Timing timer; // Paper ++ //co.aikar.timings.Timing timer; // Paper // Purpur + /*if (!org.spigotmc.ActivationRange.checkIfActive(entity)) { // Paper - comment out - EAR 2, reimplement below + entity.tickCount++; + timer = entity.getType().inactiveTickTimer.startTiming(); try { // Paper - timings +@@ -1384,24 +1452,24 @@ public class ServerLevel extends Level implements WorldGenLevel { // Spigot end // Paper start- timings final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); @@ -2608,16 +2565,15 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda // Paper end - timings entity.setOldPosAndRot(); - ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur ++ //ProfilerFiller gameprofilerfiller = this.getProfiler(); ++entity.tickCount; - this.getProfiler().push(() -> { + /*this.getProfiler().push(() -> { // Purpur return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); -- }); + }); - gameprofilerfiller.incrementCounter("tickNonPassenger"); -+ });*/ // Purpur -+ //gameprofilerfiller.incrementCounter("tickNonPassenger"); // Purpur ++ gameprofilerfiller.incrementCounter("tickNonPassenger");*/ // Purpur if (isActive) { // Paper - EAR 2 TimingHistory.activatedEntityTicks++; entity.tick(); @@ -2630,7 +2586,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda Iterator iterator = entity.getPassengers().iterator(); while (iterator.hasNext()) { -@@ -1392,17 +1459,17 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1424,17 +1492,17 @@ public class ServerLevel extends Level implements WorldGenLevel { if (passenger instanceof Player || this.entityTickList.contains(passenger)) { // Paper - EAR 2 final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger); @@ -2647,14 +2603,13 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda - gameprofilerfiller.push(() -> { + /*gameprofilerfiller.push(() -> { // Purpur return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString(); -- }); + }); - gameprofilerfiller.incrementCounter("tickPassenger"); -+ });*/ // Purpur -+ //gameprofilerfiller.incrementCounter("tickPassenger"); // Purpur ++ gameprofilerfiller.incrementCounter("tickPassenger");*/ // Purpur // Paper start - EAR 2 if (isActive) { passenger.rideTick(); -@@ -1414,7 +1481,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1446,7 +1514,7 @@ public class ServerLevel extends Level implements WorldGenLevel { vehicle.positionRider(passenger); } // Paper end - EAR 2 @@ -2663,7 +2618,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda Iterator iterator = passenger.getPassengers().iterator(); while (iterator.hasNext()) { -@@ -1423,7 +1490,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1455,7 +1523,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.tickPassenger(passenger, entity2); } @@ -2672,7 +2627,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda } } else { passenger.stopRiding(); -@@ -1443,14 +1510,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1475,14 +1543,14 @@ public class ServerLevel extends Level implements WorldGenLevel { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); } @@ -2690,7 +2645,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda // Copied from save() // CraftBukkit start - moved from MinecraftServer.saveChunks -@@ -1462,7 +1529,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1494,7 +1562,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); } // CraftBukkit end @@ -2699,16 +2654,16 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda } // Paper end -@@ -1476,7 +1543,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1508,7 +1576,7 @@ public class ServerLevel extends Level implements WorldGenLevel { if (!savingDisabled) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit - try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper -+ //try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper // Purpur // Purpur ++ //try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper // Purpur if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -1486,11 +1553,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1518,11 +1586,11 @@ public class ServerLevel extends Level implements WorldGenLevel { progressListener.progressStage(Component.translatable("menu.savingChunks")); } @@ -2723,7 +2678,7 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda // Paper - rewrite chunk system - entity saving moved into ChunkHolder } else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system -@@ -2769,7 +2836,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2808,7 +2876,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Spigot Start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message // Paper start @@ -2733,30 +2688,21 @@ index eac31c3fcc9161711328588ac852fcae1116d8ef..221d1d0e1b4b46de6ebca5faac09bbda } // Paper end diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248947e21a4 100644 +index d4aec99cac3f83d764e21946cc904c00e084704e..99cf8ce63316e127a5ee84cdd96df80d440dc0c3 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -278,6 +278,11 @@ public class ServerPlayer extends Player { +@@ -273,6 +273,10 @@ public class ServerPlayer extends Player { public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event + public boolean purpurClient = false; // Purpur -+ public boolean acceptingResourcePack = false; // Purpur -+ private boolean ramBar = false; // Purpur + private boolean tpsBar = false; // Purpur + private boolean compassBar = false; // Purpur ++ private boolean ramBar = false; // Purpur + // Paper start - replace player chunk loader private final java.util.concurrent.atomic.AtomicReference viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); - public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; -@@ -418,6 +423,7 @@ public class ServerPlayer extends Player { - this.bukkitPickUpLoot = true; - this.maxHealthCache = this.getMaxHealth(); - this.cachedSingleMobDistanceMap = new com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper -+ this.spawnInvulnerableTime = world.purpurConfig.playerSpawnInvulnerableTicks; // Purpur - } - - // Yes, this doesn't match Vanilla, but it's the best we can do for now. -@@ -557,6 +563,9 @@ public class ServerPlayer extends Player { +@@ -560,6 +564,9 @@ public class ServerPlayer extends Player { } } @@ -2766,7 +2712,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 } @Override -@@ -623,6 +632,9 @@ public class ServerPlayer extends Player { +@@ -626,6 +633,9 @@ public class ServerPlayer extends Player { } this.getBukkitEntity().setExtraData(nbt); // CraftBukkit @@ -2776,7 +2722,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 } // CraftBukkit start - World fallback code, either respawn location or global spawn -@@ -751,6 +763,15 @@ public class ServerPlayer extends Player { +@@ -754,6 +764,15 @@ public class ServerPlayer extends Player { this.trackStartFallingPosition(); this.trackEnteredOrExitedLavaOnVehicle(); this.advancements.flushDirty(this); @@ -2792,7 +2738,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 } public void doTick() { -@@ -989,6 +1010,7 @@ public class ServerPlayer extends Player { +@@ -992,6 +1011,7 @@ public class ServerPlayer extends Player { })); Team scoreboardteambase = this.getTeam(); @@ -2800,18 +2746,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != Team.Visibility.ALWAYS) { if (scoreboardteambase.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) { this.server.getPlayerList().broadcastSystemToTeam(this, ichatbasecomponent); -@@ -1090,14 +1112,30 @@ public class ServerPlayer extends Player { - - } - -+ // Purpur start -+ public boolean isSpawnInvulnerable() { -+ return spawnInvulnerableTime > 0 || frozen; -+ } -+ // Purpur end -+ - @Override - public boolean hurt(DamageSource source, float amount) { +@@ -1098,6 +1118,16 @@ public class ServerPlayer extends Player { if (this.isInvulnerableTo(source)) { return false; } else { @@ -2827,12 +2762,8 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 + // Purpur end boolean flag = this.server.isDedicatedServer() && this.isPvpAllowed() && source.is(DamageTypeTags.IS_FALL); -- if (!flag && this.spawnInvulnerableTime > 0 && !source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -+ if (!flag && isSpawnInvulnerable() && !source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { // Purpur - return false; - } else { - Entity entity = source.getEntity(); -@@ -1206,7 +1244,7 @@ public class ServerPlayer extends Player { + if (!flag && this.spawnInvulnerableTime > 0 && !source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { +@@ -1209,7 +1239,7 @@ public class ServerPlayer extends Player { PortalInfo shapedetectorshape = this.findDimensionEntryPoint(worldserver); if (shapedetectorshape != null) { @@ -2841,7 +2772,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 worldserver = shapedetectorshape.world; // CraftBukkit if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event if (resourcekey == LevelStem.OVERWORLD && worldserver.getTypeKey() == LevelStem.NETHER) { // CraftBukkit -@@ -1229,8 +1267,8 @@ public class ServerPlayer extends Player { +@@ -1232,8 +1262,8 @@ public class ServerPlayer extends Player { worldserver = ((CraftWorld) exit.getWorld()).getHandle(); // CraftBukkit end @@ -2852,7 +2783,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 if (true) { // CraftBukkit this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds -@@ -1241,13 +1279,14 @@ public class ServerPlayer extends Player { +@@ -1244,13 +1274,14 @@ public class ServerPlayer extends Player { playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -2868,15 +2799,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 this.triggerDimensionChangeTriggers(worldserver1); this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); playerlist.sendLevelInfo(this, worldserver); -@@ -1276,6 +1315,7 @@ public class ServerPlayer extends Player { - } - // Paper end - -+ this.spawnInvulnerableTime = worldserver.purpurConfig.playerSpawnInvulnerableTicks; // Purpur - return this; - } - } -@@ -1397,7 +1437,7 @@ public class ServerPlayer extends Player { +@@ -1400,7 +1431,7 @@ public class ServerPlayer extends Player { return entitymonster.isPreventingPlayerRest(this); }); @@ -2885,7 +2808,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 return Either.left(Player.BedSleepingProblem.NOT_SAFE); } } -@@ -1437,7 +1477,19 @@ public class ServerPlayer extends Player { +@@ -1440,7 +1471,19 @@ public class ServerPlayer extends Player { }); if (!this.serverLevel().canSleepThroughNights()) { @@ -2906,7 +2829,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 } ((ServerLevel) this.level()).updateSleepingPlayerList(); -@@ -1534,6 +1586,7 @@ public class ServerPlayer extends Player { +@@ -1537,6 +1580,7 @@ public class ServerPlayer extends Player { @Override public void openTextEdit(SignBlockEntity sign, boolean front) { @@ -2914,7 +2837,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 this.connection.send(new ClientboundBlockUpdatePacket(this.level(), sign.getBlockPos())); this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front)); } -@@ -1779,6 +1832,26 @@ public class ServerPlayer extends Player { +@@ -1782,6 +1826,26 @@ public class ServerPlayer extends Player { this.lastSentExp = -1; // CraftBukkit - Added to reset } @@ -2941,21 +2864,13 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 @Override public void displayClientMessage(Component message, boolean overlay) { this.sendSystemMessage(message, overlay); -@@ -2078,6 +2151,7 @@ public class ServerPlayer extends Player { - } - - public void sendTexturePack(String url, String hash, boolean required, @Nullable Component resourcePackPrompt) { -+ this.acceptingResourcePack = true; // Purpur - this.connection.send(new ClientboundResourcePackPacket(url, hash, required, resourcePackPrompt)); - } - -@@ -2092,8 +2166,68 @@ public class ServerPlayer extends Player { +@@ -2098,8 +2162,68 @@ public class ServerPlayer extends Player { public void resetLastActionTime() { this.lastActionTime = Util.getMillis(); + this.setAfk(false); // Purpur -+ } -+ + } + + // Purpur Start + private boolean isAfk = false; + @@ -3007,8 +2922,8 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 + @Override + public boolean isAfk() { + return this.isAfk; - } - ++ } ++ + @Override + public boolean canBeCollidedWith() { + return !this.isAfk() && super.canBeCollidedWith(); @@ -3018,26 +2933,7 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 public ServerStatsCounter getStats() { return this.stats; } -@@ -2605,9 +2739,17 @@ public class ServerPlayer extends Player { - - @Override - public boolean isImmobile() { -- return super.isImmobile() || (this.connection != null && this.connection.isDisconnected()); // Paper -+ return super.isImmobile() || frozen || (this.connection != null && this.connection.isDisconnected()); // Paper // Purpur - } - -+ // Purpur start -+ private boolean frozen = false; -+ -+ public void setFrozen(boolean frozen) { -+ this.frozen = frozen; -+ } -+ // Purpur end -+ - @Override - public Scoreboard getScoreboard() { - return this.getBukkitEntity().getScoreboard().getHandle(); -@@ -2655,4 +2797,50 @@ public class ServerPlayer extends Player { +@@ -2647,4 +2771,50 @@ public class ServerPlayer extends Player { return (CraftPlayer) super.getBukkitEntity(); } // CraftBukkit end @@ -3063,14 +2959,6 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 + } + } + -+ public boolean ramBar() { -+ return this.ramBar; -+ } -+ -+ public void ramBar(boolean ramBar) { -+ this.ramBar = ramBar; -+ } -+ + public boolean tpsBar() { + return this.tpsBar; + } @@ -3086,10 +2974,18 @@ index b382da838acc04a1c5d89064b4fa43bcdd38ae71..0249eeb3937cf48cea13846a7e39b248 + public void compassBar(boolean compassBar) { + this.compassBar = compassBar; + } ++ ++ public boolean ramBar() { ++ return this.ramBar; ++ } ++ ++ public void ramBar(boolean ramBar) { ++ this.ramBar = ramBar; ++ } + // Purpur end } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 618ab9a2903f6d4139acd4aaa2e6db0a26e88ba9..f3bac087856f420aa6c14707e90288f4962967bf 100644 +index b2c2bd5ec0afd479973f7237a5c610f21231c505..3250c21eded7872336d349a7a93c2c17160db723 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -398,6 +398,7 @@ public class ServerPlayerGameMode { @@ -3157,43 +3053,59 @@ index 877498729c66de9aa6a27c9148f7494d7895615c..acd7468ee3c86d3456e96e4ec3d7e6a4 if (!hasSetFarWarned) { Util.logAndPauseIfInIde("Detected setBlock in a far chunk [" + i + ", " + j + "], pos: " + pos + ", status: " + this.generatingStatus + (this.currentlyGenerating == null ? "" : ", currently generating: " + (String) this.currentlyGenerating.get())); hasSetFarWarned = true; -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fef057d09e 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -265,6 +265,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private long keepAliveTime = Util.getMillis(); +diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +index 231150bac0ae61e9722c2cdfd70d6f7d254681e4..6f6228edfe77668552a40a814ab3cebd74c4cb5a 100644 +--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -51,11 +51,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + private long keepAliveTime = Util.getMillis(); // Paper private boolean keepAlivePending; private long keepAliveChallenge; + private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur - // CraftBukkit start - multithreaded fields - private final AtomicInteger chatSpamTickCount = new AtomicInteger(); - private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits -@@ -342,6 +343,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private boolean justTeleported = false; - private boolean hasMoved; // Spigot + private int latency; + private volatile boolean suspendFlushingOnServerThread = false; + private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit + private @Nullable String clientBrandName = null; // Paper - Brand name + protected static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support ++ protected static final ResourceLocation PURPUR_CLIENT = new ResourceLocation("purpur", "client"); // Purpur + + public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit + this.server = minecraftserver; +@@ -91,6 +93,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack -+ // Purpur start -+ private final com.google.common.cache.LoadingCache kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder() -+ .maximumSize(1000) -+ .expireAfterWrite(1, java.util.concurrent.TimeUnit.MINUTES) -+ .build( -+ new com.google.common.cache.CacheLoader<>() { -+ @Override -+ public Boolean load(CraftPlayer player) { -+ return player.hasPermission("purpur.bypassIdleKick"); -+ } -+ } -+ ); -+ // Purpur end -+ - public CraftPlayer getCraftPlayer() { - return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); + @Override + public void handleKeepAlive(ServerboundKeepAlivePacket packet) { ++ // Purpur start ++ if (org.purpurmc.purpur.PurpurConfig.useAlternateKeepAlive) { ++ long id = packet.getId(); ++ if (keepAlives.size() > 0 && keepAlives.contains(id)) { ++ int ping = (int) (Util.getMillis() - id); ++ this.latency = (this.latency * 3 + ping) / 4; ++ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest ++ } ++ } else ++ // Purpur end + //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread + if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { + int i = (int) (Util.getMillis() - this.keepAliveTime); +@@ -138,6 +150,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex); + this.disconnect("Invalid payload REGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause + } ++ // Purpur start ++ } else if (identifier.equals(PURPUR_CLIENT)) { ++ try { ++ player.purpurClient = true; ++ } catch (Exception ignore) { ++ } ++ // Purpur end + } else if (identifier.equals(CUSTOM_UNREGISTER)) { + try { + String channels = payload.toString(com.google.common.base.Charsets.UTF_8); +@@ -198,12 +217,27 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } -@@ -397,12 +412,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - this.aboveGroundVehicleTickCount = 0; - } + protected void keepConnectionAlive() { - this.server.getProfiler().push("keepAlive"); + //this.server.getProfiler().push("keepAlive"); // Purpur // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings @@ -3206,7 +3118,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe + if (elapsedTime >= 1000L) { // 1 second + if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) { + LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); -+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); ++ disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); + } else { + keepAliveTime = currentTime; // hijack this field for 1 second intervals + keepAlives.add(currentTime); // currentTime is ID @@ -3219,16 +3131,41 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe if (this.keepAlivePending) { if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info -@@ -418,7 +448,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -219,7 +253,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } // Paper end - this.server.getProfiler().pop(); + //this.server.getProfiler().pop(); // Purpur - // CraftBukkit start - for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; - if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable -@@ -435,6 +465,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + } + + public void suspendFlushing() { +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 501cb7450cd28ca487c1522ada4a571e74d3258c..e001787e40cc0a843e65b36582e9d6593d0fff0e 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -323,6 +323,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + private boolean hasMoved; // Spigot + // CraftBukkit end + ++ // Purpur start ++ private final com.google.common.cache.LoadingCache kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder() ++ .maximumSize(1000) ++ .expireAfterWrite(1, java.util.concurrent.TimeUnit.MINUTES) ++ .build( ++ new com.google.common.cache.CacheLoader<>() { ++ @Override ++ public Boolean load(CraftPlayer player) { ++ return player.hasPermission("purpur.bypassIdleKick"); ++ } ++ } ++ ); ++ // Purpur end ++ + @Override + public void tick() { + if (this.ackBlockChangesUpTo > -1) { +@@ -390,6 +404,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits. @@ -3241,7 +3178,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause } -@@ -753,6 +789,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -638,6 +658,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.lastYaw = to.getYaw(); this.lastPitch = to.getPitch(); @@ -3250,7 +3187,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe // Skip the first time we do this if (true) { // Spigot - don't skip any move events Location oldTo = to.clone(); -@@ -829,6 +867,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -714,6 +736,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause @@ -3258,7 +3195,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe return; } -@@ -1241,10 +1280,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1126,10 +1149,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl int maxBookPageSize = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax; double multiplier = Math.max(0.3D, Math.min(1D, io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier)); long byteAllowed = maxBookPageSize; @@ -3271,7 +3208,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause return; } -@@ -1268,6 +1309,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1153,6 +1178,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (byteTotal > byteAllowed) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); @@ -3279,7 +3216,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause return; } -@@ -1321,13 +1363,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1206,13 +1232,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl itemstack1.setTag(nbttagcompound.copy()); } @@ -3299,7 +3236,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe this.updateBookPages(pages, (s) -> { return Component.Serializer.toJson(Component.literal(s)); -@@ -1339,10 +1384,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1224,10 +1253,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private void updateBookPages(List list, UnaryOperator unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit ListTag nbttaglist = new ListTag(); @@ -3315,7 +3252,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe Objects.requireNonNull(nbttaglist); stream.forEach(nbttaglist::add); -@@ -1352,11 +1400,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1237,11 +1269,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl for (int j = list.size(); i < j; ++i) { FilteredText filteredtext = (FilteredText) list.get(i); @@ -3329,7 +3266,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe } } -@@ -1369,6 +1417,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1254,6 +1286,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.getInventory().setItem(slot, CraftEventFactory.handleEditBookEvent(player, slot, handItem, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent) } @@ -3346,7 +3283,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe @Override public void handleEntityTagQuery(ServerboundEntityTagQuery packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); -@@ -1398,8 +1456,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1283,8 +1325,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -3364,7 +3301,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe } else { ServerLevel worldserver = this.player.serverLevel(); -@@ -1582,7 +1648,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1467,7 +1517,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (!event.isAllowed()) { flag2 = true; // Paper - diff on change, this should be moved wrongly if (event.getLogWarning()) @@ -3373,7 +3310,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe } // Paper end } -@@ -1644,6 +1710,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1529,6 +1579,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.lastYaw = to.getYaw(); this.lastPitch = to.getPitch(); @@ -3382,7 +3319,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe // Skip the first time we do this if (from.getX() != Double.MAX_VALUE) { Location oldTo = to.clone(); -@@ -1682,6 +1750,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1567,6 +1619,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.resetFallDistance(); } @@ -3396,8 +3333,8 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe this.player.checkMovementStatistics(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5); this.lastGoodX = this.player.getX(); this.lastGoodY = this.player.getY(); -@@ -1726,6 +1801,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - } +@@ -1618,6 +1677,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + return false; } // Paper end - optimise out extra getCubes + @@ -3410,7 +3347,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe private boolean isPlayerCollidingWithAnythingNew(LevelReader world, AABB box, double newX, double newY, double newZ) { AABB axisalignedbb1 = this.player.getBoundingBox().move(newX - this.player.getX(), newY - this.player.getY(), newZ - this.player.getZ()); Iterable iterable = world.getCollisions(this.player, axisalignedbb1.deflate(9.999999747378752E-6D)); -@@ -2071,6 +2153,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1963,6 +2029,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl boolean cancelled; if (movingobjectposition == null || movingobjectposition.getType() != HitResult.Type.BLOCK) { @@ -3418,29 +3355,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); cancelled = event.useItemInHand() == Event.Result.DENY; } else { -@@ -2125,12 +2208,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - @Override - public void handleResourcePackResponse(ServerboundResourcePackPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); -+ // Purpur start -+ if (player.level().purpurConfig.playerInvulnerableWhileAcceptingResourcePack && !this.player.acceptingResourcePack) { -+ ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack packet exploitation attempt", this.player.getName()); -+ this.disconnect(Component.translatable("multiplayer.texturePrompt.failure.line1"), org.bukkit.event.player.PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION); // "Server resource pack couldn't be applied" -+ return; -+ } -+ // Purpur end - if (packet.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) { - ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getGameProfile().getName()); // Paper - Don't print component in resource pack rejection message - this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"), org.bukkit.event.player.PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION); // Paper - add cause - } - // Paper start - PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()]; -+ if (player.level().purpurConfig.playerInvulnerableWhileAcceptingResourcePack) player.setFrozen(packStatus == PlayerResourcePackStatusEvent.Status.ACCEPTED); // Purpur -+ this.player.acceptingResourcePack = packStatus == PlayerResourcePackStatusEvent.Status.ACCEPTED; // Purpur - player.getBukkitEntity().setResourcePackStatus(packStatus); - this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit - // Paper end -@@ -2427,7 +2519,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2280,7 +2347,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl do { instant1 = (Instant) this.lastChatTimeStamp.get(); if (timestamp.isBefore(instant1)) { @@ -3449,7 +3364,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe } } while (!this.lastChatTimeStamp.compareAndSet(instant1, timestamp)); -@@ -2537,7 +2629,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2390,7 +2457,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl public void handleCommand(String s) { // Paper - private -> public org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher @@ -3458,7 +3373,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); -@@ -2547,7 +2639,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2400,7 +2467,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -3467,7 +3382,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe return; } -@@ -2560,7 +2652,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2413,7 +2480,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl java.util.logging.Logger.getLogger(ServerGamePacketListenerImpl.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); return; } finally { @@ -3476,7 +3391,7 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe } } // CraftBukkit end -@@ -2836,6 +2928,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2700,6 +2767,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl AABB axisalignedbb = entity.getBoundingBox(); if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { @@ -3484,16 +3399,16 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe packet.dispatch(new ServerboundInteractPacket.Handler() { private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand); -@@ -2849,6 +2942,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2713,6 +2781,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event); + cserver.getPluginManager().callEvent(event); + player.processClick(enumhand); // Purpur + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { entity.getEntityData().resendPossiblyDesyncedEntity(player); // Paper - The entire mob gets deleted, so resend it. -@@ -3429,6 +3524,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3293,6 +3363,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } } } @@ -3506,50 +3421,11 @@ index 6cafc20ce006872bedd28a34db11204c3c1fef58..255b422078880b46dfa6f5140f6c92fe boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); -@@ -3524,6 +3625,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - - @Override - public void handleKeepAlive(ServerboundKeepAlivePacket packet) { -+ // Purpur start -+ if (org.purpurmc.purpur.PurpurConfig.useAlternateKeepAlive) { -+ long id = packet.getId(); -+ if (keepAlives.size() > 0 && keepAlives.contains(id)) { -+ int ping = (int) (Util.getMillis() - id); -+ player.latency = (player.latency * 3 + ping) / 4; -+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest -+ } -+ } else -+ // Purpur end - //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread - if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { - int i = (int) (Util.getMillis() - this.keepAliveTime); -@@ -3574,6 +3685,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister"); - - private static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support -+ private static final ResourceLocation PURPUR_CLIENT = new ResourceLocation("purpur", "client"); // Purpur - - @Override - public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { -@@ -3598,6 +3710,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t unregister custom payload", ex); - this.disconnect("Invalid payload UNREGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause - } -+ // Purpur start -+ } else if (packet.identifier.equals(PURPUR_CLIENT)) { -+ try { -+ player.purpurClient = true; -+ } catch (Exception ignore) { -+ } -+ // Purpur end - } else { - try { - byte[] data = new byte[packet.data.readableBytes()]; diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 878001928327d92423d5f7f6d5ce8772d6fa477f..01d5fa265fb2818465b5a71a2e2efeec751a7a05 100644 +index 0c57a06b785dc024ee05ac1291a56f08624e1e56..b875f4af9dcb45bcad0ee59a958442ba673268fe 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -221,6 +221,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -142,6 +142,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, return false; } @@ -3558,13 +3434,13 @@ index 878001928327d92423d5f7f6d5ce8772d6fa477f..01d5fa265fb2818465b5a71a2e2efeec for (int i = 0, len = in.length(); i < len; ++i) { char c = in.charAt(i); -@@ -340,7 +342,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - ServerLoginPacketListenerImpl.this.gameProfile = gameprofile; - ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; +@@ -297,7 +299,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!"); + ServerLoginPacketListenerImpl.this.startClientVerification(ServerLoginPacketListenerImpl.this.createOfflineProfile(s1)); // Spigot } else { - ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); + ServerLoginPacketListenerImpl.this.disconnect(org.purpurmc.purpur.PurpurConfig.unverifiedUsername.equals("default") ? Component.translatable("multiplayer.disconnect.unverified_username") : io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.unverifiedUsername))); // Purpur - ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", gameprofile.getName()); + ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", s1); } } catch (AuthenticationUnavailableException authenticationunavailableexception) { diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java @@ -3600,10 +3476,10 @@ index 9ddbfcf80d9a381dace78a62880f85a4d767e0eb..7383c7d3820dce06108eaafd236a7c6c } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfdaffbb7b2 100644 +index 48d1444fbad1c57738807d0128b94160a5a17a4d..5c38df8170033dbfee267520991a3cc3285d219e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -484,6 +484,7 @@ public abstract class PlayerList { +@@ -467,6 +467,7 @@ public abstract class PlayerList { scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); } // Paper end @@ -3611,7 +3487,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd // CraftBukkit - Moved from above, added world PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); } -@@ -593,6 +594,7 @@ public abstract class PlayerList { +@@ -580,6 +581,7 @@ public abstract class PlayerList { } public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) { // Paper end @@ -3619,8 +3495,8 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd ServerLevel worldserver = entityplayer.serverLevel(); entityplayer.awardStat(Stats.LEAVE_GAME); -@@ -747,7 +749,7 @@ public abstract class PlayerList { - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure +@@ -734,7 +736,7 @@ public abstract class PlayerList { + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure } else { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; - if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { @@ -3628,16 +3504,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } -@@ -985,6 +987,8 @@ public abstract class PlayerList { - } - // Paper end - -+ entityplayer1.spawnInvulnerableTime = entityplayer1.level().purpurConfig.playerSpawnInvulnerableTicks; // Purpur -+ - // CraftBukkit end - return entityplayer1; - } -@@ -1045,6 +1049,20 @@ public abstract class PlayerList { +@@ -1039,6 +1041,20 @@ public abstract class PlayerList { } // CraftBukkit end @@ -3658,7 +3525,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd public void broadcastAll(Packet packet, ResourceKey dimension) { Iterator iterator = this.players.iterator(); -@@ -1148,6 +1166,7 @@ public abstract class PlayerList { +@@ -1142,6 +1158,7 @@ public abstract class PlayerList { } else { b0 = (byte) (24 + permissionLevel); } @@ -3666,7 +3533,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd player.connection.send(new ClientboundEntityEventPacket(player, b0)); } -@@ -1156,6 +1175,27 @@ public abstract class PlayerList { +@@ -1150,6 +1167,27 @@ public abstract class PlayerList { player.getBukkitEntity().recalculatePermissions(); // CraftBukkit this.server.getCommands().sendCommands(player); } // Paper @@ -3694,7 +3561,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd } public boolean isWhiteListed(GameProfile profile) { -@@ -1217,7 +1257,7 @@ public abstract class PlayerList { +@@ -1211,7 +1249,7 @@ public abstract class PlayerList { public void saveAll(int interval) { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main @@ -3703,7 +3570,7 @@ index f097ec5b4e3ad6b1a7c464a8cff4f8b2568fcf4f..824f31b68b38f2f8642fb9d59a123cfd int numSaved = 0; long now = MinecraftServer.currentTick; for (int i = 0; i < this.players.size(); ++i) { -@@ -1228,7 +1268,7 @@ public abstract class PlayerList { +@@ -1222,7 +1260,7 @@ public abstract class PlayerList { } // Paper end } @@ -3735,17 +3602,17 @@ index 823efad652d8ff9e96b99375b102fef6f017716e..caa8a69bde0c212c36dd990a67836ac2 } // CraftBukkit start diff --git a/src/main/java/net/minecraft/stats/ServerRecipeBook.java b/src/main/java/net/minecraft/stats/ServerRecipeBook.java -index ea29e07a105f3ba6a878bdccf36e7eaf66280280..d5dce6c8d85938d61a57a78f82381d26daf8f87a 100644 +index 4103ddf16164e3992fef0765d368282572537e29..a0cb49233b1dbf53ce9d1bcc52b8967829d0530e 100644 --- a/src/main/java/net/minecraft/stats/ServerRecipeBook.java +++ b/src/main/java/net/minecraft/stats/ServerRecipeBook.java @@ -125,6 +125,7 @@ public class ServerRecipeBook extends RecipeBook { - Optional> optional = recipeManager.byKey(minecraftkey); + Optional> optional = recipeManager.byKey(minecraftkey); - if (!optional.isPresent()) { + if (optional.isEmpty()) { + if (!org.purpurmc.purpur.PurpurConfig.loggerSuppressUnrecognizedRecipeErrors) // Purpur ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", minecraftkey); } else { - handler.accept((Recipe) optional.get()); + handler.accept((RecipeHolder) optional.get()); diff --git a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java b/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java index 196c7331138fee2822c76aacd136f9da040e0049..c6c30d99399c5cde2b0ec2f320d81d952b422d78 100644 --- a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java @@ -3930,6 +3797,34 @@ index 2e6e8eac987c4ef6b2dcd3de592d8a51d2b29792..863343a87fe34d72f04af89d75268b47 } }; } +diff --git a/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java +index 48e7211e01691a677c52cf1f5982b0c179eaf83b..729ebd1b2433327de243d0168289e180a841f47c 100644 +--- a/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java ++++ b/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java +@@ -2,16 +2,23 @@ package net.minecraft.util.profiling.metrics.profiling; + + import net.minecraft.util.profiling.ProfilerFiller; + ++@Deprecated(forRemoval = true) + public interface MetricsRecorder { ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + void end(); + ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + void cancel(); + ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + void startTick(); + ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + boolean isRecording(); + ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + ProfilerFiller getProfiler(); + ++ @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur + void endTick(); + } diff --git a/src/main/java/net/minecraft/world/damagesource/CombatRules.java b/src/main/java/net/minecraft/world/damagesource/CombatRules.java index ccbfcef3e83b1bef364447657bfd08a92d615cf6..aa2331c6df4e79d4bb0add071a0b11d2a3a08b88 100644 --- a/src/main/java/net/minecraft/world/damagesource/CombatRules.java @@ -3950,7 +3845,7 @@ index ccbfcef3e83b1bef364447657bfd08a92d615cf6..aa2331c6df4e79d4bb0add071a0b11d2 } } diff --git a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java -index c12d7bacf2c54f268b1bc5e46250a083ca041415..45a1cbe958c1a626df97022afe22484f2b387233 100644 +index 9c99b2e365aacb8309f29acb9025faccd2c676b3..6e8d9be28c5908fb12c44c0ecb0e02180601371a 100644 --- a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java +++ b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java @@ -59,7 +59,7 @@ public class CombatTracker { @@ -4034,46 +3929,24 @@ index 4604f8b38460e9113e966889a679d4547f24aff6..4a5d2e263d2bbee96bde7012d3385fa3 + } + // Purpur end } -diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java -index 53cc6befb752affcfec65e18365f6d369448d407..01850fc596a85974287ff6750427186d21acac41 100644 ---- a/src/main/java/net/minecraft/world/effect/MobEffect.java -+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java -@@ -59,16 +59,16 @@ public class MobEffect { - public void applyEffectTick(LivingEntity entity, int amplifier) { - if (this == MobEffects.REGENERATION) { - if (entity.getHealth() < entity.getMaxHealth()) { -- entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit -+ entity.heal(entity.level().purpurConfig.entityHealthRegenAmount, RegainReason.MAGIC_REGEN); // CraftBukkit // Purpur - } - } else if (this == MobEffects.POISON) { -- if (entity.getHealth() > 1.0F) { -- entity.hurt(entity.damageSources().poison, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON -+ if (entity.getHealth() > entity.level().purpurConfig.entityMinimalHealthPoison) { // Purpur -+ entity.hurt(entity.damageSources().poison, entity.level().purpurConfig.entityPoisonDegenerationAmount); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON // Purpur - } - } else if (this == MobEffects.WITHER) { -- entity.hurt(entity.damageSources().wither(), 1.0F); -+ entity.hurt(entity.damageSources().wither(), entity.level().purpurConfig.entityWitherDegenerationAmount); // Purpur - } else if (this == MobEffects.HUNGER && entity instanceof Player) { -- ((Player) entity).causeFoodExhaustion(0.005F * (float) (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent -+ ((Player) entity).causeFoodExhaustion(entity.level().purpurConfig.humanHungerExhaustionAmount * (float) (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent // Purpur - } else if (this == MobEffects.SATURATION && entity instanceof Player) { - if (!entity.level().isClientSide) { - // CraftBukkit start -@@ -76,7 +76,7 @@ public class MobEffect { - int oldFoodLevel = entityhuman.getFoodData().foodLevel; - org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, amplifier + 1 + oldFoodLevel); - if (!event.isCancelled()) { -- entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); -+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, entity.level().purpurConfig.humanSaturationRegenAmount); // Purpur - } +diff --git a/src/main/java/net/minecraft/world/effect/HungerMobEffect.java b/src/main/java/net/minecraft/world/effect/HungerMobEffect.java +index 3aad6bd0a1fb7bb3f9b7dab2c10c875864900750..31bd845130e363dd11c225dfd1e9dd896aea8aac 100644 +--- a/src/main/java/net/minecraft/world/effect/HungerMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/HungerMobEffect.java +@@ -15,7 +15,7 @@ class HungerMobEffect extends MobEffect { + if (entity instanceof Player) { + Player entityhuman = (Player) entity; + +- entityhuman.causeFoodExhaustion(0.005F * (float) (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent ++ entityhuman.causeFoodExhaustion(entity.level().purpurConfig.humanHungerExhaustionAmount * (float) (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent // Purpur + } - ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate(); + } diff --git a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java -index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bdaef6e474 100644 +index 68e1b8271475996020af50b3b2cf04cd25aa6c85..4f2fcbcf90d6f5ee89e35c993a65cae6c5b7ed91 100644 --- a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java +++ b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java -@@ -14,6 +14,7 @@ import net.minecraft.util.ExtraCodecs; +@@ -16,6 +16,7 @@ import net.minecraft.util.ExtraCodecs; import net.minecraft.util.Mth; import net.minecraft.world.entity.LivingEntity; import org.slf4j.Logger; @@ -4081,7 +3954,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd public class MobEffectInstance implements Comparable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -25,6 +26,7 @@ public class MobEffectInstance implements Comparable { +@@ -35,6 +36,7 @@ public class MobEffectInstance implements Comparable { private boolean visible; private boolean showIcon; @Nullable @@ -4089,7 +3962,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd private MobEffectInstance hiddenEffect; private final Optional factorData; -@@ -44,17 +46,36 @@ public class MobEffectInstance implements Comparable { +@@ -54,17 +56,36 @@ public class MobEffectInstance implements Comparable { this(type, duration, amplifier, ambient, visible, visible); } @@ -4127,7 +4000,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd this.hiddenEffect = hiddenEffect; this.factorData = factorCalculationData; } -@@ -75,6 +96,7 @@ public class MobEffectInstance implements Comparable { +@@ -85,6 +106,7 @@ public class MobEffectInstance implements Comparable { this.ambient = that.ambient; this.visible = that.visible; this.showIcon = that.showIcon; @@ -4135,7 +4008,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd } public boolean update(MobEffectInstance that) { -@@ -120,6 +142,13 @@ public class MobEffectInstance implements Comparable { +@@ -129,6 +151,13 @@ public class MobEffectInstance implements Comparable { bl = true; } @@ -4149,7 +4022,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd return bl; } -@@ -163,6 +192,17 @@ public class MobEffectInstance implements Comparable { +@@ -172,6 +201,17 @@ public class MobEffectInstance implements Comparable { return this.showIcon; } @@ -4167,7 +4040,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd public boolean tick(LivingEntity entity, Runnable overwriteCallback) { if (this.hasRemainingDuration()) { int i = this.isInfiniteDuration() ? entity.tickCount : this.duration; -@@ -226,6 +266,12 @@ public class MobEffectInstance implements Comparable { +@@ -232,6 +272,12 @@ public class MobEffectInstance implements Comparable { string = string + ", Show Icon: false"; } @@ -4180,7 +4053,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd return string; } -@@ -241,7 +287,7 @@ public class MobEffectInstance implements Comparable { +@@ -247,7 +293,7 @@ public class MobEffectInstance implements Comparable { return false; } else { MobEffectInstance mobEffectInstance = (MobEffectInstance)object; @@ -4189,33 +4062,33 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd } } -@@ -265,6 +311,11 @@ public class MobEffectInstance implements Comparable { - nbt.putBoolean("Ambient", this.isAmbient()); - nbt.putBoolean("ShowParticles", this.isVisible()); - nbt.putBoolean("ShowIcon", this.showIcon()); +@@ -272,6 +318,11 @@ public class MobEffectInstance implements Comparable { + nbt.putBoolean("ambient", this.isAmbient()); + nbt.putBoolean("show_particles", this.isVisible()); + nbt.putBoolean("show_icon", this.showIcon()); + // Purpur start + if (this.key != null) { -+ nbt.putString("Key", this.key.toString()); ++ nbt.putString("key", this.key.toString()); + } + // Purpur end if (this.hiddenEffect != null) { CompoundTag compoundTag = new CompoundTag(); this.hiddenEffect.save(compoundTag); -@@ -299,6 +350,13 @@ public class MobEffectInstance implements Comparable { - bl3 = nbt.getBoolean("ShowIcon"); +@@ -306,6 +357,13 @@ public class MobEffectInstance implements Comparable { + bl3 = nbt.getBoolean("show_icon"); } + // Purpur start + NamespacedKey key = null; -+ if (nbt.contains("Key")) { -+ key = NamespacedKey.fromString(nbt.getString("Key")); ++ if (nbt.contains("key")) { ++ key = NamespacedKey.fromString(nbt.getString("key")); + } + // Purpur end + MobEffectInstance mobEffectInstance = null; - if (nbt.contains("HiddenEffect", 10)) { - mobEffectInstance = loadSpecifiedEffect(type, nbt.getCompound("HiddenEffect")); -@@ -311,7 +369,7 @@ public class MobEffectInstance implements Comparable { + if (nbt.contains("hidden_effect", 10)) { + mobEffectInstance = loadSpecifiedEffect(type, nbt.getCompound("hidden_effect")); +@@ -318,7 +376,7 @@ public class MobEffectInstance implements Comparable { optional = Optional.empty(); } @@ -4223,12 +4096,66 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd + return new MobEffectInstance(type, j, Math.max(i, 0), bl, bl2, bl3, mobEffectInstance, optional, key); // Purpur - add key } + @Override +diff --git a/src/main/java/net/minecraft/world/effect/PoisonMobEffect.java b/src/main/java/net/minecraft/world/effect/PoisonMobEffect.java +index f8a8b825d21a7223a9839abda20825702985b7ad..41a853cd0f7d9aaa3d23df1c49a30fb29f19d14e 100644 +--- a/src/main/java/net/minecraft/world/effect/PoisonMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/PoisonMobEffect.java +@@ -11,8 +11,8 @@ class PoisonMobEffect extends MobEffect { + @Override + public void applyEffectTick(LivingEntity entity, int amplifier) { + super.applyEffectTick(entity, amplifier); +- if (entity.getHealth() > 1.0F) { +- entity.hurt(entity.damageSources().poison, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON ++ if (entity.getHealth() > entity.level().purpurConfig.entityMinimalHealthPoison) { // Purpur ++ entity.hurt(entity.damageSources().poison, entity.level().purpurConfig.entityPoisonDegenerationAmount); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON // Purpur + } + + } +diff --git a/src/main/java/net/minecraft/world/effect/RegenerationMobEffect.java b/src/main/java/net/minecraft/world/effect/RegenerationMobEffect.java +index 551b20f86347aeca4824b7a424ad7de7c0ff072e..06bb4ad98aa9ca38b8d423681b1ad4b821f5e47d 100644 +--- a/src/main/java/net/minecraft/world/effect/RegenerationMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/RegenerationMobEffect.java +@@ -12,7 +12,7 @@ class RegenerationMobEffect extends MobEffect { + public void applyEffectTick(LivingEntity entity, int amplifier) { + super.applyEffectTick(entity, amplifier); + if (entity.getHealth() < entity.getMaxHealth()) { +- entity.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit ++ entity.heal(entity.level().purpurConfig.entityHealthRegenAmount, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit // Purpur + } + + } +diff --git a/src/main/java/net/minecraft/world/effect/SaturationMobEffect.java b/src/main/java/net/minecraft/world/effect/SaturationMobEffect.java +index b994ae09621934df2cdd6a83a7d8ecb44649fb16..c2b812c992db1ac9cd391da902c8d819a6ec2e6d 100644 +--- a/src/main/java/net/minecraft/world/effect/SaturationMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/SaturationMobEffect.java +@@ -23,7 +23,7 @@ class SaturationMobEffect extends InstantenousMobEffect { + int oldFoodLevel = entityhuman.getFoodData().foodLevel; + org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, amplifier + 1 + oldFoodLevel); + if (!event.isCancelled()) { +- entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); ++ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, entity.level().purpurConfig.humanSaturationRegenAmount); // Purpur + } + + ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate(); +diff --git a/src/main/java/net/minecraft/world/effect/WitherMobEffect.java b/src/main/java/net/minecraft/world/effect/WitherMobEffect.java +index 1f9e0c139988c4c44a26552881647d36965aa4fa..b8d612d22aca74a08b53393c0723a2ae3a0b9ddf 100644 +--- a/src/main/java/net/minecraft/world/effect/WitherMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/WitherMobEffect.java +@@ -10,7 +10,7 @@ class WitherMobEffect extends MobEffect { + @Override + public void applyEffectTick(LivingEntity entity, int amplifier) { + super.applyEffectTick(entity, amplifier); +- entity.hurt(entity.damageSources().wither(), 1.0F); ++ entity.hurt(entity.damageSources().wither(), entity.level().purpurConfig.entityWitherDegenerationAmount); // Purpur + } + @Override diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a2b52ec8d 100644 +index b2b1e34af626fad2586dcc12596c761560d2dfad..1ca91631b03c9690b4f661ecfb4d500d23cb47ec 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -156,7 +156,7 @@ import org.bukkit.plugin.PluginManager; +@@ -155,7 +155,7 @@ import org.bukkit.plugin.PluginManager; // CraftBukkit end public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -4237,7 +4164,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a // CraftBukkit start private static final int CURRENT_LEVEL = 2; public boolean preserveMotion = true; // Paper - keep initial motion on first setPositionRotation -@@ -334,7 +334,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -333,7 +333,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public double xOld; public double yOld; public double zOld; @@ -4246,7 +4173,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a public boolean noPhysics; protected final RandomSource random; public int tickCount; -@@ -376,7 +376,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -375,7 +375,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { private final Set tags; private final double[] pistonDeltas; private long pistonDeltasGameTime; @@ -4255,7 +4182,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a private float eyeHeight; public boolean isInPowderSnow; public boolean wasInPowderSnow; -@@ -418,6 +418,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -417,6 +417,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public boolean freezeLocked = false; // Paper - Freeze Tick Lock API public boolean collidingWithWorldBorder; // Paper public boolean fixedPose = false; // Paper @@ -4263,16 +4190,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a public void setOrigin(@javax.annotation.Nonnull Location location) { this.origin = location.toVector(); -@@ -439,7 +440,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // golf score - public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // used where needed - // Pufferfish end -- -+ - public float getBukkitYaw() { - return this.yRot; - } -@@ -493,6 +494,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -491,6 +492,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return false; } @@ -4298,7 +4216,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a public final boolean hardCollides() { return this.hardCollides; } -@@ -597,7 +617,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -541,7 +561,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.bb = Entity.INITIAL_AABB; this.stuckSpeedMultiplier = Vec3.ZERO; this.nextStep = 1.0F; @@ -4307,7 +4225,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a this.remainingFireTicks = -this.getFireImmuneTicks(); this.fluidHeight = new Object2DoubleArrayMap(2); this.fluidOnEyes = new HashSet(); -@@ -845,7 +865,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -789,7 +809,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit end public void baseTick() { @@ -4316,7 +4234,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Update last hurt when ticking this.feetBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -906,7 +926,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -850,7 +870,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } this.firstTick = false; @@ -4325,7 +4243,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } public void setSharedFlagOnFire(boolean onFire) { -@@ -915,10 +935,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -859,10 +879,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void checkBelowWorld() { // Paper start - Configurable nether ceiling damage @@ -4338,7 +4256,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a this.onBelowWorld(); } -@@ -1125,7 +1146,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1069,7 +1090,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } @@ -4347,7 +4265,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { movement = movement.multiply(this.stuckSpeedMultiplier); this.stuckSpeedMultiplier = Vec3.ZERO; -@@ -1134,7 +1155,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1078,7 +1099,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // Paper start - ignore movement changes while inactive. if (isTemporarilyActive && !(this instanceof ItemEntity || this instanceof net.minecraft.world.entity.vehicle.AbstractMinecart) && movement == getDeltaMovement() && movementType == MoverType.SELF) { setDeltaMovement(Vec3.ZERO); @@ -4356,7 +4274,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a return; } // Paper end -@@ -1155,8 +1176,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1099,8 +1120,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); } @@ -4367,16 +4285,18 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a boolean flag = !Mth.equal(movement.x, vec3d1.x); boolean flag1 = !Mth.equal(movement.z, vec3d1.z); -@@ -1175,7 +1196,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1118,8 +1139,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + BlockState iblockdata = this.level().getBlockState(blockposition); this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition); - if (this.isRemoved()) { +- if (this.isRemoved()) { - this.level().getProfiler().pop(); ++ if (false && this.isRemoved()) { // Purpur + //this.level().getProfiler().pop(); // Purpur } else { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); -@@ -1313,7 +1334,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1257,7 +1278,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.setRemainingFireTicks(-this.getFireImmuneTicks()); } @@ -4385,7 +4305,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } } // Paper start - detailed watchdog information -@@ -1803,7 +1824,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1759,7 +1780,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean fireImmune() { @@ -4394,7 +4314,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } public boolean causeFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource) { -@@ -1872,7 +1893,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1832,7 +1853,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.isInWater() || flag; } @@ -4403,7 +4323,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a Entity entity = this.getVehicle(); if (entity instanceof Boat) { -@@ -2473,6 +2494,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2433,6 +2454,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { nbt.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -4415,7 +4335,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a return nbt; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2641,6 +2667,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2601,6 +2627,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { freezeLocked = nbt.getBoolean("Paper.FreezeLock"); } // Paper end @@ -4427,7 +4347,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); -@@ -2942,6 +2973,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2945,6 +2976,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.passengers = ImmutableList.copyOf(list); } @@ -4441,22 +4361,20 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a this.gameEvent(GameEvent.ENTITY_MOUNT, passenger); } } -@@ -2982,6 +3020,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2985,6 +3023,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return false; } // Spigot end -+ + // Purpur start + if (this.rider != null && this.passengers.get(0) == this.rider) { + onDismount(this.rider); + this.rider = null; + } + // Purpur end -+ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -3041,12 +3087,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3064,12 +3108,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return Vec3.directionFromRotation(this.getRotationVector()); } @@ -4473,7 +4391,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } this.isInsidePortal = true; -@@ -3064,7 +3113,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3087,7 +3134,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { ServerLevel worldserver1 = minecraftserver.getLevel(resourcekey); if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit @@ -4482,7 +4400,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a this.portalTime = i; // Paper start io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER); -@@ -3082,7 +3131,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3105,7 +3152,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } // Paper // CraftBukkit end @@ -4491,7 +4409,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } this.isInsidePortal = false; -@@ -3097,7 +3146,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3120,7 +3167,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } this.processPortalCooldown(); @@ -4500,7 +4418,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } } -@@ -3283,7 +3332,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3310,7 +3357,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public int getMaxAirSupply() { @@ -4509,7 +4427,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } public int getAirSupply() { -@@ -3553,14 +3602,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3580,14 +3627,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Paper end if (this.level() instanceof ServerLevel && !this.isRemoved()) { @@ -4526,7 +4444,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a PortalInfo shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new PortalInfo(new Vec3(location.x(), location.y(), location.z()), Vec3.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit if (shapedetectorshape == null) { -@@ -3599,7 +3648,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3626,7 +3673,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.unRide(); // CraftBukkit end @@ -4535,7 +4453,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a // Paper start - Change lead drop timing to prevent dupe if (this instanceof Mob) { ((Mob) this).dropLeash(true, true); // Paper drop lead -@@ -3622,10 +3671,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3649,10 +3696,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } this.removeAfterChangingDimensions(); @@ -4548,7 +4466,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a return entity; } } else { -@@ -3745,7 +3794,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3772,7 +3819,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean canChangeDimensions() { @@ -4557,7 +4475,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a } public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) { -@@ -4047,6 +4096,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4065,6 +4112,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return SlotAccess.NULL; } @@ -4578,7 +4496,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a @Override public void sendSystemMessage(Component message) {} -@@ -4316,6 +4379,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4334,6 +4395,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.yRotO = this.getYRot(); } @@ -4591,7 +4509,7 @@ index 36795968f4c296f680f79cc5a795391ae13c64e4..cf0d8da4c4b5f4aa4e4ef15897ca252a public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { if (false && this.touchingUnloadedChunk()) { // Pufferfish - cost of a lookup here is the same cost as below, so skip return false; -@@ -4869,4 +4938,45 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4899,4 +4966,45 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return ((net.minecraft.server.level.ServerChunkCache) level.getChunkSource()).isPositionTicking(this); } // Paper end @@ -4650,10 +4568,10 @@ index 3ff999734d14e2b6e7828e117f5ee32a60c26bc1..cfa9607241c3e69777ffc317206996c2 private EntitySelector() {} // Paper start diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index aa5cec6d56d7a8e80861aa4c9b4a74ca3e64be8c..a8ffa403ac48041e17aa4ce057be0539e5468fd4 100644 +index 2561e74ffdf595a9b6ae13dcd738662c772db442..5930e45bae5aa86b3cedb811c4c9bb92099bc1b5 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -308,13 +308,24 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -309,13 +309,24 @@ public class EntityType implements FeatureElement, EntityTypeT private Component description; @Nullable private ResourceLocation lootTable; @@ -4679,7 +4597,7 @@ index aa5cec6d56d7a8e80861aa4c9b4a74ca3e64be8c..a8ffa403ac48041e17aa4ce057be0539 public static ResourceLocation getKey(EntityType type) { return BuiltInRegistries.ENTITY_TYPE.getKey(type); } -@@ -530,6 +541,16 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -531,6 +542,16 @@ public class EntityType implements FeatureElement, EntityTypeT return this.category; } @@ -4696,7 +4614,7 @@ index aa5cec6d56d7a8e80861aa4c9b4a74ca3e64be8c..a8ffa403ac48041e17aa4ce057be0539 public String getDescriptionId() { if (this.descriptionId == null) { this.descriptionId = Util.makeDescriptionId("entity", BuiltInRegistries.ENTITY_TYPE.getKey(this)); -@@ -591,6 +612,12 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -592,6 +613,12 @@ public class EntityType implements FeatureElement, EntityTypeT entity.load(nbt); }, () -> { EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); @@ -4750,7 +4668,7 @@ index eca634792d2a7cc649675e3394e84dbaf1453905..724bf857bf1b89cb0947b8a82e0ce09a public int getValue() { return this.value; diff --git a/src/main/java/net/minecraft/world/entity/GlowSquid.java b/src/main/java/net/minecraft/world/entity/GlowSquid.java -index 759713f7c646aaf1a918c87a2834a1d405385dad..43cdda0cb26c5d5cc9025199eb71673d71c2abea 100644 +index 1bb8b6e91c44cd13411d96d749fa64835c75a267..b18cbe85330e26de6f6cbfcc3d51a7418bd93877 100644 --- a/src/main/java/net/minecraft/world/entity/GlowSquid.java +++ b/src/main/java/net/minecraft/world/entity/GlowSquid.java @@ -23,6 +23,39 @@ public class GlowSquid extends Squid { @@ -4794,7 +4712,7 @@ index 759713f7c646aaf1a918c87a2834a1d405385dad..43cdda0cb26c5d5cc9025199eb71673d protected ParticleOptions getInkParticle() { return ParticleTypes.GLOW_SQUID_INK; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba85267a875fc 100644 +index 6806aadd18696832a8d6ada3db0cee89047acb60..82d4fd6ea1ebd3147f96501605f7990934435ec8 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -218,9 +218,9 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -4847,7 +4765,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 } @@ -337,6 +342,7 @@ public abstract class LivingEntity extends Entity implements Attackable { public static AttributeSupplier.Builder createLivingAttributes() { - return AttributeSupplier.builder().add(Attributes.MAX_HEALTH).add(Attributes.KNOCKBACK_RESISTANCE).add(Attributes.MOVEMENT_SPEED).add(Attributes.ARMOR).add(Attributes.ARMOR_TOUGHNESS); + return AttributeSupplier.builder().add(Attributes.MAX_HEALTH).add(Attributes.KNOCKBACK_RESISTANCE).add(Attributes.MOVEMENT_SPEED).add(Attributes.ARMOR).add(Attributes.ARMOR_TOUGHNESS).add(Attributes.MAX_ABSORPTION); } + public boolean shouldSendAttribute(Attribute attribute) { return true; } // Purpur @@ -4977,7 +4895,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); if (event.isCancelled()) { continue; -@@ -1471,13 +1507,13 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1503,13 +1539,13 @@ public abstract class LivingEntity extends Entity implements Attackable { if (entity1 instanceof net.minecraft.world.entity.player.Player) { net.minecraft.world.entity.player.Player entityhuman = (net.minecraft.world.entity.player.Player) entity1; @@ -4993,7 +4911,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 LivingEntity entityliving2 = entitywolf.getOwner(); if (entityliving2 instanceof net.minecraft.world.entity.player.Player) { -@@ -1588,6 +1624,18 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1620,6 +1656,18 @@ public abstract class LivingEntity extends Entity implements Attackable { } } @@ -5012,7 +4930,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null; EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot); event.setCancelled(itemstack == null); -@@ -1754,7 +1802,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1787,7 +1835,7 @@ public abstract class LivingEntity extends Entity implements Attackable { boolean flag = false; if (this.dead && adversary instanceof WitherBoss) { // Paper @@ -5021,7 +4939,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 BlockPos blockposition = this.blockPosition(); BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); -@@ -1800,6 +1848,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1833,6 +1881,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.dropEquipment(); // CraftBukkit - from below if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -5029,7 +4947,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 this.dropFromLootTable(source, flag); // Paper start final boolean prev = this.clearEquipmentSlots; -@@ -1808,6 +1857,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1841,6 +1890,7 @@ public abstract class LivingEntity extends Entity implements Attackable { // Paper end this.dropCustomDeathLoot(source, i, flag); this.clearEquipmentSlots = prev; // Paper @@ -5037,7 +4955,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 } // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops, () -> { -@@ -2054,7 +2104,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2088,7 +2138,7 @@ public abstract class LivingEntity extends Entity implements Attackable { MobEffectInstance mobeffect = this.getEffect(MobEffects.JUMP); float f2 = mobeffect == null ? 0.0F : (float) (mobeffect.getAmplifier() + 1); @@ -5046,7 +4964,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 } } -@@ -2277,6 +2327,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2311,6 +2361,20 @@ public abstract class LivingEntity extends Entity implements Attackable { } } @@ -5067,7 +4985,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 if (f > 0 || !human) { if (human) { // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. -@@ -2493,7 +2557,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2531,7 +2595,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Override protected void onBelowWorld() { @@ -5076,7 +4994,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 } protected void updateSwingTime() { -@@ -2690,7 +2754,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2725,7 +2789,7 @@ public abstract class LivingEntity extends Entity implements Attackable { } protected long lastJumpTime = 0L; // Paper @@ -5085,7 +5003,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 Vec3 vec3d = this.getDeltaMovement(); // Paper start long time = System.nanoTime(); -@@ -2842,6 +2906,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2877,6 +2941,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (f3 > 0.0F) { this.playSound(this.getFallDamageSound((int) f3), 1.0F, 1.0F); @@ -5093,7 +5011,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 this.hurt(this.damageSources().flyIntoWall(), f3); } } -@@ -3063,10 +3128,10 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3098,10 +3163,10 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.run += (f3 - this.run) * 0.3F; @@ -5107,7 +5025,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 // Paper start - stop large pitch and yaw changes from crashing the server this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; -@@ -3078,7 +3143,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3113,7 +3178,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; // Paper end @@ -5116,10 +5034,10 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 this.animStep += f2; if (this.isFallFlying()) { ++this.fallFlyTicks; -@@ -3367,19 +3432,19 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3396,19 +3461,19 @@ public abstract class LivingEntity extends Entity implements Attackable { } - this.setDeltaMovement(d4, d5, d6); + this.setDeltaMovement(d0, d1, d2); - this.level().getProfiler().push("ai"); + //this.level().getProfiler().push("ai"); // Purpur if (this.isImmobile()) { @@ -5139,9 +5057,9 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 + //this.level().getProfiler().pop(); // Purpur + //this.level().getProfiler().push("jump"); // Purpur if (this.jumping && this.isAffectedByFluids()) { - double d7; + double d3; -@@ -3406,8 +3471,8 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3435,8 +3500,8 @@ public abstract class LivingEntity extends Entity implements Attackable { this.noJumpDelay = 0; } @@ -5152,7 +5070,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 this.xxa *= 0.98F; this.zza *= 0.98F; this.updateFallFlying(); -@@ -3434,8 +3499,8 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3463,8 +3528,8 @@ public abstract class LivingEntity extends Entity implements Attackable { this.travel(vec3d1); } @@ -5163,7 +5081,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 if (!this.level().isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API int i = this.getTicksFrozen(); -@@ -3452,18 +3517,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3481,18 +3546,20 @@ public abstract class LivingEntity extends Entity implements Attackable { this.hurt(this.damageSources().freeze(), 1.0F); } @@ -5189,7 +5107,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); Location to = new Location (this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -@@ -3473,12 +3540,48 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3502,12 +3569,48 @@ public abstract class LivingEntity extends Entity implements Attackable { this.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); } } @@ -5238,7 +5156,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 } public boolean isSensitiveToWater() { -@@ -3499,7 +3602,16 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3528,7 +3631,16 @@ public abstract class LivingEntity extends Entity implements Attackable { int j = i / 10; if (j % 2 == 0) { @@ -5257,7 +5175,7 @@ index d265a32bd273beed0e65e224e1c5f9c0bca7b3fb..49906b4dc8392eee592215d0b4cba852 }); } diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc593c421f2 100644 +index 4cb836dfa7cbd2e634d4a3a567da0305aac0da4d..d35afa8f8648bbcbfc044323bcda1b1182d7dce4 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -65,6 +65,7 @@ import net.minecraft.world.item.ProjectileWeaponItem; @@ -5268,7 +5186,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 import net.minecraft.world.level.GameRules; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; -@@ -132,6 +133,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -134,6 +135,7 @@ public abstract class Mob extends LivingEntity implements Targeting { private BlockPos restrictCenter; private float restrictRadius; @@ -5276,7 +5194,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 public boolean aware = true; // CraftBukkit protected Mob(EntityType type, Level world) { -@@ -145,8 +147,8 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -147,8 +149,8 @@ public abstract class Mob extends LivingEntity implements Targeting { this.restrictRadius = -1.0F; this.goalSelector = new GoalSelector(world.getProfilerSupplier()); this.targetSelector = new GoalSelector(world.getProfilerSupplier()); @@ -5287,7 +5205,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 this.jumpControl = new JumpControl(this); this.bodyRotationControl = this.createBodyControl(); this.navigation = this.createNavigation(world); -@@ -322,6 +324,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -323,6 +325,7 @@ public abstract class Mob extends LivingEntity implements Targeting { entityliving = null; } } @@ -5295,7 +5213,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 this.target = entityliving; return true; // CraftBukkit end -@@ -362,15 +365,35 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -363,15 +366,35 @@ public abstract class Mob extends LivingEntity implements Targeting { @Override public void baseTick() { super.baseTick(); @@ -5333,7 +5251,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 @Override protected void playHurtSound(DamageSource source) { this.resetAmbientSoundTime(); -@@ -560,6 +583,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -561,6 +584,7 @@ public abstract class Mob extends LivingEntity implements Targeting { } nbt.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit @@ -5341,7 +5259,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 } @Override -@@ -630,6 +654,11 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -631,6 +655,11 @@ public abstract class Mob extends LivingEntity implements Targeting { this.aware = nbt.getBoolean("Bukkit.Aware"); } // CraftBukkit end @@ -5353,7 +5271,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 } @Override -@@ -673,8 +702,8 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -674,8 +703,8 @@ public abstract class Mob extends LivingEntity implements Targeting { @Override public void aiStep() { super.aiStep(); @@ -5364,7 +5282,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 Vec3i baseblockposition = this.getPickupReach(); List list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate((double) baseblockposition.getX(), (double) baseblockposition.getY(), (double) baseblockposition.getZ())); Iterator iterator = list.iterator(); -@@ -693,7 +722,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -694,7 +723,7 @@ public abstract class Mob extends LivingEntity implements Targeting { } } @@ -5373,7 +5291,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 } protected Vec3i getPickupReach() { -@@ -905,46 +934,46 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -908,46 +937,46 @@ public abstract class Mob extends LivingEntity implements Targeting { return; } // Paper end @@ -5399,7 +5317,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 + //this.level().getProfiler().pop(); // Purpur } else { - this.level().getProfiler().push("targetSelector"); -+ //this.level().getProfiler().push("targetSelector"); ++ //this.level().getProfiler().push("targetSelector"); // Purpur if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking this.targetSelector.tick(); - this.level().getProfiler().pop(); @@ -5440,7 +5358,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 this.sendDebugPackets(); } -@@ -1173,6 +1202,12 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1176,6 +1205,12 @@ public abstract class Mob extends LivingEntity implements Targeting { } @@ -5453,7 +5371,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 @Nullable public static Item getEquipmentForSlot(EquipmentSlot equipmentSlot, int equipmentLevel) { switch (equipmentSlot) { -@@ -1267,7 +1302,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1270,7 +1305,7 @@ public abstract class Mob extends LivingEntity implements Targeting { RandomSource randomsource = world.getRandom(); this.getAttribute(Attributes.FOLLOW_RANGE).addPermanentModifier(new AttributeModifier("Random spawn bonus", randomsource.triangle(0.0D, 0.11485000000000001D), AttributeModifier.Operation.MULTIPLY_BASE)); @@ -5462,7 +5380,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 this.setLeftHanded(true); } else { this.setLeftHanded(false); -@@ -1315,6 +1350,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1318,6 +1353,7 @@ public abstract class Mob extends LivingEntity implements Targeting { if (!this.isAlive()) { return InteractionResult.PASS; } else if (this.getLeashHolder() == player) { @@ -5470,7 +5388,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 // CraftBukkit start - fire PlayerUnleashEntityEvent // Paper start - drop leash variable org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.getAbilities().instabuild); -@@ -1388,7 +1424,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1391,7 +1427,7 @@ public abstract class Mob extends LivingEntity implements Targeting { protected void onOffspringSpawnedFromEgg(Player player, Mob child) {} protected InteractionResult mobInteract(Player player, InteractionHand hand) { @@ -5479,7 +5397,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 } public boolean isWithinRestriction() { -@@ -1693,6 +1729,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1702,6 +1738,7 @@ public abstract class Mob extends LivingEntity implements Targeting { this.setLastHurtMob(target); } @@ -5487,7 +5405,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 return flag; } -@@ -1709,17 +1746,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1718,17 +1755,7 @@ public abstract class Mob extends LivingEntity implements Targeting { } public boolean isSunBurnTick() { @@ -5506,7 +5424,7 @@ index 7e453b4c49975bb06cb080f3626545286b947ddc..5dd0c925af627f7159289dc1e3e79bc5 } @Override -@@ -1766,4 +1793,56 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1775,4 +1802,56 @@ public abstract class Mob extends LivingEntity implements Targeting { return itemmonsteregg == null ? null : new ItemStack(itemmonsteregg); } @@ -5583,13 +5501,13 @@ index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..a089fc61ec09be6b7490375489178dc6 boolean readyForShearing(); } diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index e283eb57c25f7de222f9d09dca851169f5f6e488..210a0bee1227e4671909dd553ab22027cfc868fb 100644 +index d8bb16f74fdd8d5a50bd384249e0eac9640cd498..a2ec4ad05547a7c3fe9349d6e724d234fb1b7a82 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -24,14 +24,21 @@ public class AttributeMap { private final Set dirtyAttributes = Sets.newHashSet(); private final AttributeSupplier supplier; - private final java.util.function.Function createInstance; // Pufferfish + private final java.util.function.Function createdInstance; // Pufferfish + private final net.minecraft.world.entity.LivingEntity entity; // Purpur public AttributeMap(AttributeSupplier defaultAttributes) { @@ -5600,7 +5518,7 @@ index e283eb57c25f7de222f9d09dca851169f5f6e488..210a0bee1227e4671909dd553ab22027 + this.entity = entity; + // Purpur end this.supplier = defaultAttributes; - this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish + this.createdInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish } private void onAttributeModified(AttributeInstance instance) { @@ -5855,7 +5773,7 @@ index 42ae4d293a420f0b8eb476df6389b2e7a693895f..97c20c5b89e6d7e4ed844eff39ee55df } else { DoorBlock blockdoor = (DoorBlock) iblockdata.getBlock(); diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java -index 050be72c815010bf3f4b72427e2052b00420e8ee..8a213205f57c8dcd2226d7194d74b1b13dec5a78 100644 +index c3e0b1f11b58668f9f24eb421abc340e1b49dfac..d809fa4f96e2c528075f544355397903996ecaf6 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShowTradesToPlayer.java @@ -42,6 +42,7 @@ public class ShowTradesToPlayer extends Behavior { @@ -5903,7 +5821,7 @@ index cd7a90ec1073b2b452ca70decefe6a594445003b..47672e48c1cae73cffe532d622b29634 } else { workAtPoi = new WorkAtPoi(); diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -index 645d204fe2c727637a6a547aad7d4db1279628ae..8be2f612c9e8a64b0aad6bb54450cdfb12b3c19e 100644 +index 0cc411dd39d981187c9e9a3c5eb8043b19a09b98..f7032f4ea55f5aca293c2640686238b7af0f9c80 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java @@ -127,8 +127,10 @@ public class VillagerMakeLove extends Behavior { @@ -6103,16 +6021,16 @@ index 509317a26c79f453335df1c19dc4c9ec570046af..8e4d673e4f2d7f50ea5ed13794da08b1 } else if (this.nextStartTick > 0) { --this.nextStartTick; diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -index 7fc5b5d624b61a3de9c71e975b51d20c5800be00..8fb070b1ae11d34b2fa420ded58097d421263cab 100644 +index b0944fa1f3849dd24cd010fa0a6638f5fd7179d1..a3074ec9b430c9d0a0ef33fe353db643849fab7d 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -66,7 +66,7 @@ public class RunAroundLikeCrazyGoal extends Goal { +@@ -67,7 +67,7 @@ public class RunAroundLikeCrazyGoal extends Goal { int i = this.horse.getTemper(); int j = this.horse.getMaxTemper(); - if (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent + if ((this.horse.level().purpurConfig.alwaysTameInCreative && ((Player) entity).getAbilities().instabuild) || (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled())) { // CraftBukkit - fire EntityTameEvent // Purpur - this.horse.tameWithName((Player) entity); + this.horse.tameWithName(entityhuman); return; } diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/SwellGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/SwellGoal.java @@ -6148,7 +6066,7 @@ index 0d9b194781d152e842c9a4b8d6f23d307b2e4452..00cf59524477ec79d4354cc403fc3e75 @Override diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index b376670d11088e524ce246f667e580e90cd119a3..fdb08ecc19bc4a1bc93cf6b18adcea2bc5573965 100644 +index b37415d45dda8e658c8995a4519e552dc378bb41..0e36e3e672de4c806e2d534b437489a3a349a722 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java @@ -172,12 +172,12 @@ public abstract class PathNavigation { @@ -6227,7 +6145,7 @@ index fcdb9bde8e1605e30dde3e580491522d4b62cdc0..7094701d213c73ba47ace806962244c1 } diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index d25307ae8bbdf10ae067ec70fc2cb957b852a0eb..54bdb81785b617e13e67530752395f2a0c6d703a 100644 +index ac5e5676b194a2a99e5cf53eb89c1152cac963b8..872454743f6dedc27519a13566559195c47cc9f8 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -64,6 +64,10 @@ public class TargetingConditions { @@ -6440,7 +6358,7 @@ index 2249fc6dd98afb8d52623b5864955fdd3b3fc042..2ccfaab0a02cf5ff9779e250fb79a75a double d = this.wantedX - this.fish.getX(); double e = this.wantedY - this.fish.getY(); diff --git a/src/main/java/net/minecraft/world/entity/animal/Animal.java b/src/main/java/net/minecraft/world/entity/animal/Animal.java -index c2f61ed153260692c96af4f20bc5b7d55cbbc380..8773b1072016a3bbf025959e9ab827704ec17fc6 100644 +index be105a4460e9bf2ef4b72a307fa31291c37d5e0e..2e268aa614522b40fbffabce4017b228db5bcba8 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Animal.java +++ b/src/main/java/net/minecraft/world/entity/animal/Animal.java @@ -42,6 +42,7 @@ public abstract class Animal extends AgeableMob { @@ -6451,7 +6369,7 @@ index c2f61ed153260692c96af4f20bc5b7d55cbbc380..8773b1072016a3bbf025959e9ab82770 protected Animal(EntityType type, Level world) { super(type, world); -@@ -154,7 +155,7 @@ public abstract class Animal extends AgeableMob { +@@ -149,7 +150,7 @@ public abstract class Animal extends AgeableMob { if (this.isFood(itemstack)) { int i = this.getAge(); @@ -6460,7 +6378,7 @@ index c2f61ed153260692c96af4f20bc5b7d55cbbc380..8773b1072016a3bbf025959e9ab82770 this.usePlayerItem(player, hand, itemstack); this.setInLove(player); return InteractionResult.SUCCESS; -@@ -236,12 +237,20 @@ public abstract class Animal extends AgeableMob { +@@ -231,12 +232,20 @@ public abstract class Animal extends AgeableMob { AgeableMob entityageable = this.getBreedOffspring(world, other); if (entityageable != null) { @@ -6484,7 +6402,7 @@ index c2f61ed153260692c96af4f20bc5b7d55cbbc380..8773b1072016a3bbf025959e9ab82770 int experience = this.getRandom().nextInt(7) + 1; EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, other, breeder, this.breedItem, experience); if (entityBreedEvent.isCancelled()) { -@@ -269,8 +278,10 @@ public abstract class Animal extends AgeableMob { +@@ -264,8 +273,10 @@ public abstract class Animal extends AgeableMob { entityplayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, entityanimal, entityageable); } // Paper @@ -6693,10 +6611,10 @@ index 55026e1731e41b4e3e4c6a8fef5d96a32051a556..6c04c8e7776b2830ac368229da834532 } diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java -index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b4169523885b91a047 100644 +index de51ce9875e12961e6e549e87d76f492d2f19787..6e5b4a50b8d2dddbd7f099426b4866b35bcb798a 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Cat.java +++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java -@@ -97,6 +97,51 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -98,6 +98,51 @@ public class Cat extends TamableAnimal implements VariantHolder { super(type, world); } @@ -6748,7 +6666,7 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 public ResourceLocation getResourceLocation() { return this.getVariant().texture(); } -@@ -105,6 +150,7 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -106,6 +151,7 @@ public class Cat extends TamableAnimal implements VariantHolder { protected void registerGoals() { this.temptGoal = new Cat.CatTemptGoal(this, 0.6D, Cat.TEMPT_INGREDIENT, true); this.goalSelector.addGoal(1, new FloatGoal(this)); @@ -6756,7 +6674,7 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 this.goalSelector.addGoal(1, new PanicGoal(this, 1.5D)); this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this)); this.goalSelector.addGoal(3, new Cat.CatRelaxOnOwnerGoal(this)); -@@ -117,6 +163,7 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -118,6 +164,7 @@ public class Cat extends TamableAnimal implements VariantHolder { this.goalSelector.addGoal(10, new BreedGoal(this, 0.8D)); this.goalSelector.addGoal(11, new WaterAvoidingRandomStrollGoal(this, 0.8D, 1.0000001E-5F)); this.goalSelector.addGoal(12, new LookAtPlayerGoal(this, Player.class, 10.0F)); @@ -6764,7 +6682,7 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 this.targetSelector.addGoal(1, new NonTameRandomTargetGoal<>(this, Rabbit.class, false, (Predicate) null)); this.targetSelector.addGoal(1, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -308,6 +355,14 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -309,6 +356,14 @@ public class Cat extends TamableAnimal implements VariantHolder { return Mth.lerp(tickDelta, this.relaxStateOneAmountO, this.relaxStateOneAmount); } @@ -6779,7 +6697,7 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 @Nullable @Override public Cat getBreedOffspring(ServerLevel world, AgeableMob entity) { -@@ -373,6 +428,7 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -374,6 +429,7 @@ public class Cat extends TamableAnimal implements VariantHolder { @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { @@ -6787,7 +6705,7 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 ItemStack itemstack = player.getItemInHand(hand); Item item = itemstack.getItem(); -@@ -419,7 +475,7 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -420,7 +476,7 @@ public class Cat extends TamableAnimal implements VariantHolder { } } else if (this.isFood(itemstack)) { this.usePlayerItem(player, hand, itemstack); @@ -6797,10 +6715,10 @@ index 90ce201bc7c47cef9bc59d7b535a7453854bac75..3347b39fa1bc3308aa3b70b416952388 this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte) 7); diff --git a/src/main/java/net/minecraft/world/entity/animal/Chicken.java b/src/main/java/net/minecraft/world/entity/animal/Chicken.java -index 84cefbc339ca368ac306d521012ce2f826a660b5..00bdb2b75221349cb40da2b5fc1563393fd17ef6 100644 +index 5e7e6526e2750d508a870dfbdbb46e520d201796..0388ff9ce0ffe1029d977a65a528a0d9f228a3ee 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Chicken.java +++ b/src/main/java/net/minecraft/world/entity/animal/Chicken.java -@@ -54,16 +54,65 @@ public class Chicken extends Animal { +@@ -55,16 +55,65 @@ public class Chicken extends Animal { this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); } @@ -6867,7 +6785,7 @@ index 84cefbc339ca368ac306d521012ce2f826a660b5..00bdb2b75221349cb40da2b5fc156339 } @Override -@@ -72,7 +121,7 @@ public class Chicken extends Animal { +@@ -73,7 +122,7 @@ public class Chicken extends Animal { } public static AttributeSupplier.Builder createAttributes() { @@ -6915,7 +6833,7 @@ index 824e5e4fe7619ae46061c3c978c9a044db8c84ab..f0b6118a9995bb41836685bbf94d2e7f public ItemStack getBucketItemStack() { return new ItemStack(Items.COD_BUCKET); diff --git a/src/main/java/net/minecraft/world/entity/animal/Cow.java b/src/main/java/net/minecraft/world/entity/animal/Cow.java -index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce881e6875 100644 +index 3cdd9f379c7e2d46ea47c9ef55b121c93ec0bb4a..6d00b3cd4a9cb0fc8a9e9c27f37429a25fcf6e9d 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Cow.java +++ b/src/main/java/net/minecraft/world/entity/animal/Cow.java @@ -2,6 +2,7 @@ package net.minecraft.world.entity.animal; @@ -6926,15 +6844,15 @@ index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; -@@ -29,6 +30,7 @@ import net.minecraft.world.item.ItemUtils; +@@ -30,6 +31,7 @@ import net.minecraft.world.item.ItemUtils; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; - // CraftBukkit start - import org.bukkit.craftbukkit.event.CraftEventFactory; -@@ -37,25 +39,74 @@ import org.bukkit.event.player.PlayerBucketFillEvent; + import org.joml.Vector3f; + +@@ -40,25 +42,74 @@ import org.bukkit.event.player.PlayerBucketFillEvent; // CraftBukkit end public class Cow extends Animal { @@ -7010,7 +6928,7 @@ index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce } @Override -@@ -85,6 +136,7 @@ public class Cow extends Animal { +@@ -88,6 +139,7 @@ public class Cow extends Animal { @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { @@ -7018,7 +6936,7 @@ index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce ItemStack itemstack = player.getItemInHand(hand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { -@@ -92,7 +144,7 @@ public class Cow extends Animal { +@@ -95,7 +147,7 @@ public class Cow extends Animal { PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand); if (event.isCancelled()) { @@ -7027,7 +6945,7 @@ index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce } // CraftBukkit end -@@ -101,6 +153,10 @@ public class Cow extends Animal { +@@ -104,6 +156,10 @@ public class Cow extends Animal { player.setItemInHand(hand, itemstack1); return InteractionResult.sidedSuccess(this.level().isClientSide); @@ -7038,9 +6956,9 @@ index 0263acf81330ada1bb8ae7d52a3b04e08d0c4dcb..3cee7d5656b2df2997ceaee3489c02ce } else { return super.mobInteract(player, hand); } -@@ -116,4 +172,69 @@ public class Cow extends Animal { - protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) { - return this.isBaby() ? dimensions.height * 0.95F : 1.3F; +@@ -124,4 +180,69 @@ public class Cow extends Animal { + protected Vector3f getPassengerAttachmentPoint(Entity passenger, EntityDimensions dimensions, float scaleFactor) { + return new Vector3f(0.0F, dimensions.height - 0.03125F * scaleFactor, 0.0F); } + + // Purpur start - feed mushroom to change to mooshroom @@ -7271,10 +7189,10 @@ index 8448c5d778998390cf2b683f36e4e18ca7ffdc34..4c9c07d470357c35bd5ba3c21437a2c4 } diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java -index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed87f212954 100644 +index 31d4683f5e158f076ce9a416b7003478af293688..39c982f83a8b5b0787fc8dd48a0c11e5ad452bb0 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java +++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java -@@ -35,6 +35,7 @@ import net.minecraft.util.RandomSource; +@@ -36,6 +36,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.util.StringRepresentable; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; @@ -7282,15 +7200,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; -@@ -88,6 +89,7 @@ import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.CaveVines; - import net.minecraft.world.level.block.SweetBerryBushBlock; - import net.minecraft.world.level.block.state.BlockState; -+import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.level.pathfinder.BlockPathTypes; - import net.minecraft.world.phys.Vec3; - -@@ -141,6 +143,64 @@ public class Fox extends Animal implements VariantHolder { +@@ -144,6 +145,64 @@ public class Fox extends Animal implements VariantHolder { this.setCanPickUpLoot(true); } @@ -7355,7 +7265,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 @Override protected void defineSynchedData() { super.defineSynchedData(); -@@ -160,6 +220,7 @@ public class Fox extends Animal implements VariantHolder { +@@ -163,6 +222,7 @@ public class Fox extends Animal implements VariantHolder { return entityliving instanceof AbstractSchoolingFish; }); this.goalSelector.addGoal(0, new Fox.FoxFloatGoal()); @@ -7363,7 +7273,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 this.goalSelector.addGoal(0, new ClimbOnTopOfPowderSnowGoal(this, this.level())); this.goalSelector.addGoal(1, new Fox.FaceplantGoal()); this.goalSelector.addGoal(2, new Fox.FoxPanicGoal(2.2D)); -@@ -186,6 +247,7 @@ public class Fox extends Animal implements VariantHolder { +@@ -189,6 +249,7 @@ public class Fox extends Animal implements VariantHolder { this.goalSelector.addGoal(11, new Fox.FoxSearchForItemsGoal()); this.goalSelector.addGoal(12, new Fox.FoxLookAtPlayerGoal(this, Player.class, 24.0F)); this.goalSelector.addGoal(13, new Fox.PerchAndSearchGoal()); @@ -7371,7 +7281,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 this.targetSelector.addGoal(3, new Fox.DefendTrustedTargetGoal(LivingEntity.class, false, false, (entityliving) -> { return Fox.TRUSTED_TARGET_SELECTOR.test(entityliving) && !this.trusts(entityliving.getUUID()); })); -@@ -342,6 +404,11 @@ public class Fox extends Animal implements VariantHolder { +@@ -345,6 +406,11 @@ public class Fox extends Animal implements VariantHolder { } private void setTargetGoals() { @@ -7383,7 +7293,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 if (this.getVariant() == Fox.Type.RED) { this.targetSelector.addGoal(4, this.landTargetGoal); this.targetSelector.addGoal(4, this.turtleEggTargetGoal); -@@ -375,6 +442,7 @@ public class Fox extends Animal implements VariantHolder { +@@ -378,6 +444,7 @@ public class Fox extends Animal implements VariantHolder { public void setVariant(Fox.Type variant) { this.entityData.set(Fox.DATA_TYPE_ID, variant.getId()); @@ -7391,7 +7301,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 } List getTrustedUUIDs() { -@@ -711,6 +779,29 @@ public class Fox extends Animal implements VariantHolder { +@@ -717,6 +784,29 @@ public class Fox extends Animal implements VariantHolder { return this.getTrustedUUIDs().contains(uuid); } @@ -7421,7 +7331,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 @Override // Paper start - Cancellable death event protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) { -@@ -758,16 +849,16 @@ public class Fox extends Animal implements VariantHolder { +@@ -769,16 +859,16 @@ public class Fox extends Animal implements VariantHolder { return new Vec3(0.0D, (double) (0.55F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); } @@ -7441,7 +7351,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 } } -@@ -778,16 +869,16 @@ public class Fox extends Animal implements VariantHolder { +@@ -789,16 +879,16 @@ public class Fox extends Animal implements VariantHolder { } } @@ -7461,7 +7371,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 } } -@@ -905,8 +996,10 @@ public class Fox extends Animal implements VariantHolder { +@@ -916,8 +1006,10 @@ public class Fox extends Animal implements VariantHolder { CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer2, this.animal, this.partner, entityfox); } @@ -7474,7 +7384,7 @@ index 62604ed2e82afd3603ccac5d9c6e285c431542b1..ca3096abbd54745af591101c7b306ed8 this.animal.resetLove(); this.partner.resetLove(); worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason -@@ -1294,7 +1387,7 @@ public class Fox extends Animal implements VariantHolder { +@@ -1303,7 +1395,7 @@ public class Fox extends Animal implements VariantHolder { } protected void onReachedTarget() { @@ -7596,7 +7506,7 @@ index f383928fc5b331ddf128bdcb6a23010d8fe088d3..64aba511e615983988cdb6a0fd45b7d9 } } diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java -index a04374f91f2fbb31219d86b6ae63bcf8fdf7318c..e462b81aa1276a8f1222b74459359f6c6d57f739 100644 +index 52cc265f1663d648b6bfd03f2ac3e191b1c16d44..59ef1070c6c1ac876e097cd23835e4ed8b6e732f 100644 --- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java +++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java @@ -63,6 +63,43 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder { -@@ -145,7 +182,7 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder> optional = this.getEffectFromItemStack(itemstack); +@@ -144,7 +181,7 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder> optional = this.getEffectsFromItemStack(itemstack); - if (!optional.isPresent()) { + if (optional.isEmpty()) { - return InteractionResult.PASS; + return tryRide(player, hand); // Purpur } - Pair pair = (Pair) optional.get(); -@@ -170,7 +207,7 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder(this, Chicken.class, false)); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, false, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -254,7 +293,7 @@ public class Ocelot extends Animal { +@@ -256,7 +295,7 @@ public class Ocelot extends Animal { if (world.isUnobstructed(this) && !world.containsAnyLiquid(this.getBoundingBox())) { BlockPos blockposition = this.blockPosition(); @@ -7770,10 +7680,10 @@ index 924ea172cab5178e5754bfe09cc7b83c1a66faa6..45fb438065b1db2a9baa648f4d397472 } diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java -index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65936991da 100644 +index 683cc5f9f066d554383fcd30e3654ac06ec76510..505469cf6b7fa66c6cbac73a49e4eec850d5bfec 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Panda.java +++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java -@@ -111,6 +111,53 @@ public class Panda extends Animal { +@@ -114,6 +114,53 @@ public class Panda extends Animal { } @@ -7827,7 +7737,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 @Override public boolean canTakeItem(ItemStack stack) { EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(stack); -@@ -272,6 +319,7 @@ public class Panda extends Animal { +@@ -275,6 +322,7 @@ public class Panda extends Animal { @Override protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); @@ -7835,7 +7745,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 this.goalSelector.addGoal(2, new Panda.PandaPanicGoal(this, 2.0D)); this.goalSelector.addGoal(2, new Panda.PandaBreedGoal(this, 1.0D)); this.goalSelector.addGoal(3, new Panda.PandaAttackGoal(this, 1.2000000476837158D, true)); -@@ -287,6 +335,7 @@ public class Panda extends Animal { +@@ -290,6 +338,7 @@ public class Panda extends Animal { this.goalSelector.addGoal(12, new Panda.PandaRollGoal(this)); this.goalSelector.addGoal(13, new FollowParentGoal(this, 1.25D)); this.goalSelector.addGoal(14, new WaterAvoidingRandomStrollGoal(this, 1.0D)); @@ -7843,7 +7753,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 this.targetSelector.addGoal(1, (new Panda.PandaHurtByTargetGoal(this, new Class[0])).setAlertOthers(new Class[0])); } -@@ -610,7 +659,10 @@ public class Panda extends Animal { +@@ -613,7 +662,10 @@ public class Panda extends Animal { public void setAttributes() { if (this.isWeak()) { @@ -7855,7 +7765,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 } if (this.isLazy()) { -@@ -633,7 +685,7 @@ public class Panda extends Animal { +@@ -636,7 +688,7 @@ public class Panda extends Animal { ItemStack itemstack = player.getItemInHand(hand); if (this.isScared()) { @@ -7864,7 +7774,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 } else if (this.isOnBack()) { this.setOnBack(false); return InteractionResult.sidedSuccess(this.level().isClientSide); -@@ -650,7 +702,7 @@ public class Panda extends Animal { +@@ -653,7 +705,7 @@ public class Panda extends Animal { this.setInLove(player); } else { if (this.level().isClientSide || this.isSitting() || this.isInWater()) { @@ -7873,7 +7783,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 } this.tryToSit(); -@@ -669,7 +721,7 @@ public class Panda extends Animal { +@@ -672,7 +724,7 @@ public class Panda extends Animal { return InteractionResult.SUCCESS; } else { @@ -7882,8 +7792,8 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 } } -@@ -709,7 +761,7 @@ public class Panda extends Animal { - return !this.isOnBack() && !this.isScared() && !this.isEating() && !this.isRolling() && !this.isSitting(); +@@ -717,7 +769,7 @@ public class Panda extends Animal { + return new Vector3f(0.0F, dimensions.height - (this.isBaby() ? 0.4375F : 0.0F) * scaleFactor, 0.0F); } - private static class PandaMoveControl extends MoveControl { @@ -7891,7 +7801,7 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 private final Panda panda; -@@ -719,9 +771,9 @@ public class Panda extends Animal { +@@ -727,9 +779,9 @@ public class Panda extends Animal { } @Override @@ -7904,10 +7814,10 @@ index f43c4fed59c4c75540008284ddb197d9a6b5487b..bd7c5f6768a54a3d8ffd585d91414e65 } } diff --git a/src/main/java/net/minecraft/world/entity/animal/Parrot.java b/src/main/java/net/minecraft/world/entity/animal/Parrot.java -index e1874aaa0065a6e8e6ae043713c22f08b58b5e21..0e20d9ed5b25f5aaab68dc3a4fa4e63ced280969 100644 +index 397264d31992fd43bd57736c25693ae001330b6d..d97ca9d567df224c34eba306b4c9b7df65f31824 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java +++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java -@@ -129,12 +129,88 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder type, Level world) { super(type, world); @@ -7997,7 +7907,7 @@ index e1874aaa0065a6e8e6ae043713c22f08b58b5e21..0e20d9ed5b25f5aaab68dc3a4fa4e63c @Nullable @Override public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData, @Nullable CompoundTag entityNbt) { -@@ -153,8 +229,11 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) { -@@ -306,13 +386,13 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder { +@@ -87,6 +87,7 @@ public class Rabbit extends Animal implements VariantHolder { private boolean wasOnGround; private int jumpDelayTicks; public int moreCarrotTicks; @@ -8307,7 +8217,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 public Rabbit(EntityType type, Level world) { super(type, world); -@@ -93,9 +94,75 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -94,9 +95,75 @@ public class Rabbit extends Animal implements VariantHolder { this.moveControl = new Rabbit.RabbitMoveControl(this); } @@ -8383,7 +8293,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 this.goalSelector.addGoal(1, new ClimbOnTopOfPowderSnowGoal(this, this.level())); this.goalSelector.addGoal(1, new Rabbit.RabbitPanicGoal(this, 2.2D)); this.goalSelector.addGoal(2, new BreedGoal(this, 0.8D)); -@@ -110,6 +177,14 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -111,6 +178,14 @@ public class Rabbit extends Animal implements VariantHolder { @Override protected float getJumpPower() { @@ -8398,7 +8308,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 float f = 0.3F; if (this.horizontalCollision || this.moveControl.hasWanted() && this.moveControl.getWantedY() > this.getY() + 0.5D) { -@@ -134,7 +209,7 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -135,7 +210,7 @@ public class Rabbit extends Animal implements VariantHolder { } @Override @@ -8407,7 +8317,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 super.jumpFromGround(); double d0 = this.moveControl.getSpeedModifier(); -@@ -184,6 +259,13 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -185,6 +260,13 @@ public class Rabbit extends Animal implements VariantHolder { @Override public void customServerAiStep() { @@ -8421,7 +8331,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 if (this.jumpDelayTicks > 0) { --this.jumpDelayTicks; } -@@ -401,10 +483,23 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -402,10 +484,23 @@ public class Rabbit extends Animal implements VariantHolder { } this.setVariant(entityrabbit_variant); @@ -8445,7 +8355,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 Holder holder = world.getBiome(pos); int i = world.getRandom().nextInt(100); -@@ -468,7 +563,7 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -469,7 +564,7 @@ public class Rabbit extends Animal implements VariantHolder { } } @@ -8454,7 +8364,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 private final Rabbit rabbit; private double nextJumpSpeed; -@@ -479,14 +574,14 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -480,14 +575,14 @@ public class Rabbit extends Animal implements VariantHolder { } @Override @@ -8471,7 +8381,7 @@ index 082351bd5f98d8738334b9164375f63fdc890455..81a33954aedffd18fcfa96babeaf6388 } @Override -@@ -548,7 +643,7 @@ public class Rabbit extends Animal implements VariantHolder { +@@ -549,7 +644,7 @@ public class Rabbit extends Animal implements VariantHolder { @Override public boolean canUse() { if (this.nextStartTick <= 0) { @@ -8519,10 +8429,10 @@ index 0af79daa357f53a8871e293b57e16c099e5d3f64..382e47f26ee94506cb76463a677351b9 public int getMaxSchoolSize() { return 5; diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -index c0e89262c596fbdd0bb3c3f76baccb17a1bb5fcd..54de1f782e45cb3e3b1442aeb56b6e8547b065c0 100644 +index 55afa58f3df53ce548c7484d8fff62c903f9dc07..8502fc1331c2e94992ab39e4e7ea0f36e83b06a5 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java +++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -@@ -117,10 +117,48 @@ public class Sheep extends Animal implements Shearable { +@@ -119,10 +119,48 @@ public class Sheep extends Animal implements Shearable { super(type, world); } @@ -8571,7 +8481,7 @@ index c0e89262c596fbdd0bb3c3f76baccb17a1bb5fcd..54de1f782e45cb3e3b1442aeb56b6e85 this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D)); this.goalSelector.addGoal(3, new TemptGoal(this, 1.1D, Ingredient.of(Items.WHEAT), false)); -@@ -255,7 +293,7 @@ public class Sheep extends Animal implements Shearable { +@@ -257,7 +295,7 @@ public class Sheep extends Animal implements Shearable { return InteractionResult.PASS; } // CraftBukkit end @@ -8580,7 +8490,7 @@ index c0e89262c596fbdd0bb3c3f76baccb17a1bb5fcd..54de1f782e45cb3e3b1442aeb56b6e85 this.gameEvent(GameEvent.SHEAR, player); itemstack.hurtAndBreak(1, player, (entityhuman1) -> { entityhuman1.broadcastBreakEvent(hand); -@@ -270,14 +308,15 @@ public class Sheep extends Animal implements Shearable { +@@ -272,14 +310,15 @@ public class Sheep extends Animal implements Shearable { } @Override @@ -8901,10 +8811,10 @@ index b05b560b7570e97bc234b75f26233909fcf575b3..87b6f6b10ba6e3d9c6a42298a2019a52 return "entity.minecraft.tropical_fish.predefined." + variant; } diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -index d3c15d029d5f003cba3c89f7ea1f3ed4f943f2bd..1502f13acd0a104efe470e605826213ea92af191 100644 +index 490472bb618e9ac07da5883a71dff8920525b1e2..c8f3be5fd869f62472d5a248f9c02700dac0ac69 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java +++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -@@ -83,6 +83,43 @@ public class Turtle extends Animal { +@@ -86,6 +86,43 @@ public class Turtle extends Animal { this.setMaxUpStep(1.0F); } @@ -8948,7 +8858,7 @@ index d3c15d029d5f003cba3c89f7ea1f3ed4f943f2bd..1502f13acd0a104efe470e605826213e public void setHomePos(BlockPos pos) { this.entityData.set(Turtle.HOME_POS, pos.immutable()); // Paper - called with mutablepos... } -@@ -185,6 +222,7 @@ public class Turtle extends Animal { +@@ -188,6 +225,7 @@ public class Turtle extends Animal { @Override protected void registerGoals() { @@ -8956,8 +8866,8 @@ index d3c15d029d5f003cba3c89f7ea1f3ed4f943f2bd..1502f13acd0a104efe470e605826213e this.goalSelector.addGoal(0, new Turtle.TurtlePanicGoal(this, 1.2D)); this.goalSelector.addGoal(1, new Turtle.TurtleBreedGoal(this, 1.0D)); this.goalSelector.addGoal(1, new Turtle.TurtleLayEggGoal(this, 1.0D)); -@@ -342,13 +380,15 @@ public class Turtle extends Animal { - org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit +@@ -351,13 +389,15 @@ public class Turtle extends Animal { + return new Vector3f(0.0F, dimensions.height + (this.isBaby() ? 0.0F : 0.15625F) * scaleFactor, -0.25F * scaleFactor); } - private static class TurtleMoveControl extends MoveControl { @@ -8973,7 +8883,7 @@ index d3c15d029d5f003cba3c89f7ea1f3ed4f943f2bd..1502f13acd0a104efe470e605826213e } private void updateSpeed() { -@@ -367,8 +407,18 @@ public class Turtle extends Animal { +@@ -376,8 +416,18 @@ public class Turtle extends Animal { } @@ -8993,7 +8903,7 @@ index d3c15d029d5f003cba3c89f7ea1f3ed4f943f2bd..1502f13acd0a104efe470e605826213e this.updateSpeed(); if (this.operation == MoveControl.Operation.MOVE_TO && !this.turtle.getNavigation().isDone()) { double d0 = this.wantedX - this.turtle.getX(); -@@ -384,7 +434,7 @@ public class Turtle extends Animal { +@@ -393,7 +443,7 @@ public class Turtle extends Animal { this.turtle.setYRot(this.rotlerp(this.turtle.getYRot(), f, 90.0F)); this.turtle.yBodyRot = this.turtle.getYRot(); @@ -9015,7 +8925,7 @@ index cd2ce5bcb8c30e4657cd0e340d80544c7e805905..c8c6fed3f93903bb5c6145930538d415 } } diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java -index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba30e39d995 100644 +index eecb7511582e5e316b71fa4a4734881424be5ca7..5d49ed7ddf44a3d549b178ae548664194967776b 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java +++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java @@ -10,6 +10,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; @@ -9063,7 +8973,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.BlockPathTypes; -@@ -84,6 +91,37 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -86,6 +93,37 @@ public class Wolf extends TamableAnimal implements NeutralMob { return entitytypes == EntityType.SHEEP || entitytypes == EntityType.RABBIT || entitytypes == EntityType.FOX; }; @@ -9101,7 +9011,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 private static final float START_HEALTH = 8.0F; private static final float TAME_HEALTH = 20.0F; private float interestedAngle; -@@ -103,12 +141,93 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -105,12 +143,93 @@ public class Wolf extends TamableAnimal implements NeutralMob { this.setPathfindingMalus(BlockPathTypes.DANGER_POWDER_SNOW, -1.0F); } @@ -9195,7 +9105,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F)); this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true)); this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false)); -@@ -117,11 +236,12 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -119,11 +238,12 @@ public class Wolf extends TamableAnimal implements NeutralMob { this.goalSelector.addGoal(9, new BegGoal(this, 8.0F)); this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(10, new RandomLookAroundGoal(this)); @@ -9209,7 +9119,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR)); this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeleton.class, false)); this.targetSelector.addGoal(8, new ResetUniversalAngerTargetGoal<>(this, true)); -@@ -148,6 +268,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -150,6 +270,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { public void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); nbt.putByte("CollarColor", (byte) this.getCollarColor().getId()); @@ -9217,7 +9127,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.addPersistentAngerSaveData(nbt); } -@@ -157,6 +278,10 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -159,6 +280,10 @@ public class Wolf extends TamableAnimal implements NeutralMob { if (nbt.contains("CollarColor", 99)) { this.setCollarColor(DyeColor.byId(nbt.getInt("CollarColor"))); } @@ -9228,7 +9138,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.readPersistentAngerSaveData(this.level(), nbt); } -@@ -201,6 +326,11 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -203,6 +328,11 @@ public class Wolf extends TamableAnimal implements NeutralMob { public void tick() { super.tick(); if (this.isAlive()) { @@ -9240,7 +9150,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.interestedAngleO = this.interestedAngle; if (this.isInterested()) { this.interestedAngle += (1.0F - this.interestedAngle) * 0.4F; -@@ -405,7 +535,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -407,7 +537,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { } // CraftBukkit - added event call and isCancelled check. @@ -9249,7 +9159,7 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 this.tame(player); this.navigation.stop(); this.setTarget((LivingEntity) null); -@@ -416,6 +546,19 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -418,6 +548,19 @@ public class Wolf extends TamableAnimal implements NeutralMob { } return InteractionResult.SUCCESS; @@ -9270,10 +9180,10 @@ index 57ceec70bb150afaa66962090b142048d5b50c2f..64bceae4d06b35fcbecb0daca2496ba3 return super.mobInteract(player, hand); } diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a..7166f4a39fd615e10d7b1f53c57363832a41f365 100644 +index d241ca4d0295f9fce39c11197bd435cfac7f6e54..c783ce59ea766e6c46a3313628b961f27e01ee8b 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -101,10 +101,23 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -100,10 +100,23 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS private float spinningAnimationTicks; private float spinningAnimationTicks0; public boolean forceDancing = false; // CraftBukkit @@ -9298,7 +9208,7 @@ index 1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a..7166f4a39fd615e10d7b1f53c5736383 this.setCanPickUpLoot(this.canPickUpLoot()); this.vibrationUser = new Allay.VibrationUser(); this.vibrationData = new VibrationSystem.Data(); -@@ -118,6 +131,28 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -117,6 +130,28 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS } // CraftBukkit end @@ -9327,7 +9237,7 @@ index 1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a..7166f4a39fd615e10d7b1f53c5736383 @Override protected Brain.Provider brainProvider() { return Brain.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); -@@ -225,13 +260,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -224,13 +259,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS private int behaviorTick = 0; // Pufferfish @Override protected void customServerAiStep() { @@ -9346,7 +9256,7 @@ index 1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a..7166f4a39fd615e10d7b1f53c5736383 super.customServerAiStep(); } -@@ -372,9 +407,31 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -371,9 +406,31 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS @Override public boolean wantsToPickUp(ItemStack stack) { @@ -9382,7 +9292,7 @@ index 1a0eee3b766a5ce5623c32ed9c023a0f80db1d1a..7166f4a39fd615e10d7b1f53c5736383 private boolean allayConsidersItemEqual(ItemStack stack, ItemStack stack2) { diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 42e22a4b9cb6841de04862cc81454da3232aa65a..07abf72b7aed98652ac6639b26ade358fcd9135a 100644 +index eb1e850f11ed1cd8d2f1f2eb1af55b7fe6352ed4..61cd0e050a2784f1d59ed3c9493e2386ef5fc3bb 100644 --- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java @@ -98,6 +98,43 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder getModelRotationValues() { return this.modelRotationValues; -@@ -288,13 +325,13 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder optional = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS); -@@ -521,14 +558,22 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder { +@@ -79,16 +79,69 @@ public class Frog extends Animal implements VariantHolder { public final AnimationState croakAnimationState = new AnimationState(); public final AnimationState tongueAnimationState = new AnimationState(); public final AnimationState swimIdleAnimationState = new AnimationState(); @@ -9622,7 +9532,7 @@ index 80ddb3059d6484c2b90c55ef601043798f1a4b50..dc1e8bcd8049d79c0e383ccd6a5697f7 @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -165,13 +218,13 @@ public class Frog extends Animal implements VariantHolder { +@@ -167,13 +220,13 @@ public class Frog extends Animal implements VariantHolder { private int behaviorTick = 0; // Pufferfish @Override protected void customServerAiStep() { @@ -9641,7 +9551,7 @@ index 80ddb3059d6484c2b90c55ef601043798f1a4b50..dc1e8bcd8049d79c0e383ccd6a5697f7 super.customServerAiStep(); } -@@ -347,7 +400,7 @@ public class Frog extends Animal implements VariantHolder { +@@ -354,7 +407,7 @@ public class Frog extends Animal implements VariantHolder { return world.getBlockState(pos.below()).is(BlockTags.FROGS_SPAWNABLE_ON) && isBrightEnoughToSpawn(world, pos); } @@ -9726,10 +9636,10 @@ index 6ed4ac06c76b8d0d6e8db778cade15dbd1e3e5f5..6b012bea26e8ef0c04571f43da67f6e1 } diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -index 7f21d1d400c8a5615ed1a787dcb0680338f8c28d..b04af8b72357b455597d80592c8b8b0c9da744cd 100644 +index ff12ba2b79cb2e7e0bfd0e3b58ff6cb9e770092b..5d7b20c30bc5e3be8511b300c318d12a1e4a49d0 100644 --- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java +++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -@@ -90,6 +90,38 @@ public class Goat extends Animal { +@@ -92,6 +92,38 @@ public class Goat extends Animal { return InstrumentItem.create(Items.GOAT_HORN, (Holder) holderset.getRandomElement(randomsource).get()); } @@ -9768,15 +9678,14 @@ index 7f21d1d400c8a5615ed1a787dcb0680338f8c28d..b04af8b72357b455597d80592c8b8b0c @Override protected Brain.Provider brainProvider() { return Brain.provider(Goat.MEMORY_TYPES, Goat.SENSOR_TYPES); -@@ -192,13 +224,14 @@ public class Goat extends Animal { +@@ -194,13 +226,13 @@ public class Goat extends Animal { private int behaviorTick = 0; // Pufferfish @Override protected void customServerAiStep() { - this.level().getProfiler().push("goatBrain"); - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + //this.level().getProfiler().push("goatBrain"); // Purpur -+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Purpur - TODO: Uncomment when pufferfish patch -+ //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Purpur - TODO: Uncomment when pufferfish patch ++ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider this.getBrain().tick((ServerLevel) this.level(), this); - this.level().getProfiler().pop(); - this.level().getProfiler().push("goatActivityUpdate"); @@ -9788,7 +9697,7 @@ index 7f21d1d400c8a5615ed1a787dcb0680338f8c28d..b04af8b72357b455597d80592c8b8b0c super.customServerAiStep(); } -@@ -390,6 +423,7 @@ public class Goat extends Animal { +@@ -397,6 +429,7 @@ public class Goat extends Animal { // Paper start - Goat ram API public void ram(net.minecraft.world.entity.LivingEntity entity) { @@ -9797,10 +9706,10 @@ index 7f21d1d400c8a5615ed1a787dcb0680338f8c28d..b04af8b72357b455597d80592c8b8b0c brain.setMemory(MemoryModuleType.RAM_TARGET, entity.position()); brain.eraseMemory(MemoryModuleType.RAM_COOLDOWN_TICKS); diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -index 49d7109b6ca63c8073db777549a65b2fcb70967e..fdf41f4990923aa4309febb9c0ca8009de8e16f1 100644 +index 09e9c0e55c789f03a4b64136f28154bd114db6f5..d3b655ccf40d24b7f5a09383fd5771bb275ac4b7 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -147,12 +147,60 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, +@@ -149,12 +149,60 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, protected AbstractHorse(EntityType type, Level world) { super(type, world); @@ -9861,7 +9770,7 @@ index 49d7109b6ca63c8073db777549a65b2fcb70967e..fdf41f4990923aa4309febb9c0ca8009 this.goalSelector.addGoal(1, new PanicGoal(this, 1.2D)); this.goalSelector.addGoal(1, new RunAroundLikeCrazyGoal(this, 1.2D)); this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D, AbstractHorse.class)); -@@ -163,6 +211,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, +@@ -165,6 +213,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, if (this.canPerformRearing()) { this.goalSelector.addGoal(9, new RandomStandGoal(this)); } @@ -9869,7 +9778,7 @@ index 49d7109b6ca63c8073db777549a65b2fcb70967e..fdf41f4990923aa4309febb9c0ca8009 this.addBehaviourGoals(); } -@@ -335,7 +384,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, +@@ -337,7 +386,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, @Override protected int calculateFallDamage(float fallDistance, float damageMultiplier) { @@ -9878,7 +9787,7 @@ index 49d7109b6ca63c8073db777549a65b2fcb70967e..fdf41f4990923aa4309febb9c0ca8009 } protected int getInventorySize() { -@@ -1247,7 +1296,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, +@@ -1234,7 +1283,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, entityData = new AgeableMob.AgeableMobGroupData(0.2F); } @@ -9984,10 +9893,10 @@ index 5f5dc651d570989ec1294c31a14dcfede466b80a..3b1faa63e46a48e83ea672cf6da444a1 protected void randomizeAttributes(RandomSource random) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue((double)generateMaxHealth(random::nextInt)); diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java -index d28089c37707f323f73e60cb0ebed4e3cdf8c0fd..a9f36af3e07f74b3d11697d5fad9f0a469844779 100644 +index 5f61c97478f005aaaaad1b027118079db7275cf7..9288327a365bc67c5bb8ed6aa23b78c725d5ba40 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java -@@ -73,9 +73,84 @@ public class Llama extends AbstractChestedHorse implements VariantHolder type, Level world) { super(type, world); this.setMaxUpStep(1.0F); @@ -11883,7 +11793,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf this.goalSelector.addGoal(1, new EnderMan.EndermanFreezeWhenLookedAt(this)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.0D, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D, 0.0F)); -@@ -106,9 +134,10 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -108,9 +136,10 @@ public class EnderMan extends Monster implements NeutralMob { this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.goalSelector.addGoal(10, new EnderMan.EndermanLeaveBlockGoal(this)); this.goalSelector.addGoal(11, new EnderMan.EndermanTakeBlockGoal(this)); @@ -11895,7 +11805,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, false)); } -@@ -245,7 +274,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -247,7 +276,7 @@ public class EnderMan extends Monster implements NeutralMob { // Paper end ItemStack itemstack = (ItemStack) player.getInventory().armor.get(3); @@ -11904,7 +11814,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf return false; } else { Vec3 vec3d = player.getViewVector(1.0F).normalize(); -@@ -282,12 +311,12 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -289,12 +318,12 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean isSensitiveToWater() { @@ -11919,7 +11829,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf float f = this.getLightLevelDependentMagicValue(); if (f > 0.5F && this.level().canSeeSky(this.blockPosition()) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.RUNAWAY)) { // Paper -@@ -408,6 +437,8 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -415,6 +444,8 @@ public class EnderMan extends Monster implements NeutralMob { public boolean hurt(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { return false; @@ -11928,7 +11838,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf } else { boolean flag = source.getDirectEntity() instanceof ThrownPotion; boolean flag1; -@@ -422,6 +453,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -429,6 +460,7 @@ public class EnderMan extends Monster implements NeutralMob { } else { flag1 = flag && this.hurtWithCleanWater(source, (ThrownPotion) source.getDirectEntity(), amount); @@ -11936,7 +11846,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper start for (int i = 0; i < 64; ++i) { if (this.teleport()) { -@@ -468,7 +500,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -475,7 +507,7 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean requiresCustomPersistence() { @@ -11945,7 +11855,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf } private static class EndermanFreezeWhenLookedAt extends Goal { -@@ -515,7 +547,16 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -522,7 +554,16 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean canUse() { @@ -11963,7 +11873,7 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf } @Override -@@ -560,7 +601,16 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -567,7 +608,16 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean canUse() { @@ -11982,10 +11892,10 @@ index 410f10ad93935d1c078447a4596023f367a8e9b7..44331be61edffd5afadf3e637dd181bf @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/Endermite.java b/src/main/java/net/minecraft/world/entity/monster/Endermite.java -index 29b8771ec85f07fcd9d9ba041c9a25a212009b16..e131949bd6aab4c8ff5cd4ea57280ad945ceef67 100644 +index 66b6c55f72aec7e4e9dfa5417a46ba68dbb16a83..20ca96baf8f73fd5835422c6551f515a394cb168 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Endermite.java +++ b/src/main/java/net/minecraft/world/entity/monster/Endermite.java -@@ -31,20 +31,63 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -32,20 +32,63 @@ import org.joml.Vector3f; public class Endermite extends Monster { private static final int MAX_LIFE = 2400; public int life; @@ -12049,7 +11959,7 @@ index 29b8771ec85f07fcd9d9ba041c9a25a212009b16..e131949bd6aab4c8ff5cd4ea57280ad9 this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers()); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); } -@@ -87,12 +130,14 @@ public class Endermite extends Monster { +@@ -88,12 +131,14 @@ public class Endermite extends Monster { public void readAdditionalSaveData(CompoundTag nbt) { super.readAdditionalSaveData(nbt); this.life = nbt.getInt("Lifetime"); @@ -12065,10 +11975,10 @@ index 29b8771ec85f07fcd9d9ba041c9a25a212009b16..e131949bd6aab4c8ff5cd4ea57280ad9 @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/Evoker.java b/src/main/java/net/minecraft/world/entity/monster/Evoker.java -index a6dde4e31790eaecff27135a4036627192c85702..4a87b76cc92220f6569b976871a86c8eab3c218d 100644 +index 7f0fbca7638bf89465bafed9d106813b86f0149b..4095f03ccd1712335baffe858603618100aed99c 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Evoker.java +++ b/src/main/java/net/minecraft/world/entity/monster/Evoker.java -@@ -48,10 +48,43 @@ public class Evoker extends SpellcasterIllager { +@@ -50,10 +50,43 @@ public class Evoker extends SpellcasterIllager { this.xpReward = 10; } @@ -12112,7 +12022,7 @@ index a6dde4e31790eaecff27135a4036627192c85702..4a87b76cc92220f6569b976871a86c8e this.goalSelector.addGoal(1, new Evoker.EvokerCastingSpellGoal()); this.goalSelector.addGoal(2, new AvoidEntityGoal<>(this, Player.class, 8.0F, 0.6D, 1.0D)); this.goalSelector.addGoal(4, new Evoker.EvokerSummonSpellGoal()); -@@ -60,6 +93,7 @@ public class Evoker extends SpellcasterIllager { +@@ -62,6 +95,7 @@ public class Evoker extends SpellcasterIllager { this.goalSelector.addGoal(8, new RandomStrollGoal(this, 0.6D)); this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 3.0F, 1.0F)); this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F)); @@ -12120,7 +12030,7 @@ index a6dde4e31790eaecff27135a4036627192c85702..4a87b76cc92220f6569b976871a86c8e this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Raider.class})).setAlertOthers()); this.targetSelector.addGoal(2, (new NearestAttackableTargetGoal<>(this, Player.class, true)).setUnseenMemoryTicks(300)); this.targetSelector.addGoal(3, (new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)).setUnseenMemoryTicks(300)); -@@ -317,7 +351,7 @@ public class Evoker extends SpellcasterIllager { +@@ -321,7 +355,7 @@ public class Evoker extends SpellcasterIllager { return false; } else if (Evoker.this.tickCount < this.nextAttackTickCount) { return false; @@ -12130,10 +12040,10 @@ index a6dde4e31790eaecff27135a4036627192c85702..4a87b76cc92220f6569b976871a86c8e } else { List list = Evoker.this.level().getNearbyEntities(Sheep.class, this.wololoTargeting, Evoker.this, Evoker.this.getBoundingBox().inflate(16.0D, 4.0D, 16.0D)); diff --git a/src/main/java/net/minecraft/world/entity/monster/Ghast.java b/src/main/java/net/minecraft/world/entity/monster/Ghast.java -index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4da842fb3 100644 +index c135bc245f59a1af706f98b9d140dee77016b12f..640f0c378a18cf0a820ad544bb3b172b698c6bfc 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Ghast.java +++ b/src/main/java/net/minecraft/world/entity/monster/Ghast.java -@@ -44,11 +44,47 @@ public class Ghast extends FlyingMob implements Enemy { +@@ -45,11 +45,47 @@ public class Ghast extends FlyingMob implements Enemy { this.moveControl = new Ghast.GhastMoveControl(this); } @@ -12181,7 +12091,7 @@ index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4 this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entityliving) -> { return Math.abs(entityliving.getY() - this.getY()) <= 4.0D; })); -@@ -96,6 +132,21 @@ public class Ghast extends FlyingMob implements Enemy { +@@ -97,6 +133,21 @@ public class Ghast extends FlyingMob implements Enemy { } } @@ -12203,7 +12113,7 @@ index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4 @Override protected void defineSynchedData() { super.defineSynchedData(); -@@ -103,7 +154,7 @@ public class Ghast extends FlyingMob implements Enemy { +@@ -104,7 +155,7 @@ public class Ghast extends FlyingMob implements Enemy { } public static AttributeSupplier.Builder createAttributes() { @@ -12212,7 +12122,7 @@ index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4 } @Override -@@ -160,7 +211,7 @@ public class Ghast extends FlyingMob implements Enemy { +@@ -171,7 +222,7 @@ public class Ghast extends FlyingMob implements Enemy { return 2.6F; } @@ -12221,7 +12131,7 @@ index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4 private final Ghast ghast; private int floatDuration; -@@ -171,7 +222,7 @@ public class Ghast extends FlyingMob implements Enemy { +@@ -182,7 +233,7 @@ public class Ghast extends FlyingMob implements Enemy { } @Override @@ -12231,16 +12141,17 @@ index 592b0dae251800552a0771ec46b4b8532b63075d..b0aad5778a12d3f0f2ef806f856064c4 if (this.floatDuration-- <= 0) { this.floatDuration += this.ghast.getRandom().nextInt(5) + 2; diff --git a/src/main/java/net/minecraft/world/entity/monster/Giant.java b/src/main/java/net/minecraft/world/entity/monster/Giant.java -index 41004c28edb748e12c4f868aa07b4672891197c1..88b0dffe2c2b4da1406f218186d28f018ee879a3 100644 +index 793c72bb7b86e404926085629121d6cad19a2740..d13eed85d5399cd6991b3ad90f05a5805a3a2678 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Giant.java +++ b/src/main/java/net/minecraft/world/entity/monster/Giant.java -@@ -1,17 +1,122 @@ +@@ -1,18 +1,123 @@ package net.minecraft.world.entity.monster; import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.Difficulty; +import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EquipmentSlot; @@ -12357,7 +12268,7 @@ index 41004c28edb748e12c4f868aa07b4672891197c1..88b0dffe2c2b4da1406f218186d28f01 } @Override -@@ -25,6 +130,6 @@ public class Giant extends Monster { +@@ -31,6 +136,6 @@ public class Giant extends Monster { @Override public float getWalkTargetValue(BlockPos pos, LevelReader world) { @@ -12366,10 +12277,10 @@ index 41004c28edb748e12c4f868aa07b4672891197c1..88b0dffe2c2b4da1406f218186d28f01 } } diff --git a/src/main/java/net/minecraft/world/entity/monster/Guardian.java b/src/main/java/net/minecraft/world/entity/monster/Guardian.java -index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce230581f146 100644 +index 45300f79cba6133d2a2eca706eae03ee3cd973c3..54113957c9cfab2ad3be25dbc05b8c29d1a064d5 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Guardian.java +++ b/src/main/java/net/minecraft/world/entity/monster/Guardian.java -@@ -69,15 +69,51 @@ public class Guardian extends Monster { +@@ -70,15 +70,51 @@ public class Guardian extends Monster { this.xpReward = 10; this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); this.moveControl = new Guardian.GuardianMoveControl(this); @@ -12421,7 +12332,7 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 this.goalSelector.addGoal(4, this.guardianAttackGoal = new Guardian.GuardianAttackGoal(this)); // CraftBukkit - assign field this.goalSelector.addGoal(5, pathfindergoalmovetowardsrestriction); this.goalSelector.addGoal(7, this.randomStrollGoal); -@@ -86,6 +122,7 @@ public class Guardian extends Monster { +@@ -87,6 +123,7 @@ public class Guardian extends Monster { this.goalSelector.addGoal(9, new RandomLookAroundGoal(this)); this.randomStrollGoal.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); pathfindergoalmovetowardsrestriction.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); @@ -12429,7 +12340,7 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, LivingEntity.class, 10, true, false, new Guardian.GuardianAttackSelector(this))); } -@@ -351,7 +388,7 @@ public class Guardian extends Monster { +@@ -352,7 +389,7 @@ public class Guardian extends Monster { @Override public void travel(Vec3 movementInput) { if (this.isControlledByLocalInstance() && this.isInWater()) { @@ -12438,8 +12349,8 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 this.move(MoverType.SELF, this.getDeltaMovement()); this.setDeltaMovement(this.getDeltaMovement().scale(0.9D)); if (!this.isMoving() && this.getTarget() == null) { -@@ -363,7 +400,7 @@ public class Guardian extends Monster { - +@@ -369,7 +406,7 @@ public class Guardian extends Monster { + return new Vector3f(0.0F, dimensions.height + 0.125F * scaleFactor, 0.0F); } - private static class GuardianMoveControl extends MoveControl { @@ -12447,7 +12358,7 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 private final Guardian guardian; -@@ -372,8 +409,17 @@ public class Guardian extends Monster { +@@ -378,8 +415,17 @@ public class Guardian extends Monster { this.guardian = guardian; } @@ -12466,7 +12377,7 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 if (this.operation == MoveControl.Operation.MOVE_TO && !this.guardian.getNavigation().isDone()) { Vec3 vec3d = new Vec3(this.wantedX - this.guardian.getX(), this.wantedY - this.guardian.getY(), this.wantedZ - this.guardian.getZ()); double d0 = vec3d.length(); -@@ -384,7 +430,7 @@ public class Guardian extends Monster { +@@ -390,7 +436,7 @@ public class Guardian extends Monster { this.guardian.setYRot(this.rotlerp(this.guardian.getYRot(), f, 90.0F)); this.guardian.yBodyRot = this.guardian.getYRot(); @@ -12476,10 +12387,10 @@ index 5e9b9e9f124ec6103b2e832ae94bc5b334a2c533..96338ed7952683f56d9a406d0956ce23 this.guardian.setSpeed(f2); diff --git a/src/main/java/net/minecraft/world/entity/monster/Husk.java b/src/main/java/net/minecraft/world/entity/monster/Husk.java -index efe8e6b895da1a81e5de42697fda58443cf15a59..cd78fbca21112a2354bc40747531e5202bbd5f20 100644 +index 8ef1e325d722ca36fc0fc36f1e5287d7002b9fb2..473f28e86a0e5157264b83d9c3c4a18c72216da3 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Husk.java +++ b/src/main/java/net/minecraft/world/entity/monster/Husk.java -@@ -20,6 +20,59 @@ public class Husk extends Zombie { +@@ -22,6 +22,59 @@ public class Husk extends Zombie { public Husk(EntityType type, Level world) { super(type, world); @@ -12539,7 +12450,7 @@ index efe8e6b895da1a81e5de42697fda58443cf15a59..cd78fbca21112a2354bc40747531e520 } public static boolean checkHuskSpawnRules(EntityType type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) { -@@ -28,7 +81,7 @@ public class Husk extends Zombie { +@@ -30,7 +83,7 @@ public class Husk extends Zombie { @Override public boolean isSunSensitive() { @@ -12703,10 +12614,10 @@ index 55c245d0dfa369dc6de2197ae37335fba4fae4ae..c9b40515f4c2ff1eedfc9510930c3bae return false; } else { diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c7590b98dba6 100644 +index 5b4719dd7c3b8f93c898779f45239568f6a5fe43..355445b7f8972cb789d33f59d03c382f238c294d 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java +++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -@@ -49,6 +49,8 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -50,6 +50,8 @@ public class Phantom extends FlyingMob implements Enemy { Vec3 moveTargetPoint; public BlockPos anchorPoint; Phantom.AttackPhase attackPhase; @@ -12715,7 +12626,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 public Phantom(EntityType type, Level world) { super(type, world); -@@ -58,6 +60,92 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -59,6 +61,92 @@ public class Phantom extends FlyingMob implements Enemy { this.xpReward = 5; this.moveControl = new Phantom.PhantomMoveControl(this); this.lookControl = new Phantom.PhantomLookControl(this); @@ -12808,7 +12719,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 } @Override -@@ -72,9 +160,17 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -73,9 +161,17 @@ public class Phantom extends FlyingMob implements Enemy { @Override protected void registerGoals() { @@ -12829,7 +12740,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 this.targetSelector.addGoal(1, new Phantom.PhantomAttackPlayerTargetGoal()); } -@@ -90,7 +186,10 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -91,7 +187,10 @@ public class Phantom extends FlyingMob implements Enemy { private void updatePhantomSizeInfo() { this.refreshDimensions(); @@ -12841,7 +12752,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 } public int getPhantomSize() { -@@ -120,6 +219,21 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -121,6 +220,21 @@ public class Phantom extends FlyingMob implements Enemy { return true; } @@ -12863,7 +12774,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 @Override public void tick() { super.tick(); -@@ -140,14 +254,12 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -141,14 +255,12 @@ public class Phantom extends FlyingMob implements Enemy { this.level().addParticle(ParticleTypes.MYCELIUM, this.getX() - (double) f2, this.getY() + (double) f4, this.getZ() - (double) f3, 0.0D, 0.0D, 0.0D); } @@ -12880,7 +12791,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 super.aiStep(); } -@@ -159,7 +271,11 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -160,7 +272,11 @@ public class Phantom extends FlyingMob implements Enemy { @Override public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData, @Nullable CompoundTag entityNbt) { this.anchorPoint = this.blockPosition().above(5); @@ -12893,7 +12804,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); } -@@ -175,7 +291,7 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -176,7 +292,7 @@ public class Phantom extends FlyingMob implements Enemy { if (nbt.hasUUID("Paper.SpawningEntity")) { this.spawningEntity = nbt.getUUID("Paper.SpawningEntity"); } @@ -12902,7 +12813,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); } // Paper end -@@ -192,7 +308,7 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -193,7 +309,7 @@ public class Phantom extends FlyingMob implements Enemy { if (this.spawningEntity != null) { nbt.putUUID("Paper.SpawningEntity", this.spawningEntity); } @@ -12911,7 +12822,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 // Paper end } -@@ -258,8 +374,14 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -263,8 +379,14 @@ public class Phantom extends FlyingMob implements Enemy { } public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; } @@ -12928,7 +12839,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } // Paper end private static enum AttackPhase { -@@ -269,7 +391,125 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -274,7 +396,125 @@ public class Phantom extends FlyingMob implements Enemy { private AttackPhase() {} } @@ -13055,7 +12966,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 private float speed = 0.1F; -@@ -277,8 +517,19 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -282,8 +522,19 @@ public class Phantom extends FlyingMob implements Enemy { super(entity); } @@ -13076,7 +12987,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 if (Phantom.this.horizontalCollision) { Phantom.this.setYRot(Phantom.this.getYRot() + 180.0F); this.speed = 0.1F; -@@ -324,14 +575,20 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -329,14 +580,20 @@ public class Phantom extends FlyingMob implements Enemy { } } @@ -13099,7 +13010,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 } private class PhantomBodyRotationControl extends BodyRotationControl { -@@ -418,6 +675,12 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -423,6 +680,12 @@ public class Phantom extends FlyingMob implements Enemy { return false; } else if (!entityliving.isAlive()) { return false; @@ -13112,7 +13023,7 @@ index 4a132c3eff6978e927bcd4df56b9ce0306af6d19..17638b9d3340c86528a8ae597712c759 } else { if (entityliving instanceof Player) { Player entityhuman = (Player) entityliving; -@@ -563,6 +826,7 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -568,6 +831,7 @@ public class Phantom extends FlyingMob implements Enemy { this.nextScanTick = reducedTickDelay(60); List list = Phantom.this.level().getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); @@ -13175,10 +13086,10 @@ index cec545c3baa6599d47b9cf1a4b97de8771062a22..06d52d8b61abc4dbbdc953bfed2e688b this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java -index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747d170178e 100644 +index 0c11d9bef8f0129c541e30ad057612e881703b24..c9c21c87e3bd1c404fbef6768761bcb5d97d98b9 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java +++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java -@@ -68,14 +68,54 @@ public class Ravager extends Raider { +@@ -71,14 +71,54 @@ public class Ravager extends Raider { this.setPathfindingMalus(BlockPathTypes.LEAVES, 0.0F); } @@ -13225,7 +13136,7 @@ index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747 super.registerGoals(); this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - this.goalSelector.addGoal(4, new Ravager.RavagerMeleeAttackGoal()); + this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0D, true)); this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.4D)); this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F)); this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F)); @@ -13233,7 +13144,7 @@ index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747 this.targetSelector.addGoal(2, (new HurtByTargetGoal(this, new Class[]{Raider.class})).setAlertOthers()); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, true)); this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, true, (entityliving) -> { -@@ -153,7 +193,7 @@ public class Ravager extends Raider { +@@ -136,7 +176,7 @@ public class Ravager extends Raider { @Override public void aiStep() { super.aiStep(); @@ -13242,7 +13153,7 @@ index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747 if (this.isImmobile()) { this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.0D); } else { -@@ -163,7 +203,7 @@ public class Ravager extends Raider { +@@ -146,7 +186,7 @@ public class Ravager extends Raider { this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1D, d1, d0)); } @@ -13251,7 +13162,7 @@ index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747 boolean flag = false; AABB axisalignedbb = this.getBoundingBox().inflate(0.2D); Iterator iterator = BlockPos.betweenClosed(Mth.floor(axisalignedbb.minX), Mth.floor(axisalignedbb.minY), Mth.floor(axisalignedbb.minZ), Mth.floor(axisalignedbb.maxX), Mth.floor(axisalignedbb.maxY), Mth.floor(axisalignedbb.maxZ)).iterator(); -@@ -173,7 +213,7 @@ public class Ravager extends Raider { +@@ -156,7 +196,7 @@ public class Ravager extends Raider { BlockState iblockdata = this.level().getBlockState(blockposition); Block block = iblockdata.getBlock(); @@ -13261,7 +13172,7 @@ index e87c6c8ab585d6b0b38bbb8e42c0082e38f03250..0211b50ce4b48a26698f1ece8b593747 if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state continue; diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java -index d2073de07bdad71b20e05046577b16649123967b..3e2c60a301d4c66c85cd8ff812331005a667dc4e 100644 +index 8cb6f2d32c4b7a62ec1bdfeb8b661a1387cafe4b..81caa18fca658f70846ba437ac02906f5e9653b9 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java +++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java @@ -22,6 +22,8 @@ import net.minecraft.tags.DamageTypeTags; @@ -13273,16 +13184,16 @@ index d2073de07bdad71b20e05046577b16649123967b..3e2c60a301d4c66c85cd8ff812331005 import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; -@@ -50,6 +52,8 @@ import net.minecraft.world.entity.projectile.AbstractArrow; +@@ -49,6 +51,8 @@ import net.minecraft.world.entity.player.Player; + import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.ShulkerBullet; - import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.DyeItem; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.block.Blocks; -@@ -98,12 +102,59 @@ public class Shulker extends AbstractGolem implements VariantHolder getVariant() { @@ -13378,7 +13289,7 @@ index d2073de07bdad71b20e05046577b16649123967b..3e2c60a301d4c66c85cd8ff812331005 } @Nullable -@@ -609,7 +669,7 @@ public class Shulker extends AbstractGolem implements VariantHolder(this, Player.class, true)); } -@@ -184,7 +218,7 @@ public class Silverfish extends Monster { +@@ -186,7 +220,7 @@ public class Silverfish extends Monster { continue; } // CraftBukkit end @@ -13449,7 +13360,7 @@ index 8d1f99f95a08eac98c6a03c6e534fc1997f8fe71..83641c7cf51453e98809900e23f44a68 world.destroyBlock(blockposition1, true, this.silverfish); } else { world.setBlock(blockposition1, ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)), 3); -@@ -222,7 +256,7 @@ public class Silverfish extends Monster { +@@ -224,7 +258,7 @@ public class Silverfish extends Monster { } else { RandomSource randomsource = this.mob.getRandom(); @@ -13587,10 +13498,10 @@ index 8b818a7cb835512c4bd2ea9641d4bfd904150332..f4a47ac2c86cc95178922cce7320ba1e + // Purpur end } diff --git a/src/main/java/net/minecraft/world/entity/monster/Slime.java b/src/main/java/net/minecraft/world/entity/monster/Slime.java -index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811aeef4d7b 100644 +index b14979ab7bed34a37fceff5589ecb789bab31318..e2eb27a60fde8a937ad1101bbda54c89ef358826 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Slime.java +++ b/src/main/java/net/minecraft/world/entity/monster/Slime.java -@@ -64,6 +64,7 @@ public class Slime extends Mob implements Enemy { +@@ -61,6 +61,7 @@ public class Slime extends Mob implements Enemy { public float squish; public float oSquish; private boolean wasOnGround; @@ -13598,7 +13509,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 public Slime(EntityType type, Level world) { super(type, world); -@@ -71,12 +72,89 @@ public class Slime extends Mob implements Enemy { +@@ -68,12 +69,89 @@ public class Slime extends Mob implements Enemy { this.moveControl = new Slime.SlimeMoveControl(this); } @@ -13688,7 +13599,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entityliving) -> { return Math.abs(entityliving.getY() - this.getY()) <= 4.0D; })); -@@ -96,9 +174,9 @@ public class Slime extends Mob implements Enemy { +@@ -98,9 +176,9 @@ public class Slime extends Mob implements Enemy { this.entityData.set(Slime.ID_SIZE, j); this.reapplyPosition(); this.refreshDimensions(); @@ -13700,7 +13611,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 if (heal) { this.setHealth(this.getMaxHealth()); } -@@ -368,11 +446,12 @@ public class Slime extends Mob implements Enemy { +@@ -375,11 +453,12 @@ public class Slime extends Mob implements Enemy { } @Override @@ -13714,7 +13625,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 } @Nullable -@@ -406,7 +485,7 @@ public class Slime extends Mob implements Enemy { +@@ -413,7 +492,7 @@ public class Slime extends Mob implements Enemy { return super.getDimensions(pose).scale(0.255F * (float) this.getSize()); } @@ -13723,7 +13634,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 private float yRot; private int jumpDelay; -@@ -425,21 +504,33 @@ public class Slime extends Mob implements Enemy { +@@ -432,21 +511,33 @@ public class Slime extends Mob implements Enemy { } public void setWantedMovement(double speed) { @@ -13760,7 +13671,7 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 if (this.jumpDelay-- <= 0) { this.jumpDelay = this.slime.getJumpDelay(); if (this.isAggressive) { -@@ -456,7 +547,7 @@ public class Slime extends Mob implements Enemy { +@@ -463,7 +554,7 @@ public class Slime extends Mob implements Enemy { this.mob.setSpeed(0.0F); } } else { @@ -13770,10 +13681,10 @@ index 343433158507451152e5b2fc5e5fd0b0e6b229db..467337542551dedc05d922bb3a37b811 } diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java -index 05432184077752b1d0cb764a5e39ed875748b2d6..b3ab0f8cdbd678970e39e89c2062772374466b67 100644 +index 71b5a9c97a13f703073c0122742ff9e8a0e49df2..42252e86ca02955ba8cae913081795b57e04c934 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Spider.java +++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java -@@ -51,14 +51,48 @@ public class Spider extends Monster { +@@ -53,14 +53,48 @@ public class Spider extends Monster { super(type, world); } @@ -13866,7 +13777,7 @@ index 118b636a44e4b062e812e433f603b039276337da..a95e983032b3d3d125a39a46700b7db9 BlockPos blockPos = pos; diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java -index ebf54d6e36fdee2833250816fae14195ac45eb67..cfa603c7ccaaf1940aa89fa7cd8fafba29529075 100644 +index 61162ecd43dc5e6f7898daecdec49f444e6d869b..2f49b528601a1feb7246fe7a9b83ce828c2d78fc 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Strider.java +++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java @@ -94,12 +94,44 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { @@ -13918,12 +13829,12 @@ index ebf54d6e36fdee2833250816fae14195ac45eb67..cfa603c7ccaaf1940aa89fa7cd8fafba @@ -161,6 +193,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { @Override protected void registerGoals() { - this.panicGoal = new PanicGoal(this, 1.65D); + this.goalSelector.addGoal(1, new PanicGoal(this, 1.65D)); + this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - this.goalSelector.addGoal(1, this.panicGoal); this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D)); this.temptGoal = new TemptGoal(this, 1.4D, Strider.TEMPT_ITEMS, false); -@@ -416,7 +449,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { + this.goalSelector.addGoal(3, this.temptGoal); +@@ -414,7 +447,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { @Override public boolean isSensitiveToWater() { @@ -13932,7 +13843,7 @@ index ebf54d6e36fdee2833250816fae14195ac45eb67..cfa603c7ccaaf1940aa89fa7cd8fafba } @Override -@@ -458,6 +491,19 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { +@@ -456,6 +489,19 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { public InteractionResult mobInteract(Player player, InteractionHand hand) { boolean flag = this.isFood(player.getItemInHand(hand)); @@ -13952,7 +13863,7 @@ index ebf54d6e36fdee2833250816fae14195ac45eb67..cfa603c7ccaaf1940aa89fa7cd8fafba if (!flag && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) { if (!this.level().isClientSide) { player.startRiding(this); -@@ -470,7 +516,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { +@@ -468,7 +514,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { if (!enuminteractionresult.consumesAction()) { ItemStack itemstack = player.getItemInHand(hand); @@ -13962,7 +13873,7 @@ index ebf54d6e36fdee2833250816fae14195ac45eb67..cfa603c7ccaaf1940aa89fa7cd8fafba if (flag && !this.isSilent()) { this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.STRIDER_EAT, this.getSoundSource(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java -index 65cb385ab294e362d666a6d03c4496cdc3b64890..5db70031c8c9ba901a360c758d51222efe911fcc 100644 +index 90e577b1a89b02c38daff2845a63dafe5ed929e1..be1c9a7e2bafb33dcb954ba9fd427c033bb7542f 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Vex.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java @@ -63,6 +63,65 @@ public class Vex extends Monster implements TraceableEntity { @@ -14061,8 +13972,8 @@ index 65cb385ab294e362d666a6d03c4496cdc3b64890..5db70031c8c9ba901a360c758d51222e } @Override -@@ -235,14 +296,14 @@ public class Vex extends Monster implements TraceableEntity { - return 0.4D; +@@ -240,14 +301,14 @@ public class Vex extends Monster implements TraceableEntity { + return new Vector3f(0.0F, dimensions.height - 0.0625F * scaleFactor, 0.0F); } - private class VexMoveControl extends MoveControl { @@ -14078,7 +13989,7 @@ index 65cb385ab294e362d666a6d03c4496cdc3b64890..5db70031c8c9ba901a360c758d51222e if (this.operation == MoveControl.Operation.MOVE_TO) { Vec3 vec3d = new Vec3(this.wantedX - Vex.this.getX(), this.wantedY - Vex.this.getY(), this.wantedZ - Vex.this.getZ()); double d0 = vec3d.length(); -@@ -251,7 +312,7 @@ public class Vex extends Monster implements TraceableEntity { +@@ -256,7 +317,7 @@ public class Vex extends Monster implements TraceableEntity { this.operation = MoveControl.Operation.WAIT; Vex.this.setDeltaMovement(Vex.this.getDeltaMovement().scale(0.5D)); } else { @@ -14088,7 +13999,7 @@ index 65cb385ab294e362d666a6d03c4496cdc3b64890..5db70031c8c9ba901a360c758d51222e Vec3 vec3d1 = Vex.this.getDeltaMovement(); diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java -index 2acc531bd9e948251cac77d979f973678f576394..f1e410b602bf0d5520f8e9340f7b8b9e25ca4d39 100644 +index ad41bbbf5395ed18c2c9e1e692c7661a6e0cb98c..ffe956f200dd0b4148043d0d7f2eac007a9f22b1 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java @@ -58,14 +58,48 @@ public class Vindicator extends AbstractIllager { @@ -14135,7 +14046,7 @@ index 2acc531bd9e948251cac77d979f973678f576394..f1e410b602bf0d5520f8e9340f7b8b9e this.goalSelector.addGoal(1, new Vindicator.VindicatorBreakDoorGoal(this)); this.goalSelector.addGoal(2, new AbstractIllager.RaiderOpenDoorGoal(this)); this.goalSelector.addGoal(3, new Raider.HoldGroundAttackGoal(this, 10.0F)); - this.goalSelector.addGoal(4, new Vindicator.VindicatorMeleeAttackGoal(this)); + this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0D, false)); + this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, Raider.class)).setAlertOthers()); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -14154,10 +14065,10 @@ index 2acc531bd9e948251cac77d979f973678f576394..f1e410b602bf0d5520f8e9340f7b8b9e } diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java -index 701f6bf1d558cf0ec4bc1abb9e1f66d96ea5a6c9..80e90202eae1e12d5261d0bb77ecfadcc9ac4599 100644 +index 580dff41d746d9591f718081d9dfe4ac77e7eeaa..1f19be94995d02596306fa49e19582b3deb1924a 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Witch.java +++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java -@@ -57,6 +57,38 @@ public class Witch extends Raider implements RangedAttackMob { +@@ -59,6 +59,38 @@ public class Witch extends Raider implements RangedAttackMob { super(type, world); } @@ -14196,7 +14107,7 @@ index 701f6bf1d558cf0ec4bc1abb9e1f66d96ea5a6c9..80e90202eae1e12d5261d0bb77ecfadc @Override protected void registerGoals() { super.registerGoals(); -@@ -65,10 +97,12 @@ public class Witch extends Raider implements RangedAttackMob { +@@ -67,10 +99,12 @@ public class Witch extends Raider implements RangedAttackMob { }); this.attackPlayersGoal = new NearestAttackableWitchTargetGoal<>(this, Player.class, 10, true, false, (Predicate) null); this.goalSelector.addGoal(1, new FloatGoal(this)); @@ -14210,7 +14121,7 @@ index 701f6bf1d558cf0ec4bc1abb9e1f66d96ea5a6c9..80e90202eae1e12d5261d0bb77ecfadc this.targetSelector.addGoal(2, this.healRaidersGoal); this.targetSelector.addGoal(3, this.attackPlayersGoal); diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java -index 9a81cb0c3a5ac40ff50dc7c81f6196a447cd03c6..2b3decb90aeb99bef42b36f3b8df06cb1172b413 100644 +index 3dcd43279ce1295b37c3504ecbdaac5275df2b80..b5462ca1e67c87eeb447b8c4536c4bba897be186 100644 --- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java +++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java @@ -35,6 +35,38 @@ public class WitherSkeleton extends AbstractSkeleton { @@ -14253,10 +14164,10 @@ index 9a81cb0c3a5ac40ff50dc7c81f6196a447cd03c6..2b3decb90aeb99bef42b36f3b8df06cb protected void registerGoals() { this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractPiglin.class, true)); diff --git a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -index c1abeb62f63d2f8fb891efec8f76c6736b8f7f75..399e9baedaf37597c539aa5432a513365df83b5e 100644 +index b79c86272f12c4b1173ea494cbe09e1ecdc23533..1d36459ee10da702d65b4a6d139a05fdd487556f 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -@@ -67,6 +67,38 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { +@@ -69,6 +69,38 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { this.xpReward = 5; } @@ -14295,7 +14206,7 @@ index c1abeb62f63d2f8fb891efec8f76c6736b8f7f75..399e9baedaf37597c539aa5432a51336 @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -182,7 +214,7 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { +@@ -184,7 +216,7 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { @Override public Brain getBrain() { @@ -14304,7 +14215,7 @@ index c1abeb62f63d2f8fb891efec8f76c6736b8f7f75..399e9baedaf37597c539aa5432a51336 } protected void updateActivity() { -@@ -198,9 +230,10 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { +@@ -200,9 +232,10 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { @Override protected void customServerAiStep() { @@ -14318,10 +14229,10 @@ index c1abeb62f63d2f8fb891efec8f76c6736b8f7f75..399e9baedaf37597c539aa5432a51336 } diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed9920333a 100644 +index 1ddbba72a5fd3d225b651815a38d178941fba289..97ed65885f43c712953d6d8b3c231bac6f031390 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -@@ -95,22 +95,69 @@ public class Zombie extends Monster { +@@ -96,22 +96,69 @@ public class Zombie extends Monster { private int inWaterTime; public int conversionTime; private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field @@ -14392,7 +14303,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed this.addBehaviourGoals(); } -@@ -120,7 +167,19 @@ public class Zombie extends Monster { +@@ -121,7 +168,19 @@ public class Zombie extends Monster { this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D)); this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -14413,7 +14324,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -242,30 +301,7 @@ public class Zombie extends Monster { +@@ -243,30 +302,7 @@ public class Zombie extends Monster { @Override public void aiStep() { @@ -14445,7 +14356,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed super.aiStep(); } -@@ -303,6 +339,7 @@ public class Zombie extends Monster { +@@ -304,6 +340,7 @@ public class Zombie extends Monster { } @@ -14453,7 +14364,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed public boolean isSunSensitive() { return this.shouldBurnInDay; // Paper - use api value instead } -@@ -432,7 +469,7 @@ public class Zombie extends Monster { +@@ -433,7 +470,7 @@ public class Zombie extends Monster { nbt.putBoolean("CanBreakDoors", this.canBreakDoors()); nbt.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); nbt.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -14462,7 +14373,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed } @Override -@@ -446,7 +483,7 @@ public class Zombie extends Monster { +@@ -447,7 +484,7 @@ public class Zombie extends Monster { } // Paper start if (nbt.contains("Paper.ShouldBurnInDay")) { @@ -14471,7 +14382,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed } // Paper end -@@ -527,19 +564,20 @@ public class Zombie extends Monster { +@@ -528,19 +565,20 @@ public class Zombie extends Monster { if (object instanceof Zombie.ZombieGroupData) { Zombie.ZombieGroupData entityzombie_groupdatazombie = (Zombie.ZombieGroupData) object; @@ -14498,7 +14409,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed Chicken entitychicken1 = (Chicken) EntityType.CHICKEN.create(this.level()); if (entitychicken1 != null) { -@@ -549,6 +587,7 @@ public class Zombie extends Monster { +@@ -550,6 +588,7 @@ public class Zombie extends Monster { this.startRiding(entitychicken1); world.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit } @@ -14506,7 +14417,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed } } } -@@ -559,11 +598,7 @@ public class Zombie extends Monster { +@@ -560,11 +599,7 @@ public class Zombie extends Monster { } if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { @@ -14519,7 +14430,7 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(randomsource.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F; } -@@ -595,7 +630,7 @@ public class Zombie extends Monster { +@@ -596,7 +631,7 @@ public class Zombie extends Monster { } protected void randomizeReinforcementsChance() { @@ -14529,10 +14440,10 @@ index 3f8c1d1d3c408fc4f15c4b5680bc22c86f104a9d..7c5efb5582f43d9f333f926ad7dba1ed @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -index 25ed5571b24e590bc95056020d84496492b53298..be2a35f703310f699ee31bd2ec1c938af281a577 100644 +index 807cff3fb51269b97d9aecbcc4706f0a139dfeaa..858bf64d951ae48421ceb2f9b62de9397ffb4dc3 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -79,6 +79,58 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -82,6 +82,58 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { }); } @@ -14591,7 +14502,7 @@ index 25ed5571b24e590bc95056020d84496492b53298..be2a35f703310f699ee31bd2ec1c938a @Override protected void defineSynchedData() { super.defineSynchedData(); -@@ -165,13 +217,13 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -168,13 +220,13 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.is(Items.GOLDEN_APPLE)) { @@ -14608,10 +14519,10 @@ index 25ed5571b24e590bc95056020d84496492b53298..be2a35f703310f699ee31bd2ec1c938a return InteractionResult.SUCCESS; diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java -index aff140cfb2bbdce8b512080cf394c84c5c4ff807..7bb99d7fd8e05805e0cac7bec0b2771990057f58 100644 +index 1afe8a8694c1fd0bf43ce3c0c36a83fda9aec141..df8c7a45eb49a8c667030eb67d6d49dcbaef4fcf 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java -@@ -63,6 +63,53 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { +@@ -64,6 +64,53 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { this.setPathfindingMalus(BlockPathTypes.LAVA, 8.0F); } @@ -14665,7 +14576,7 @@ index aff140cfb2bbdce8b512080cf394c84c5c4ff807..7bb99d7fd8e05805e0cac7bec0b27719 @Override public void setPersistentAngerTarget(@Nullable UUID angryAt) { this.persistentAngerTarget = angryAt; -@@ -115,7 +162,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { +@@ -111,7 +158,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { this.maybeAlertOthers(); } @@ -14674,7 +14585,7 @@ index aff140cfb2bbdce8b512080cf394c84c5c4ff807..7bb99d7fd8e05805e0cac7bec0b27719 this.lastHurtByPlayerTime = this.tickCount; } -@@ -170,7 +217,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { +@@ -166,7 +213,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { this.ticksUntilNextAlert = ZombifiedPiglin.ALERT_INTERVAL.sample(this.random); } @@ -14683,7 +14594,7 @@ index aff140cfb2bbdce8b512080cf394c84c5c4ff807..7bb99d7fd8e05805e0cac7bec0b27719 this.setLastHurtByPlayer((Player) entityliving); } -@@ -250,7 +297,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { +@@ -246,7 +293,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { @Override protected void randomizeReinforcementsChance() { @@ -14693,10 +14604,10 @@ index aff140cfb2bbdce8b512080cf394c84c5c4ff807..7bb99d7fd8e05805e0cac7bec0b27719 @Nullable diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -index d6d61b91096d28eea1e5af69ea1c07890820ee7f..ecc445bb3cda2d79d64c580b72544567dd304f53 100644 +index e703320717ff620a19ff76d1c10066117c9895d5..9d6c4f13c4a444c6c815c6c4f2114142f166b9bb 100644 --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -67,6 +67,43 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { +@@ -69,6 +69,43 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { this.xpReward = 5; } @@ -14740,7 +14651,7 @@ index d6d61b91096d28eea1e5af69ea1c07890820ee7f..ecc445bb3cda2d79d64c580b72544567 @Override public boolean canBeLeashed(Player player) { return !this.isLeashed(); -@@ -129,10 +166,10 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { +@@ -131,10 +168,10 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { private int behaviorTick; // Pufferfish @Override protected void customServerAiStep() { @@ -14755,7 +14666,7 @@ index d6d61b91096d28eea1e5af69ea1c07890820ee7f..ecc445bb3cda2d79d64c580b72544567 if (this.isConverting()) { ++this.timeInOverworld; diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -index e235cc9d1b3ce59ab662ef3cf3ce0267ca78536d..79f969ea76fc2073e10c050c2aa64b5b5e473181 100644 +index cfdc1650783d6855e0d4f33ec68aab48dbee09f0..b2094e07084f06600f1e68b3ac5f865bf6667449 100644 --- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java @@ -96,6 +96,38 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @@ -14797,21 +14708,21 @@ index e235cc9d1b3ce59ab662ef3cf3ce0267ca78536d..79f969ea76fc2073e10c050c2aa64b5b @Override public void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); -@@ -308,10 +340,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -303,10 +335,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento private int behaviorTick; // Pufferfish @Override protected void customServerAiStep() { - this.level().getProfiler().push("piglinBrain"); - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + //this.level().getProfiler().push("piglinBrain"); // Purpur -+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider ++ //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider this.getBrain().tick((ServerLevel) this.level(), this); - this.level().getProfiler().pop(); + //this.level().getProfiler().pop(); // Purpur PiglinAi.updateActivity(this); super.customServerAiStep(); } -@@ -407,7 +439,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -402,7 +434,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @Override public boolean wantsToPickUp(ItemStack stack) { @@ -14821,7 +14732,7 @@ index e235cc9d1b3ce59ab662ef3cf3ce0267ca78536d..79f969ea76fc2073e10c050c2aa64b5b protected boolean canReplaceCurrentItem(ItemStack stack) { diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java -index d98c526676202741e628d5e317b8cdd3f4d3be0a..edf9208ed49a179dc15308dd72ee47367c0a9ded 100644 +index 5c13e376dd079134da465044f1057bcce66973a3..8f10ced20d7cdb7020f032c9e37d9bbb38f360d6 100644 --- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java @@ -597,20 +597,33 @@ public class PiglinAi { @@ -14847,7 +14758,7 @@ index d98c526676202741e628d5e317b8cdd3f4d3be0a..edf9208ed49a179dc15308dd72ee4736 + // Purpur start + private static boolean isWearingGoldTrim(LivingEntity entity, ItemStack itemstack) { -+ Optional optionalArmorTrim = net.minecraft.world.item.armortrim.ArmorTrim.getTrim(entity.level().registryAccess(), itemstack); ++ Optional optionalArmorTrim = net.minecraft.world.item.armortrim.ArmorTrim.getTrim(entity.level().registryAccess(), itemstack, true); + + if (optionalArmorTrim.isEmpty()) return false; + @@ -14926,10 +14837,10 @@ index d02ee11066fc4f07ccb110b09b86d895ff90d4f2..856e6e02c9424a6c06e310262cb4f5bd PiglinBruteAi.maybePlayActivitySound(this); super.customServerAiStep(); diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 71db8bd6885377d55cfc571fccc21df6d8a57b54..3fa46affc4d77d01909cfeaeaba6e06ba9fd5592 100644 +index 5e43912708f9074dee1bb351efa737a7e6796fc3..5e66c2bd3807619cadee5b7081d93d21886e2806 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -121,8 +121,32 @@ public class Warden extends Monster implements VibrationSystem { +@@ -122,8 +122,32 @@ public class Warden extends Monster implements VibrationSystem { this.setPathfindingMalus(BlockPathTypes.LAVA, 8.0F); this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, 0.0F); this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, 0.0F); @@ -14962,7 +14873,7 @@ index 71db8bd6885377d55cfc571fccc21df6d8a57b54..3fa46affc4d77d01909cfeaeaba6e06b @Override public Packet getAddEntityPacket() { return new ClientboundAddEntityPacket(this, this.hasPose(Pose.EMERGING) ? 1 : 0); -@@ -276,10 +300,10 @@ public class Warden extends Monster implements VibrationSystem { +@@ -277,10 +301,10 @@ public class Warden extends Monster implements VibrationSystem { protected void customServerAiStep() { ServerLevel worldserver = (ServerLevel) this.level(); @@ -14975,7 +14886,7 @@ index 71db8bd6885377d55cfc571fccc21df6d8a57b54..3fa46affc4d77d01909cfeaeaba6e06b super.customServerAiStep(); if ((this.tickCount + this.getId()) % 120 == 0) { Warden.applyDarknessAround(worldserver, this.position(), this, 20); -@@ -396,19 +420,16 @@ public class Warden extends Monster implements VibrationSystem { +@@ -397,19 +421,16 @@ public class Warden extends Monster implements VibrationSystem { @Contract("null->false") public boolean canTargetEntity(@Nullable Entity entity) { @@ -14999,10 +14910,10 @@ index 71db8bd6885377d55cfc571fccc21df6d8a57b54..3fa46affc4d77d01909cfeaeaba6e06b public static void applyDarknessAround(ServerLevel world, Vec3 pos, @Nullable Entity entity, int range) { diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index 564908ce0a560c2190fb624e77d227d3b7031024..f2a4e214744227f1df32e3782e71f8a9d5cea261 100644 +index 5119d070dbb04f5a4f9c2def526e33e15ca8573f..d5408629801716ccb227b6a7068d17495ed3d0fb 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -43,6 +43,7 @@ import org.bukkit.event.entity.VillagerAcquireTradeEvent; +@@ -42,6 +42,7 @@ import org.bukkit.event.entity.VillagerAcquireTradeEvent; // CraftBukkit end public abstract class AbstractVillager extends AgeableMob implements InventoryCarrier, Npc, Merchant { @@ -15057,18 +14968,18 @@ index 5f407535298a31a34cfe114dd863fd6a9b977707..29c7e33fe961020e5a0007287fe9b663 } diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6f53e9c30 100644 +index 1bc082a1fad26e38a8606b633bf3789b5e4d6046..b0b06ba1ea4cfdb2c0d27aee12312323c95002e4 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -140,6 +140,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> { +@@ -142,6 +142,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler return holder.is(PoiTypes.MEETING); }); -+ private boolean isLobotomized = false; public boolean isLobotomized() { return this.isLobotomized; } // Purpur -+ private int notLobotomizedCount = 0; // Purpur - public long nextGolemPanic = -1; // Pufferfish ++ private boolean isLobotomized = false; public boolean isLobotomized() { return this.isLobotomized; } // Purpur ++ private int notLobotomizedCount = 0; + public Villager(EntityType entityType, Level world) { + this(entityType, world, VillagerType.PLAINS); @@ -154,6 +156,90 @@ public class Villager extends AbstractVillager implements ReputationEventHandler this.getNavigation().setCanFloat(true); this.setCanPickUpLoot(true); @@ -15149,8 +15060,8 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 + } + net.minecraft.world.level.block.Block bottom = state.getBlock(); + if (bottom instanceof net.minecraft.world.level.block.FenceBlock || -+ bottom instanceof net.minecraft.world.level.block.FenceGateBlock || -+ bottom instanceof net.minecraft.world.level.block.WallBlock) { ++ bottom instanceof net.minecraft.world.level.block.FenceGateBlock || ++ bottom instanceof net.minecraft.world.level.block.WallBlock) { + // bottom block is too tall to get over + return false; + } @@ -15169,7 +15080,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 } brain.addActivity(Activity.CORE, VillagerGoalPackages.getCorePackage(villagerprofession, 0.5F)); -@@ -253,15 +339,22 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -253,15 +339,25 @@ public class Villager extends AbstractVillager implements ReputationEventHandler // Paper start this.customServerAiStep(false); } @@ -15177,9 +15088,6 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 + protected void customServerAiStep(boolean inactive) { // Purpur - not final // Paper end - this.level().getProfiler().push("villagerBrain"); -- // Pufferfish start -- if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) { -- this.getBrain().tick((ServerLevel) this.level(), this); // Paper + //this.level().getProfiler().push("villagerBrain"); // Purpur + // Purpur start + if (this.level().purpurConfig.villagerLobotomizeEnabled) { @@ -15188,18 +15096,21 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 + } else { + // clean up state for API + this.isLobotomized = false; ++ } + // Pufferfish start +- if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) { ++ if (!inactive && (getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider + this.getBrain().tick((ServerLevel) this.level(), this); // Paper } -- // Pufferfish end -- this.level().getProfiler().pop(); -+ if (!inactive && (getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Purpur - only use brain if no rider -+ this.getBrain().tick((ServerLevel) this.level(), this); // Paper + else if (this.isLobotomized && shouldRestock()) restock(); + // Pufferfish end +- this.level().getProfiler().pop(); + // Purpur end + //this.level().getProfiler().pop(); // Purpur if (this.assignProfessionWhenSpawned) { this.assignProfessionWhenSpawned = false; } -@@ -317,7 +410,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -317,7 +413,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler if (!itemstack.is(Items.VILLAGER_SPAWN_EGG) && this.isAlive() && !this.isTrading() && !this.isSleeping()) { if (this.isBaby()) { this.setUnhappy(); @@ -15208,7 +15119,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 } else { boolean flag = this.getOffers().isEmpty(); -@@ -330,9 +423,10 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -330,9 +426,10 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } if (flag) { @@ -15221,7 +15132,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 this.startTrading(player); } -@@ -501,7 +595,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -501,7 +598,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler while (iterator.hasNext()) { MerchantOffer merchantrecipe = (MerchantOffer) iterator.next(); @@ -15230,7 +15141,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 } } -@@ -751,7 +845,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -751,7 +848,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @Override public boolean canBreed() { @@ -15239,7 +15150,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 } private boolean hungry() { -@@ -944,6 +1038,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -944,6 +1041,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler public boolean hasFarmSeeds() { return this.getInventory().hasAnyMatching((itemstack) -> { @@ -15251,7 +15162,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 return itemstack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS); }); } -@@ -993,6 +1092,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -1001,6 +1103,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } public void spawnGolemIfNeeded(ServerLevel world, long time, int requiredCount) { @@ -15259,7 +15170,7 @@ index c4ddf2661bca728d504918171295e10e307b18b4..2ea19f72dd8e86d5821f734c13ac2dc6 if (this.wantsToSpawnGolem(time)) { AABB axisalignedbb = this.getBoundingBox().inflate(10.0D, 10.0D, 10.0D); List list = world.getEntitiesOfClass(Villager.class, axisalignedbb); -@@ -1066,6 +1166,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -1074,6 +1177,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @Override public void startSleeping(BlockPos pos) { @@ -15286,10 +15197,10 @@ index ac70c2c03241e73943bd517a8c69dd05e0873634..0318663a824d2a9515f867a075d148c3 public static final VillagerProfession FISHERMAN = register("fisherman", PoiTypes.FISHERMAN, SoundEvents.VILLAGER_WORK_FISHERMAN); public static final VillagerProfession FLETCHER = register("fletcher", PoiTypes.FLETCHER, SoundEvents.VILLAGER_WORK_FLETCHER); diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java -index 0002f3a2f2e096d4b2015baf707707f6cc1a9582..0e5fae26bf89749e446050c92dc7c23d788f5edb 100644 +index 3c2941d799c9acb3dd9e2b67b7092f4bba5ede17..d8a4b1aaa180fc0c837bc0d8efab781a578898a5 100644 --- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java +++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java -@@ -66,6 +66,43 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill +@@ -70,6 +70,43 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill //this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader // Paper - move back to MobSpawnerTrader - Vanilla behavior is that only traders spawned by it have this value set. } @@ -15333,7 +15244,7 @@ index 0002f3a2f2e096d4b2015baf707707f6cc1a9582..0e5fae26bf89749e446050c92dc7c23d @Override protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); -@@ -73,7 +110,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill +@@ -77,7 +114,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill return this.canDrinkPotion && this.level().isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API })); this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { @@ -15342,7 +15253,7 @@ index 0002f3a2f2e096d4b2015baf707707f6cc1a9582..0e5fae26bf89749e446050c92dc7c23d })); this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this)); this.goalSelector.addGoal(1, new AvoidEntityGoal<>(this, Zombie.class, 8.0F, 0.5D, 0.5D)); -@@ -86,6 +123,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill +@@ -90,6 +127,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill this.goalSelector.addGoal(1, new PanicGoal(this, 0.5D)); this.goalSelector.addGoal(1, new LookAtTradingPlayerGoal(this)); this.goalSelector.addGoal(2, new WanderingTrader.WanderToPositionGoal(this, 2.0D, 0.35D)); @@ -15350,7 +15261,7 @@ index 0002f3a2f2e096d4b2015baf707707f6cc1a9582..0e5fae26bf89749e446050c92dc7c23d this.goalSelector.addGoal(4, new MoveTowardsRestrictionGoal(this, 0.35D)); this.goalSelector.addGoal(8, new WaterAvoidingRandomStrollGoal(this, 0.35D)); this.goalSelector.addGoal(9, new InteractGoal(this, Player.class, 3.0F, 1.0F)); -@@ -113,9 +151,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill +@@ -117,9 +155,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill } if (this.getOffers().isEmpty()) { @@ -15387,10 +15298,10 @@ index 8385eb1d60f377da94e3178ab506feefb43563fd..a5443f92786427c42092aec8350e7ab3 if (NaturalSpawner.isSpawnPositionOk(SpawnPlacements.Type.ON_GROUND, world, blockposition2, EntityType.WANDERING_TRADER)) { blockposition1 = blockposition2; diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08e6b558f0 100644 +index d58b4c0dbe651b5068212e5f14dce3164ee520f5..20c3d3c9d2150574e9b4761dc1bda11cee04862f 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -187,17 +187,40 @@ public abstract class Player extends LivingEntity { +@@ -188,17 +188,40 @@ public abstract class Player extends LivingEntity { public boolean affectsSpawning = true; public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper end @@ -15431,7 +15342,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 public Player(Level world, BlockPos pos, float yaw, GameProfile gameProfile) { super(EntityType.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -242,6 +265,12 @@ public abstract class Player extends LivingEntity { +@@ -243,6 +266,12 @@ public abstract class Player extends LivingEntity { @Override public void tick() { @@ -15444,7 +15355,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 this.noPhysics = this.isSpectator(); if (this.isSpectator()) { this.setOnGround(false); -@@ -345,6 +374,16 @@ public abstract class Player extends LivingEntity { +@@ -346,6 +375,16 @@ public abstract class Player extends LivingEntity { this.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit } @@ -15461,7 +15372,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 } protected ItemCooldowns createItemCooldowns() { -@@ -431,7 +470,7 @@ public abstract class Player extends LivingEntity { +@@ -436,7 +475,7 @@ public abstract class Player extends LivingEntity { @Override public int getPortalWaitTime() { @@ -15470,16 +15381,16 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 } @Override -@@ -591,7 +630,7 @@ public abstract class Player extends LivingEntity { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); +@@ -597,7 +636,7 @@ public abstract class Player extends LivingEntity { + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); - if (entity.getType() == EntityType.EXPERIENCE_ORB) { + if (entity.getType() == EntityType.EXPERIENCE_ORB && entity.level().purpurConfig.playerExpPickupDelay >= 0) { // Purpur list1.add(entity); } else if (!entity.isRemoved()) { this.touch(entity); -@@ -1282,7 +1321,7 @@ public abstract class Player extends LivingEntity { +@@ -1288,7 +1327,7 @@ public abstract class Player extends LivingEntity { flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper flag2 = flag2 && !this.isSprinting(); if (flag2) { @@ -15488,7 +15399,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 } f += f1; -@@ -1977,9 +2016,19 @@ public abstract class Player extends LivingEntity { +@@ -1983,9 +2022,19 @@ public abstract class Player extends LivingEntity { @Override public int getExperienceReward() { if (!this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && !this.isSpectator()) { @@ -15511,7 +15422,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 } else { return 0; } -@@ -2055,6 +2104,11 @@ public abstract class Player extends LivingEntity { +@@ -2061,6 +2110,11 @@ public abstract class Player extends LivingEntity { return this.inventory.armor; } @@ -15523,7 +15434,7 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 public boolean setEntityOnShoulder(CompoundTag entityNbt) { if (!this.isPassenger() && this.onGround() && !this.isInWater() && !this.isInPowderSnow) { if (this.getShoulderEntityLeft().isEmpty()) { -@@ -2339,7 +2393,7 @@ public abstract class Player extends LivingEntity { +@@ -2341,7 +2395,7 @@ public abstract class Player extends LivingEntity { public ItemStack eat(Level world, ItemStack stack) { this.getFoodData().eat(stack.getItem(), stack); this.awardStat(Stats.ITEM_USED.get(stack.getItem())); @@ -15533,10 +15444,10 @@ index 58152160d609d0e9d105153aeb166a56a7955603..d00035e31cf4773a418d1cc6a6018d08 CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) this, stack); } diff --git a/src/main/java/net/minecraft/world/entity/player/StackedContents.java b/src/main/java/net/minecraft/world/entity/player/StackedContents.java -index 68d272e98f9e54c9b150c75c27a9ae545be842f6..63fc6074082b579c3f88316008cbeb2a2d7f5841 100644 +index 26b236a764177ac16d53f5cbaf83d3e21d015ebc..6bc60ea5249cca9f4c1d029a2b7460fe3476e05a 100644 --- a/src/main/java/net/minecraft/world/entity/player/StackedContents.java +++ b/src/main/java/net/minecraft/world/entity/player/StackedContents.java -@@ -40,8 +40,62 @@ public class StackedContents { +@@ -41,8 +41,62 @@ public class StackedContents { int j = Math.min(maxCount, stack.getCount()); if (this.extrasMap != null && stack.hasTag() && this.extrasMap.accountStack(stack, j)) return; // Paper - if an exact ingredient, don't include it this.put(i, j); @@ -15599,7 +15510,7 @@ index 68d272e98f9e54c9b150c75c27a9ae545be842f6..63fc6074082b579c3f88316008cbeb2a } public static int getStackingIndex(ItemStack stack) { -@@ -83,6 +137,12 @@ public class StackedContents { +@@ -84,6 +138,12 @@ public class StackedContents { } public static ItemStack fromStackingIndex(int itemId) { @@ -15613,7 +15524,7 @@ index 68d272e98f9e54c9b150c75c27a9ae545be842f6..63fc6074082b579c3f88316008cbeb2a } diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index fa885337085348308604e50049ecc5bb52023884..6b070ad6aa1b62a66fb85d54042af9d64cdcea7f 100644 +index 8affdd74769aed9aa92a76ba539cd9d27208827c..4063aed1a3f0bfd7351c1ec2e9684e4991cb5285 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java @@ -72,6 +72,7 @@ public abstract class AbstractArrow extends Projectile { @@ -15776,10 +15687,10 @@ index 718e120c9768cf716b32d3d652f53f1dda925168..440d3d72d8b2dac14f83a83caa5ae9db protected void onHit(HitResult hitResult) { super.onHit(hitResult); diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -index e8114d89a3129e56c0329410a49ded63cc77cb4c..d7359c675707eade00f9b737fd67ef8d066e813f 100644 +index e02d5dcbf69bd68b2f567c1a16a44ab59955f871..fb0f29b714344f0ac3e7f6bd809ac57a21061156 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -68,10 +68,11 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -67,10 +67,11 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { Bukkit.getPluginManager().callEvent(teleEvent); if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) { @@ -15792,7 +15703,7 @@ index e8114d89a3129e56c0329410a49ded63cc77cb4c..d7359c675707eade00f9b737fd67ef8d entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); } -@@ -84,7 +85,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -83,7 +84,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { entityplayer.connection.teleport(teleEvent.getTo()); entity.resetFallDistance(); CraftEventFactory.entityDamage = this; @@ -15846,7 +15757,7 @@ index 06d1bdb9bd124b201c36d284c50d22bf50d3735a..b4687453256ead43cf5288994316c7bf public boolean isPickable() { return false; diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java -index 57fdcdaf54fd1c92a6e51a3a81789029096e5abe..822dd4265ce02252afadbc652064450b7dfd7e0d 100644 +index cdbc925ef61b8b439415f0a89368227890bcecb2..300411e88cdaef7e0ce280edbd5f18fa8d004a33 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raider.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java @@ -319,7 +319,7 @@ public abstract class Raider extends PatrollingMonster { @@ -15859,10 +15770,10 @@ index 57fdcdaf54fd1c92a6e51a3a81789029096e5abe..822dd4265ce02252afadbc652064450b if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) { diff --git a/src/main/java/net/minecraft/world/entity/raid/Raids.java b/src/main/java/net/minecraft/world/entity/raid/Raids.java -index 41457c9f27b18fa2734a6cca297ec5186470e82f..94356e0541f8f4da68211fa533347cc97d4f3518 100644 +index 31831811ce16265e9828fa34d9e67d8ac195d723..a1f74718240da3dfb0fc53f337ec3bf1636def75 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raids.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raids.java -@@ -28,6 +28,7 @@ import net.minecraft.world.phys.Vec3; +@@ -29,6 +29,7 @@ import net.minecraft.world.phys.Vec3; public class Raids extends SavedData { private static final String RAID_FILE_ID = "raids"; @@ -15870,7 +15781,7 @@ index 41457c9f27b18fa2734a6cca297ec5186470e82f..94356e0541f8f4da68211fa533347cc9 public final Map raidMap = Maps.newHashMap(); private final ServerLevel level; private int nextAvailableID; -@@ -45,6 +46,17 @@ public class Raids extends SavedData { +@@ -54,6 +55,17 @@ public class Raids extends SavedData { public void tick() { ++this.tick; @@ -15888,7 +15799,7 @@ index 41457c9f27b18fa2734a6cca297ec5186470e82f..94356e0541f8f4da68211fa533347cc9 Iterator iterator = this.raidMap.values().iterator(); while (iterator.hasNext()) { -@@ -129,11 +141,13 @@ public class Raids extends SavedData { +@@ -138,11 +150,13 @@ public class Raids extends SavedData { } if (flag) { @@ -15903,10 +15814,10 @@ index 41457c9f27b18fa2734a6cca297ec5186470e82f..94356e0541f8f4da68211fa533347cc9 if (!this.raidMap.containsKey(raid.getId())) { this.raidMap.put(raid.getId(), raid); diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index 9948a28dae4edba877c13ef0156be5ff58df3fa2..b99b94c6ec4767aba16d82eaca8b2761d779b226 100644 +index 44a6118d3bd67a95180f750c17967561946e2e87..faf449dfb4f95a300796db46833f3b6a51cb961b 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -108,11 +108,13 @@ public abstract class AbstractMinecart extends Entity { +@@ -112,12 +112,14 @@ public abstract class AbstractMinecart extends Entity { private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision public double maxSpeed = 0.4D; @@ -15915,12 +15826,13 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..b99b94c6ec4767aba16d82eaca8b2761 protected AbstractMinecart(EntityType type, Level world) { super(type, world); + this.targetDeltaMovement = Vec3.ZERO; this.blocksBuilding = true; + if (world != null) maxSpeed = storedMaxSpeed = world.purpurConfig.minecartMaxSpeed; // Purpur } protected AbstractMinecart(EntityType type, Level world, double x, double y, double z) { -@@ -335,6 +337,12 @@ public abstract class AbstractMinecart extends Entity { +@@ -342,6 +344,12 @@ public abstract class AbstractMinecart extends Entity { @Override public void tick() { @@ -16006,10 +15918,10 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..b99b94c6ec4767aba16d82eaca8b2761 Vec3 vec3d5 = this.getDeltaMovement(); double d21 = vec3d5.x; diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -index 2c5658df753ebc08f8531d4bdf22ff8f6ca77e94..a7ab9e2284d4a1ae6f5601adc3dfac534bce26fc 100644 +index 5c07da62c82bc70138f6cb5007629d6974be69ac..c314febb75a85ef12051bde392c5b57e9c5d85ac 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -@@ -223,7 +223,13 @@ public class Boat extends Entity implements VariantHolder { +@@ -242,7 +242,13 @@ public class Boat extends Entity implements VariantHolder { } protected void destroy(DamageSource source) { @@ -16024,7 +15936,7 @@ index 2c5658df753ebc08f8531d4bdf22ff8f6ca77e94..a7ab9e2284d4a1ae6f5601adc3dfac53 } @Override -@@ -541,6 +547,7 @@ public class Boat extends Entity implements VariantHolder { +@@ -578,6 +584,7 @@ public class Boat extends Entity implements VariantHolder { if (f > 0.0F) { this.landFriction = f; @@ -16103,7 +16015,7 @@ index b16d9e2eaa589f19c563ee70b1a56d67dbcdecb0..71beab673f04cd051c46ea37f8c84731 public static final FoodProperties BAKED_POTATO = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.6F).build(); public static final FoodProperties BEEF = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.3F).meat().build(); diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index 7bba845462813615224f48322c51c7b480adcaa7..38d47fbcd49cc291040ea00470abeb982fe2714c 100644 +index ffd349c1b80df0f1e8c02bda23700184825170fd..29f301bde378bd320d5c44f2c1b6bf9dc185e286 100644 --- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -76,6 +76,7 @@ public abstract class AbstractContainerMenu { @@ -16115,10 +16027,10 @@ index 7bba845462813615224f48322c51c7b480adcaa7..38d47fbcd49cc291040ea00470abeb98 // CraftBukkit start public boolean checkReachable = true; diff --git a/src/main/java/net/minecraft/world/inventory/AbstractFurnaceMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractFurnaceMenu.java -index 35b41bceeba72c3896c91c2605bac3b0bf9c54e9..5c028f957661089ff502109c996692856b12ee27 100644 +index 1af7e1548f0648890a1ef2fc0ff4e4c3a56c947c..decea1697c075e7549ccc7501c8e59357d198a60 100644 --- a/src/main/java/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -145,7 +145,13 @@ public abstract class AbstractFurnaceMenu extends RecipeBookMenu { +@@ -147,7 +147,13 @@ public abstract class AbstractFurnaceMenu extends RecipeBookMenu { } else if (slot != 1 && slot != 0) { if (this.canSmelt(itemstack1)) { if (!this.moveItemStackTo(itemstack1, 0, 1, false)) { @@ -16348,10 +16260,10 @@ index 0dbfd23bbfc6ad203f048142f8c90ef741849fe1..9a80427d2bb470b6b1638e59aba57216 return new ChestMenu(MenuType.GENERIC_9x6, syncId, playerInventory, inventory, 6); } diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -index 496c3fcf49043bba4d249e1c05aac7d7b4897ea8..f0a84889103cb605d3b1496f03d855848a5f5067 100644 +index c5c509fbb915c60dfa95aac8510684d0b9f8b0ff..d604b7ec46f08993647979ed220a84842e3fe325 100644 --- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -38,6 +38,12 @@ import org.bukkit.event.enchantment.PrepareItemEnchantEvent; +@@ -40,6 +40,12 @@ import org.bukkit.event.enchantment.PrepareItemEnchantEvent; import org.bukkit.entity.Player; // CraftBukkit end @@ -16363,8 +16275,8 @@ index 496c3fcf49043bba4d249e1c05aac7d7b4897ea8..f0a84889103cb605d3b1496f03d85584 + public class EnchantmentMenu extends AbstractContainerMenu { - private final Container enchantSlots; -@@ -71,6 +77,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { + static final ResourceLocation EMPTY_SLOT_LAPIS_LAZULI = new ResourceLocation("item/empty_slot_lapis_lazuli"); +@@ -74,6 +80,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { return context.getLocation(); } // CraftBukkit end @@ -16387,7 +16299,7 @@ index 496c3fcf49043bba4d249e1c05aac7d7b4897ea8..f0a84889103cb605d3b1496f03d85584 }; this.random = RandomSource.create(); this.enchantmentSeed = DataSlot.standalone(); -@@ -96,6 +118,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -99,6 +121,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { } }); @@ -16405,7 +16317,7 @@ index 496c3fcf49043bba4d249e1c05aac7d7b4897ea8..f0a84889103cb605d3b1496f03d85584 int j; for (j = 0; j < 3; ++j) { -@@ -340,6 +373,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -344,6 +377,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { public void removed(net.minecraft.world.entity.player.Player player) { super.removed(player); this.access.execute((world, blockposition) -> { @@ -16489,7 +16401,7 @@ index a21eadcdfbdc4be803c5793bc97996db3e706071..3b721092a7a73472756064e0eb91d322 return itemstack; diff --git a/src/main/java/net/minecraft/world/inventory/InventoryMenu.java b/src/main/java/net/minecraft/world/inventory/InventoryMenu.java -index c549618421c5d077c3d977d8d2064eca2acc438a..5972fa434847d24fa98b7895fd8386d20a636885 100644 +index b399903e8f11ec6c12fe7e724b7d9c8292acd573..a4afa946cd47238eb0fed297a27b24013d5ba77c 100644 --- a/src/main/java/net/minecraft/world/inventory/InventoryMenu.java +++ b/src/main/java/net/minecraft/world/inventory/InventoryMenu.java @@ -4,6 +4,7 @@ import com.mojang.datafixers.util.Pair; @@ -16548,18 +16460,18 @@ index 4703f23316f82a1a942907b46d2d6dcb7d70ec37..162798f57a05b78121fa6c4fadf5adee this.activeChest = blockEntity; } diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java -index d7a0cbde8f8c99276307502674c71463fbe7e89c..3500c56cb85d8c76b2acd77976d374eaf487b3b3 100644 +index 42d87800a328f71c5127ce5599ca4c71cc9bb1cd..7868c2f7b563792f8902d9a77dca46e0dcb82194 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -60,7 +60,7 @@ public class ArmorItem extends Item implements Equipable { +@@ -61,7 +61,7 @@ public class ArmorItem extends Item implements Equipable { return false; } else { LivingEntity entityliving = (LivingEntity) list.get(0); - EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(armor); -+ EquipmentSlot enumitemslot = pointer.getLevel().purpurConfig.dispenserApplyCursedArmor ? Mob.getEquipmentSlotForItem(armor) : Mob.getSlotForDispenser(armor); if (enumitemslot == null) return false; // Purpur ++ EquipmentSlot enumitemslot = pointer.level().purpurConfig.dispenserApplyCursedArmor ? Mob.getEquipmentSlotForItem(armor) : Mob.getSlotForDispenser(armor); if (enumitemslot == null) return false; // Purpur ItemStack itemstack1 = armor.copyWithCount(1); // Paper - shrink below and single item in event // CraftBukkit start - Level world = pointer.getLevel(); + Level world = pointer.level(); diff --git a/src/main/java/net/minecraft/world/item/ArmorStandItem.java b/src/main/java/net/minecraft/world/item/ArmorStandItem.java index 7cffc64573008502bdd14ae4906fe51166b12fb3..1feafdbb48cf760cb6ebf95d5be2c32bdb1ad44f 100644 --- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java @@ -16751,19 +16663,19 @@ index 08d597db1a5345a343777a01427655e6bf2c926b..d45a2f49c82d00801578c34e5f5277fc } else { user.startUsingItem(hand); diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java -index 578c3db52dda4c169b5ea615a4ce4a79f15a4cad..0bd98b802f246a3f6061f716d470a4797b28d59d 100644 +index 277555a26e8281dd1a626e572794b08cf51d00c5..48e4fecf5ae5538004e3f53093b8be7c4be1cbee 100644 --- a/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java -@@ -164,7 +164,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { +@@ -195,7 +195,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { // CraftBukkit end - if (!flag1) { + if (!flag2) { return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (BlockHitResult) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit - } else if (world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if ((world.dimensionType().ultraWarm() || (world.isTheEnd() && !org.purpurmc.purpur.PurpurConfig.allowWaterPlacementInTheEnd)) && this.content.is(FluidTags.WATER)) { // Purpur int i = blockposition.getX(); int j = blockposition.getY(); int k = blockposition.getZ(); -@@ -172,7 +172,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { +@@ -203,7 +203,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { world.playSound(entityhuman, blockposition, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { @@ -16978,10 +16890,10 @@ index 180aec596110309aade13d2080f8824d152b07cb..552c31c0f3746dd35388395036e70a92 return InteractionResult.PASS; } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d7f15a93d 100644 +index 4697df75fdee2023c41260bed211e3e3d90d2b9b..4d99e7db4e9e56caead5ea177b79aaca8e1d20da 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -113,6 +113,7 @@ import org.bukkit.event.world.StructureGrowEvent; +@@ -114,6 +114,7 @@ import org.bukkit.event.world.StructureGrowEvent; public final class ItemStack { @@ -16989,7 +16901,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { return instance.group(BuiltInRegistries.ITEM.byNameCodec().fieldOf("id").forGetter(ItemStack::getItem), Codec.INT.fieldOf("Count").forGetter(ItemStack::getCount), CompoundTag.CODEC.optionalFieldOf("tag").forGetter((itemstack) -> { return Optional.ofNullable(itemstack.getTag()); -@@ -427,6 +428,7 @@ public final class ItemStack { +@@ -432,6 +433,7 @@ public final class ItemStack { world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 for (BlockState blockstate : blocks) { blockstate.update(true, false); @@ -16997,7 +16909,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d } world.preventPoiUpdated = false; -@@ -456,6 +458,7 @@ public final class ItemStack { +@@ -461,6 +463,7 @@ public final class ItemStack { if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context } @@ -17005,7 +16917,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point } -@@ -584,6 +587,16 @@ public final class ItemStack { +@@ -589,6 +592,16 @@ public final class ItemStack { return this.isDamageableItem() && this.getDamageValue() > 0; } @@ -17022,7 +16934,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d public int getDamageValue() { return this.tag == null ? 0 : this.tag.getInt("Damage"); } -@@ -603,7 +616,7 @@ public final class ItemStack { +@@ -608,7 +621,7 @@ public final class ItemStack { int j; if (amount > 0) { @@ -17031,7 +16943,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d int k = 0; for (int l = 0; j > 0 && l < amount; ++l) { -@@ -658,6 +671,12 @@ public final class ItemStack { +@@ -663,6 +676,12 @@ public final class ItemStack { if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent breakCallback.accept(entity); Item item = this.getItem(); @@ -17044,7 +16956,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d // CraftBukkit start - Check for item breaking if (this.count == 1 && entity instanceof net.minecraft.world.entity.player.Player) { org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this); -@@ -1184,7 +1203,7 @@ public final class ItemStack { +@@ -1189,7 +1208,7 @@ public final class ItemStack { ListTag nbttaglist = this.tag.getList("Enchantments", 10); @@ -17053,7 +16965,7 @@ index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..50ea2bc3f785dabc686162c895590b7d processEnchantOrder(this.tag); // Paper } -@@ -1192,6 +1211,12 @@ public final class ItemStack { +@@ -1197,6 +1216,12 @@ public final class ItemStack { return this.tag != null && this.tag.contains("Enchantments", 9) ? !this.tag.getList("Enchantments", 10).isEmpty() : false; } @@ -17103,7 +17015,7 @@ index 5f20e075c532f0f1d413242949d1738c0c152bf7..5fbb13ebef0ca66419f3e5006d19e4a5 } } diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java -index d3c29e6bf8b3c2dd628809177dac50220a7de415..735486b46581bb3b91c85f57490b560ff490787e 100644 +index c368b437597edf7e165326727ae778a69c3fcc83..fed5bfb02ab7d6c1d1d9bf993fda5b3f411b9352 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java @@ -243,6 +243,7 @@ public class MapItem extends ComplexItem { @@ -17138,10 +17050,10 @@ index f33977d95b6db473be4f95075ba99caf90ad0220..56dc04d8875971ee9a5d077a695509af return stack.isEmpty() ? new ItemStack(Items.BUCKET) : stack; diff --git a/src/main/java/net/minecraft/world/item/MinecartItem.java b/src/main/java/net/minecraft/world/item/MinecartItem.java -index c6d2f764efa9b8bec730bbe757d480e365b25ccc..cef98413d25dcc2def82775bbae71f92b096d905 100644 +index a33395dc5a94d89b5ab273c7832813b6ff9ea3b7..2b2218e2de535ebc8f529f5b5bf98fa1ef819a5e 100644 --- a/src/main/java/net/minecraft/world/item/MinecartItem.java +++ b/src/main/java/net/minecraft/world/item/MinecartItem.java -@@ -120,8 +120,9 @@ public class MinecartItem extends Item { +@@ -122,8 +122,9 @@ public class MinecartItem extends Item { BlockState iblockdata = world.getBlockState(blockposition); if (!iblockdata.is(BlockTags.RAILS)) { @@ -17153,7 +17065,7 @@ index c6d2f764efa9b8bec730bbe757d480e365b25ccc..cef98413d25dcc2def82775bbae71f92 ItemStack itemstack = context.getItemInHand(); if (!world.isClientSide) { -@@ -149,6 +150,6 @@ public class MinecartItem extends Item { +@@ -151,6 +152,6 @@ public class MinecartItem extends Item { itemstack.shrink(1); return InteractionResult.sidedSuccess(world.isClientSide); @@ -17289,18 +17201,18 @@ index 8078f127ff4b6e0aafb5804b9c02e237f79445b5..c32cbe6065ecb6810f352b8a3598c21e entityhuman.startAutoSpinAttack(20); if (entityhuman.onGround()) { diff --git a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java -index cd7ea0c16f9ddcb84b5d7e8a2533e6e84f3879c7..f47eab4c31925f51de4a6bc8be730281cb3388fc 100644 +index 06fe5b056d78d42cdf78437eeabe1786d596b7f8..ae98a5b49b5eb7b9b2846d1e41b5665c725198a2 100644 --- a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java +++ b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java @@ -39,6 +39,7 @@ public final class Ingredient implements Predicate { @Nullable private IntList stackingIds; public boolean exact; // CraftBukkit -+ public Predicate predicate; ++ public Predicate predicate; // Purpur + public static final Codec CODEC = Ingredient.codec(true); + public static final Codec CODEC_NONEMPTY = Ingredient.codec(false); - public Ingredient(Stream entries) { - this.values = (Ingredient.Value[]) entries.toArray((i) -> { -@@ -50,7 +51,11 @@ public final class Ingredient implements Predicate { +@@ -56,7 +57,11 @@ public final class Ingredient implements Predicate { if (this.itemStacks == null) { this.itemStacks = (ItemStack[]) Arrays.stream(this.values).flatMap((recipeitemstack_provider) -> { return recipeitemstack_provider.getItems().stream(); @@ -17313,7 +17225,7 @@ index cd7ea0c16f9ddcb84b5d7e8a2533e6e84f3879c7..f47eab4c31925f51de4a6bc8be730281 return new ItemStack[i]; }); } -@@ -64,6 +69,12 @@ public final class Ingredient implements Predicate { +@@ -70,6 +75,12 @@ public final class Ingredient implements Predicate { } else if (this.isEmpty()) { return itemstack.isEmpty(); } else { @@ -17326,7 +17238,7 @@ index cd7ea0c16f9ddcb84b5d7e8a2533e6e84f3879c7..f47eab4c31925f51de4a6bc8be730281 ItemStack[] aitemstack = this.getItems(); int i = aitemstack.length; -@@ -99,7 +110,13 @@ public final class Ingredient implements Predicate { +@@ -105,7 +116,13 @@ public final class Ingredient implements Predicate { for (int j = 0; j < i; ++j) { ItemStack itemstack = aitemstack1[j]; @@ -17436,11 +17348,11 @@ index ecf640b00007a386290f8dfe9935a8aa610079fd..1eec84e217f6dc929091fa7451cd235e public static Map.Entry getRandomItemWith(Enchantment enchantment, LivingEntity entity) { return getRandomItemWith(enchantment, entity, (stack) -> { diff --git a/src/main/java/net/minecraft/world/item/enchantment/LootBonusEnchantment.java b/src/main/java/net/minecraft/world/item/enchantment/LootBonusEnchantment.java -index 4007c16550683e23b396dfdff29530a82523fe05..8fe09c13643d99639fb242da4367c42ef31b38b4 100644 +index 7f1ffc0ac402fcf0ec086986e959ecc9f78dde03..1351d52374d1c2367932e5ecd5f4637955fb14c9 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/LootBonusEnchantment.java +++ b/src/main/java/net/minecraft/world/item/enchantment/LootBonusEnchantment.java @@ -7,6 +7,14 @@ public class LootBonusEnchantment extends Enchantment { - super(weight, target, slotTypes); + super(rarity, target, slotTypes); } + // Purpur start @@ -17455,10 +17367,10 @@ index 4007c16550683e23b396dfdff29530a82523fe05..8fe09c13643d99639fb242da4367c42e public int getMinCost(int level) { return 15 + (level - 1) * 9; diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java -index 28bdcb14cb5b458d3c990fcf343ef97f08e4f3c6..48167334162443365bb8a6d082a51b2c626ab3d8 100644 +index 4f7457578ab3118d10e0d5dfc23d79c9b20c2f44..e03ce53b93d1b9366f2a7f14f341750a163ae0db 100644 --- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java +++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java -@@ -134,7 +134,12 @@ public class MerchantOffer { +@@ -149,7 +149,12 @@ public class MerchantOffer { } public void updateDemand() { @@ -17485,10 +17397,10 @@ index 633500aefd515df5dadda3802b94079f75a03fa0..64d911bee1607880514061c75116d867 } diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index 3b959f42d958bf0f426853aee56753d6c455fcdb..d17abb283ea818244df0379d6b57fc634071e0b9 100644 +index aaa07fcd4b32fe0de88142ab30378327a01f1729..bc8555d21d418f9da37cc089904f7cb038b1cdbe 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java -@@ -154,7 +154,7 @@ public interface EntityGetter { +@@ -191,7 +191,7 @@ public interface EntityGetter { default boolean hasNearbyAlivePlayer(double x, double y, double z, double range) { for(Player player : this.players()) { @@ -17498,10 +17410,10 @@ index 3b959f42d958bf0f426853aee56753d6c455fcdb..d17abb283ea818244df0379d6b57fc63 if (range < 0.0D || d < range * range) { return true; diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 8f97c9df726ac20cfce7bdddd5dd4f8c5aa76c35..4932374ab9a3d8582fb0ef024d817ad896dd23c4 100644 +index 45243249a561440512ef2a620c60b02e159c80e2..ef9b1687dd2dfda5398523140aecc678b4690642 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -86,7 +86,7 @@ public class Explosion { +@@ -87,7 +87,7 @@ public class Explosion { this.hitPlayers = Maps.newHashMap(); this.level = world; this.source = entity; @@ -17510,7 +17422,7 @@ index 8f97c9df726ac20cfce7bdddd5dd4f8c5aa76c35..4932374ab9a3d8582fb0ef024d817ad8 this.x = x; this.y = y; this.z = z; -@@ -137,10 +137,27 @@ public class Explosion { +@@ -403,10 +403,27 @@ public class Explosion { public void explode() { // CraftBukkit start @@ -17539,7 +17451,7 @@ index 8f97c9df726ac20cfce7bdddd5dd4f8c5aa76c35..4932374ab9a3d8582fb0ef024d817ad8 this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z)); Set set = Sets.newHashSet(); boolean flag = true; -@@ -382,7 +399,7 @@ public class Explosion { +@@ -706,7 +723,7 @@ public class Explosion { if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper BlockPos blockposition1 = blockposition.immutable(); @@ -17548,7 +17460,7 @@ index 8f97c9df726ac20cfce7bdddd5dd4f8c5aa76c35..4932374ab9a3d8582fb0ef024d817ad8 if (block.dropFromExplosion(this)) { Level world = this.level; -@@ -404,7 +421,7 @@ public class Explosion { +@@ -728,7 +745,7 @@ public class Explosion { this.level.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); block.wasExploded(this.level, blockposition, this); @@ -17558,7 +17470,7 @@ index 8f97c9df726ac20cfce7bdddd5dd4f8c5aa76c35..4932374ab9a3d8582fb0ef024d817ad8 } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482279c27ec 100644 +index 4b49df79d366e58e1cee245e1aaefbb95f4fdfc0..75622ee77096d7eb311df0fd16b70c0f6dae3ccc 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -176,6 +176,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -17619,16 +17531,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 public CraftWorld getWorld() { return this.world; } -@@ -273,7 +317,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - public abstract ResourceKey getTypeKey(); - -- protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter -+ //protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter // Purpur - dont break ABI - - // Pufferfish start - ensure these get inlined - private final int minBuildHeight, minSection, height, maxBuildHeight, maxSection; -@@ -287,6 +331,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -213,6 +257,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper @@ -17637,7 +17540,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 this.generator = gen; this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); -@@ -966,18 +1012,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1253,18 +1299,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } protected void tickBlockEntities() { @@ -17661,7 +17564,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 // Spigot start // Iterator iterator = this.blockEntityTickers.iterator(); int tilesThisCycle = 0; -@@ -1010,10 +1056,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1297,10 +1343,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } this.blockEntityTickers.removeAll(toRemove); @@ -17674,7 +17577,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 spigotConfig.currentPrimedTnt = 0; // Spigot } -@@ -1206,7 +1252,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1503,7 +1549,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { @@ -17683,7 +17586,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 List list = Lists.newArrayList(); ((ServerLevel)this).getEntityLookup().getEntities(except, box, list, predicate); // Paper - optimise this call return list; -@@ -1225,7 +1271,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1522,7 +1568,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public void getEntities(EntityTypeTest filter, AABB box, Predicate predicate, List result, int limit) { @@ -17692,7 +17595,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 // Paper start - optimise this call //TODO use limit if (filter instanceof net.minecraft.world.entity.EntityType entityTypeTest) { -@@ -1482,7 +1528,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1779,7 +1825,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public ProfilerFiller getProfiler() { @@ -17701,10 +17604,10 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 return (ProfilerFiller) this.profiler.get(); } -@@ -1584,4 +1630,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1879,4 +1925,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } } - // Paper end + // Paper end - notify observers even if grow failed + + // Purpur start + public boolean isNether() { @@ -17717,7 +17620,7 @@ index 21c11ff8d5ae9bf97dfcf3118cabe678deb4c064..713a091b8083e46b395311889c2a1482 + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 49de1fca183b2c6a0a5399025abfc0e47f314315..1f9994f4b0b736f64a8676d9431469527c6484df 100644 +index 27b75fba1b8052a715979f48b28bba0e4be16274..f64d17e701aa38f7223b8c9a09f351ed84dbcf5d 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -132,8 +132,8 @@ public final class NaturalSpawner { @@ -17731,7 +17634,7 @@ index 49de1fca183b2c6a0a5399025abfc0e47f314315..1f9994f4b0b736f64a8676d943146952 MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; -@@ -188,8 +188,8 @@ public final class NaturalSpawner { +@@ -186,8 +186,8 @@ public final class NaturalSpawner { } } @@ -17742,12 +17645,12 @@ index 49de1fca183b2c6a0a5399025abfc0e47f314315..1f9994f4b0b736f64a8676d943146952 } // Paper start -@@ -260,7 +260,7 @@ public final class NaturalSpawner { +@@ -258,7 +258,7 @@ public final class NaturalSpawner { blockposition_mutableblockposition.set(l, i, i1); double d0 = (double) l + 0.5D; double d1 = (double) i1 + 0.5D; -- Player entityhuman = (chunk instanceof LevelChunk) ? ((LevelChunk)chunk).findNearestPlayer(d0, i, d1, 576.0D, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS) : world.getNearestPlayer(d0, (double) i, d1, -1.0D, false); // Paper - use chunk's player cache to optimize search in range -+ Player entityhuman = (chunk instanceof LevelChunk) ? ((LevelChunk)chunk).findNearestPlayer(d0, i, d1, 576.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers ? net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR : net.minecraft.world.entity.EntitySelector.NO_SPECTATORS) : world.getNearestPlayer(d0, (double) i, d1, -1.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers); // Paper - use chunk's player cache to optimize search in range // Purpur +- Player entityhuman = world.getNearestPlayer(d0, (double) i, d1, -1.0D, false); ++ Player entityhuman = world.getNearestPlayer(d0, (double) i, d1, -1.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers); // Purpur if (entityhuman != null) { double d2 = entityhuman.distanceToSqr(d0, (double) i, d1); @@ -17811,7 +17714,7 @@ index 5c5a3b169795bf8a527b316c666cbc2105c66622..020afeca950d2c7fb6c7b179d424548f return InteractionResult.SUCCESS; } else { diff --git a/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java b/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java -index 95b53450a807fccfa55b59852da52785b8cf3e3d..c69f1d23979a0759472d22760a18d986b2d979b6 100644 +index 087f3b3cc180e16195efdc0b402701fd9f5d78b4..aa4e13f1c77f10221128569483497668cd2eb7d3 100644 --- a/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java +++ b/src/main/java/net/minecraft/world/level/block/AzaleaBlock.java @@ -43,6 +43,20 @@ public class AzaleaBlock extends BushBlock implements BonemealableBlock { @@ -17879,7 +17782,7 @@ index d40500f9a807cab0b2fb6fa9032f33f4fb74c895..2b66ddafaaca17f64d1e7502dfa4d757 @Override diff --git a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java -index 5921f7ebb56e1d5d3004ae327271873093cff357..c7bb655983d2ee2c6461d23d6fa921def1a9a74c 100644 +index 54cf35b0c48d96ecfb27ff13cd685c16a1cd616b..1822ea0c72cc1685aab86a44f75c791bc5c595fa 100644 --- a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java @@ -236,7 +236,7 @@ public class BigDripleafBlock extends HorizontalDirectionalBlock implements Bone @@ -17892,7 +17795,7 @@ index 5921f7ebb56e1d5d3004ae327271873093cff357..c7bb655983d2ee2c6461d23d6fa921de if (i != -1) { world.scheduleTick(blockposition, (Block) this, i); diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index fdd9c61b7248e92dbcbec91cd6fe4c6310bba237..dc718efe054aaf36961514287c9cc48e2d28bc4c 100644 +index d4cbff18adb62073a1dceb189043789620af6877..65504432a13df45e895cf6ca885627014444563a 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -62,6 +62,13 @@ import net.minecraft.world.phys.shapes.Shapes; @@ -18022,10 +17925,10 @@ index fdd9c61b7248e92dbcbec91cd6fe4c6310bba237..dc718efe054aaf36961514287c9cc48e public void updateEntityAfterFallOn(BlockGetter world, Entity entity) { diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java -index 877035b6c6593a28f475b9c5bcd7727e3fcdb802..ed35878fdb9dffcd46c27d26ee8379401207cef5 100644 +index d5654cfe37bd82f1290b280990a8502432491ae1..6425bc42bb8024aa7936b841d6c2ee2c892eb329 100644 --- a/src/main/java/net/minecraft/world/level/block/Blocks.java +++ b/src/main/java/net/minecraft/world/level/block/Blocks.java -@@ -1093,8 +1093,8 @@ public class Blocks { +@@ -1094,8 +1094,8 @@ public class Blocks { public static final Block CAVE_VINES = register("cave_vines", new CaveVinesBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).randomTicks().noCollission().lightLevel(CaveVines.emission(14)).instabreak().sound(SoundType.CAVE_VINES).pushReaction(PushReaction.DESTROY))); public static final Block CAVE_VINES_PLANT = register("cave_vines_plant", new CaveVinesPlantBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().lightLevel(CaveVines.emission(14)).instabreak().sound(SoundType.CAVE_VINES).pushReaction(PushReaction.DESTROY))); public static final Block SPORE_BLOSSOM = register("spore_blossom", new SporeBlossomBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).instabreak().noCollission().sound(SoundType.SPORE_BLOSSOM).pushReaction(PushReaction.DESTROY))); @@ -18036,7 +17939,7 @@ index 877035b6c6593a28f475b9c5bcd7727e3fcdb802..ed35878fdb9dffcd46c27d26ee837940 public static final Block MOSS_CARPET = register("moss_carpet", new CarpetBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GREEN).strength(0.1F).sound(SoundType.MOSS_CARPET).pushReaction(PushReaction.DESTROY))); public static final Block PINK_PETALS = register("pink_petals", new PinkPetalsBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().sound(SoundType.PINK_PETALS).pushReaction(PushReaction.DESTROY))); public static final Block MOSS_BLOCK = register("moss_block", new MossBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GREEN).strength(0.1F).sound(SoundType.MOSS).pushReaction(PushReaction.DESTROY))); -@@ -1159,7 +1159,7 @@ public class Blocks { +@@ -1160,7 +1160,7 @@ public class Blocks { } private static Boolean ocelotOrParrot(BlockState state, BlockGetter world, BlockPos pos, EntityType type) { @@ -18075,7 +17978,7 @@ index 03fde6e47c4a347c62fe9b4a3351769aedf874f6..ca906b0250e5332f7ececf1419ca6d2c + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -index 0003fb51ae3a6575575e10b4c86719f3061e2577..0d5f87d24231f6d2b8639825bcd62dd2f8791c8e 100644 +index 0003fb51ae3a6575575e10b4c86719f3061e2577..fa6a2fbb8065b1f120750491b7e4b89542a6a891 100644 --- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java @@ -22,7 +22,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; @@ -18103,7 +18006,7 @@ index 0003fb51ae3a6575575e10b4c86719f3061e2577..0d5f87d24231f6d2b8639825bcd62dd2 + + // Purpur start + @Override -+ public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) { ++ public boolean isValidBonemealTarget(final LevelReader world, final BlockPos pos, final BlockState state) { + if (!((Level) world).purpurConfig.cactusAffectedByBonemeal || !world.isEmptyBlock(pos.above())) return false; + + int cactusHeight = 0; @@ -18132,10 +18035,10 @@ index 0003fb51ae3a6575575e10b4c86719f3061e2577..0d5f87d24231f6d2b8639825bcd62dd2 + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -index 219c87dcf065e86512f330fbeec59e55f4675083..f8fd3b320494d1c1e8ee3d170f2feebd152230fa 100644 +index 7700461b8cd0bde1bf6c0d5e4b73184bed1adc4e..cfa02b274286374c7555919d0e8d66a2c8fb8b88 100644 --- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -@@ -122,7 +122,7 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB +@@ -123,7 +123,7 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB BlockPos blockposition = ctx.getClickedPos(); boolean flag = world.getFluidState(blockposition).getType() == Fluids.WATER; @@ -18197,7 +18100,7 @@ index 2f85b893dd0abc39fcedec65acc89e1567faf6f0..3ee012a9ef8cada0b2203e53b2f731f6 @Override diff --git a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java -index 18b5bce1138d50be32e5da013221be69dc47e21f..58b4a0d97af37f7164db86ef821f04102c6c5ddd 100644 +index ead7b37122c76d43af2cdd17af7f0da8014efb26..1acc2dcda68ec8e462d51927f2ea985e7952a830 100644 --- a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java @@ -88,4 +88,11 @@ public class CaveVinesBlock extends GrowingPlantHeadBlock implements Bonemealabl @@ -18309,10 +18212,10 @@ index 88faea00be60a519f56f975a5311df5e1eb3e6b8..cbb726ac367be81e27d3a86643baf7c4 int i = aenumdirection.length; diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java -index decb8caa67bc5f4525e4d92fedf465a17171fceb..26b3f162f25bed3e9d8001e3d9c2f8d7d4b3e08a 100644 +index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..61d051f42d8c3d1f039b97fdc7a61b54f57ee86a 100644 --- a/src/main/java/net/minecraft/world/level/block/CropBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java -@@ -168,7 +168,7 @@ public class CropBlock extends BushBlock implements BonemealableBlock { +@@ -172,7 +172,7 @@ public class CropBlock extends BushBlock implements BonemealableBlock { @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper @@ -18321,7 +18224,7 @@ index decb8caa67bc5f4525e4d92fedf465a17171fceb..26b3f162f25bed3e9d8001e3d9c2f8d7 world.destroyBlock(pos, true, entity); } -@@ -203,4 +203,15 @@ public class CropBlock extends BushBlock implements BonemealableBlock { +@@ -207,4 +207,15 @@ public class CropBlock extends BushBlock implements BonemealableBlock { protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(CropBlock.AGE); } @@ -18541,7 +18444,7 @@ index 5946f06f63b5694034bd027984a4925b0831d439..d566f67f8f6f1748023430de4f191881 @Override diff --git a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java -index 3a1aa4e2405090ccebefb7f5944f36462929e221..f3cf9f06de40054720d1847c1869a9d82592134d 100644 +index b325fdec8eb99ce57152a5c0fefa5059685276e4..c93e60b01dd46e7de6a6b5a5149a522304f28178 100644 --- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java @@ -30,12 +30,12 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @@ -18640,10 +18543,10 @@ index 04089e6f7d6e3d532b00585870283922b6be5246..61e6d14abd54ecd5e43a5459f8daa7d8 } else { world.setBlockAndUpdate(pos, IceBlock.meltsInto()); diff --git a/src/main/java/net/minecraft/world/level/block/KelpBlock.java b/src/main/java/net/minecraft/world/level/block/KelpBlock.java -index bc66fa91ec3e13431d5d9b6e17935cab73066be7..0f16b5ed2e249f3d8f583dc941e32066d354cf95 100644 +index ff30a93f4160e8e22b40c7a7033c14fa15839160..bf043e1b9f0ec5876a2fa2d0597ec3c60b32b2c0 100644 --- a/src/main/java/net/minecraft/world/level/block/KelpBlock.java +++ b/src/main/java/net/minecraft/world/level/block/KelpBlock.java -@@ -64,4 +64,11 @@ public class KelpBlock extends GrowingPlantHeadBlock implements LiquidBlockConta +@@ -65,4 +65,11 @@ public class KelpBlock extends GrowingPlantHeadBlock implements LiquidBlockConta public FluidState getFluidState(BlockState state) { return Fluids.WATER.getSource(false); } @@ -18656,10 +18559,10 @@ index bc66fa91ec3e13431d5d9b6e17935cab73066be7..0f16b5ed2e249f3d8f583dc941e32066 + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -index bbabe4ad8afcc3a2069f6e9d4a9adcb643266894..55419bd653f7f5391fa13cd15a0b00fbff5e9c39 100644 +index 4a1830f85f47014da63e4584f411d13f0f0cd8b3..17b3dbb83fd9eb6ecdd58c1ac6446410b4bc3a51 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -105,7 +105,7 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -107,7 +107,7 @@ public class LiquidBlock extends Block implements BucketPickup { @Override public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { @@ -18668,7 +18571,7 @@ index bbabe4ad8afcc3a2069f6e9d4a9adcb643266894..55419bd653f7f5391fa13cd15a0b00fb world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper } -@@ -133,7 +133,7 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -135,7 +135,7 @@ public class LiquidBlock extends Block implements BucketPickup { @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { @@ -18677,7 +18580,7 @@ index bbabe4ad8afcc3a2069f6e9d4a9adcb643266894..55419bd653f7f5391fa13cd15a0b00fb world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world)); } -@@ -142,7 +142,7 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -144,7 +144,7 @@ public class LiquidBlock extends Block implements BucketPickup { @Override public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { @@ -18728,7 +18631,7 @@ index a6ab0d0defc05e56a91084c49897059670a1324b..589b437e7c97c846410f293e2f014bdc EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ())); world.getCraftServer().getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java b/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java -index e55720c4d2fbdf6aae526910e87a67c29cf906fd..4310d62c45c776eea81987809309da08c242c7b0 100644 +index e55720c4d2fbdf6aae526910e87a67c29cf906fd..7d15796e3637c1a865703807c98a22c01315c307 100644 --- a/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java +++ b/src/main/java/net/minecraft/world/level/block/NetherWartBlock.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty; @@ -18756,7 +18659,7 @@ index e55720c4d2fbdf6aae526910e87a67c29cf906fd..4310d62c45c776eea81987809309da08 + } + + @Override -+ public boolean isValidBonemealTarget(net.minecraft.world.level.LevelReader world, BlockPos pos, BlockState state, boolean isClient) { ++ public boolean isValidBonemealTarget(final net.minecraft.world.level.LevelReader world, final BlockPos pos, final BlockState state) { + return ((net.minecraft.world.level.Level) world).purpurConfig.netherWartAffectedByBonemeal && state.getValue(NetherWartBlock.AGE) < 3; + } + @@ -18828,10 +18731,10 @@ index cd943997f11f5ea5c600fdc6db96043fb0fa713c..4adeda49a2e422e11f885bffb311653d if (dripChance < f1) { diff --git a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java -index 7e04ecba2a14be0f0d47c917368abd2a2bd64a05..5c944e39e611201c6ae4dad14511a54c451204f6 100644 +index e6fcea4482d5d87ed78beefad4c57bc86089460f..1626eb90a6b348ad9735b82452f52d4560075a03 100644 --- a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -72,7 +72,7 @@ public class PowderSnowBlock extends Block implements BucketPickup { +@@ -73,7 +73,7 @@ public class PowderSnowBlock extends Block implements BucketPickup { if (!world.isClientSide) { // CraftBukkit start if (entity.isOnFire() && entity.mayInteract(world, pos)) { @@ -18880,10 +18783,10 @@ index 02d01eabb9606ae8c3b76ad9fa4bb9a525e247b1..ce51fec4a874f9466f9966684c535315 @Override diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java -index b51155ad12515b2d0dd0f202580b9f455c114d9a..dd6c82a418ee299d7a5614cb0260949c198b4149 100644 +index d5fe3b8e2f5a8899f6afeb0600764284a617f261..2b513fc2f6c33963e43093cb08594bff946d72fa 100644 --- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -137,7 +137,7 @@ public class ShulkerBoxBlock extends BaseEntityBlock { +@@ -135,7 +135,7 @@ public class ShulkerBoxBlock extends BaseEntityBlock { public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity) { @@ -18893,10 +18796,10 @@ index b51155ad12515b2d0dd0f202580b9f455c114d9a..dd6c82a418ee299d7a5614cb0260949c blockEntity.saveToItem(itemStack); if (shulkerBoxBlockEntity.hasCustomName()) { diff --git a/src/main/java/net/minecraft/world/level/block/SlabBlock.java b/src/main/java/net/minecraft/world/level/block/SlabBlock.java -index 18b603d646081926343dea108b55d641df1c2c34..370772b1297b78bcc7419684015830a87c4d9a17 100644 +index ea8c78af35b0ddc0d08adfccfc78770b867e5df6..88cfa41f90d4ad395b96fd0b69ac0bdefe06ed2d 100644 --- a/src/main/java/net/minecraft/world/level/block/SlabBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SlabBlock.java -@@ -130,4 +130,25 @@ public class SlabBlock extends Block implements SimpleWaterloggedBlock { +@@ -131,4 +131,25 @@ public class SlabBlock extends Block implements SimpleWaterloggedBlock { return false; } } @@ -19011,10 +18914,10 @@ index 936d844a5a246138c9f9ae4ae6e318242b8f1420..93f5f226cf6fd6110e4daa02b3f5d9ad int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java -index 4bce895268542531598a01a1bccd8ac1ed703b7d..2276fed1feb4fea59b5bd49b5e4586d49478b3cc 100644 +index d810f6bf9a8a354e5b8994e51ec3672428277dde..cc1ac862526377b2ac7b66bc20f428dc1aed6e78 100644 --- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java -@@ -48,7 +48,7 @@ public class SpongeBlock extends Block { +@@ -51,7 +51,7 @@ public class SpongeBlock extends Block { private boolean removeWaterBreadthFirstSearch(Level world, BlockPos pos) { BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator @@ -19023,7 +18926,7 @@ index 4bce895268542531598a01a1bccd8ac1ed703b7d..2276fed1feb4fea59b5bd49b5e4586d4 Direction[] aenumdirection = SpongeBlock.ALL_DIRECTIONS; int i = aenumdirection.length; -@@ -67,7 +67,7 @@ public class SpongeBlock extends Block { +@@ -70,7 +70,7 @@ public class SpongeBlock extends Block { FluidState fluid = blockList.getFluidState(blockposition1); // CraftBukkit end @@ -19032,7 +18935,7 @@ index 4bce895268542531598a01a1bccd8ac1ed703b7d..2276fed1feb4fea59b5bd49b5e4586d4 return false; } else { Block block = iblockdata.getBlock(); -@@ -82,6 +82,10 @@ public class SpongeBlock extends Block { +@@ -85,6 +85,10 @@ public class SpongeBlock extends Block { if (iblockdata.getBlock() instanceof LiquidBlock) { blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit @@ -19065,7 +18968,7 @@ index 0a95842c53a9d0286c57bcb42db97e468e30fb7d..0882e67c5cf876e0fc58a4ca4accb4be + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java -index c3f500580d257e1397f2eb7c47b063a6fe6bb405..0d5c6bdfd4aeda472804b493315bf21ac3067e9d 100644 +index c3f500580d257e1397f2eb7c47b063a6fe6bb405..21a194fadb7d1f0a30f94caf999dabdd78847f36 100644 --- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java @@ -19,7 +19,7 @@ import net.minecraft.world.level.material.FluidState; @@ -19084,7 +18987,7 @@ index c3f500580d257e1397f2eb7c47b063a6fe6bb405..0d5c6bdfd4aeda472804b493315bf21a + + // Purpur start + @Override -+ public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) { ++ public boolean isValidBonemealTarget(final LevelReader world, final BlockPos pos, final BlockState state) { + if (!((net.minecraft.world.level.Level) world).purpurConfig.sugarCanAffectedByBonemeal || !world.isEmptyBlock(pos.above())) return false; + + int reedHeight = 0; @@ -19113,10 +19016,10 @@ index c3f500580d257e1397f2eb7c47b063a6fe6bb405..0d5c6bdfd4aeda472804b493315bf21a + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java b/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java -index 181e99e3f29c70568b6f28f8a5d3bb692f7abad8..58facc048840d3ba0a58c92673340e6e0aa4e305 100644 +index 07157822659288e76b2fba34db8d5d566506f33b..e23b920be6702ef6faf97b42fb8a87442707d6be 100644 --- a/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -160,7 +160,7 @@ public class TurtleEggBlock extends Block { +@@ -162,7 +162,7 @@ public class TurtleEggBlock extends Block { private boolean shouldUpdateHatchLevel(Level world) { float f = world.getTimeOfDay(1.0F); @@ -19125,7 +19028,7 @@ index 181e99e3f29c70568b6f28f8a5d3bb692f7abad8..58facc048840d3ba0a58c92673340e6e } @Override -@@ -193,6 +193,31 @@ public class TurtleEggBlock extends Block { +@@ -195,6 +195,31 @@ public class TurtleEggBlock extends Block { } private boolean canDestroyEgg(Level world, Entity entity) { @@ -19203,7 +19106,7 @@ index 1aa0e921890d600c9274deb923da04e72b12bcc6..44bd7bee2665a05878fd2df935a700f0 if (!world.addFreshEntity(entitywither, SpawnReason.BUILD_WITHER)) { return; diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 448fa4f4f200430d6ce3051763c7ceb697696146..997d0fab71eacc6466ffe3bc8f6349e5813d6d49 100644 +index a18aadbf7ae83713e1f2b21553185d8000bc7699..92e58d9503daf4cc9bc1f4c7785e159e0c1f4bf3 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -44,6 +44,7 @@ import net.minecraft.world.level.Level; @@ -19266,7 +19169,7 @@ index 448fa4f4f200430d6ce3051763c7ceb697696146..997d0fab71eacc6466ffe3bc8f6349e5 + if (usedLavaFromUnderneath) blockEntity.items.set(1, ItemStack.EMPTY); // Purpur } - private static boolean canBurn(RegistryAccess registryManager, @Nullable Recipe recipe, NonNullList slots, int count) { + private static boolean canBurn(RegistryAccess registryManager, @Nullable RecipeHolder recipe, NonNullList slots, int count) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java index 416aa989ebb18a8741cc9d605a1180ab830f6643..e38a0adf5463c48311ad08b8d2e5b5c2d989a3b5 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java @@ -19326,10 +19229,10 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..e38a0adf5463c48311ad08b8d2e5b5c2 @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index 5c951ef93fe4cf4f085df86b0cefc02bc2610ab9..2979c1eceaac79a82da19eba5d8fb1db6537ff45 100644 +index f13943db6f2fb923c52dcf9e8bf7000041d0a362..99ef8d7e3ee0ee9777d12ad825e728c38d886114 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -84,6 +84,16 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name +@@ -88,6 +88,16 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name public double getEffectRange() { if (this.effectRange < 0) { @@ -19346,7 +19249,7 @@ index 5c951ef93fe4cf4f085df86b0cefc02bc2610ab9..2979c1eceaac79a82da19eba5d8fb1db return this.levels * 10 + 10; } else { return effectRange; -@@ -155,6 +165,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name +@@ -164,6 +174,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name int j = pos.getY(); int k = pos.getZ(); BlockPos blockposition1; @@ -19354,7 +19257,7 @@ index 5c951ef93fe4cf4f085df86b0cefc02bc2610ab9..2979c1eceaac79a82da19eba5d8fb1db if (blockEntity.lastCheckY < j) { blockposition1 = pos; -@@ -188,6 +199,9 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name +@@ -197,6 +208,9 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name } } } else { @@ -19364,7 +19267,7 @@ index 5c951ef93fe4cf4f085df86b0cefc02bc2610ab9..2979c1eceaac79a82da19eba5d8fb1db if (tileentitybeacon_beaconcolortracker == null || iblockdata1.getLightBlock(world, blockposition1) >= 15 && !iblockdata1.is(Blocks.BEDROCK)) { blockEntity.checkingBeamSections.clear(); blockEntity.lastCheckY = l; -@@ -207,7 +221,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name +@@ -216,7 +230,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name blockEntity.levels = BeaconBlockEntity.updateBase(world, i, j, k); } @@ -19783,7 +19686,7 @@ index 744d91546d1a810f60a43c15ed74b4158f341a4a..354538daefa603f6df5a139b6bff87db } diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index de4c1e4701236e7d5ec77339c51ad6a9d8288bb6..942ce713afe27ec75d849877a88721ef6334fafa 100644 +index e6a4a5898ffdcb2aa2bc01371a6d7dbc06d610ce..e46a097dc134672720bc753ec0da0a9102737d2c 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -81,7 +81,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -19805,19 +19708,10 @@ index de4c1e4701236e7d5ec77339c51ad6a9d8288bb6..942ce713afe27ec75d849877a88721ef protected ResourceLocation drops; diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 3eeb1f0eac76efe9b7c24f6d5787018c7842d07a..c17b04880b4032984b43dd4fbe1c08f96112abac 100644 +index 4abec88caab4116cfa318f7b66c6b1a8346a7401..8d385708df97d47881929d4352f1b90286aad1a2 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -125,7 +125,7 @@ public class LevelChunk extends ChunkAccess { - this.blockTicks = blockTickScheduler; - this.fluidTicks = fluidTickScheduler; - -- this.lightningTick = this.level.getThreadUnsafeRandom().nextInt(100000) << 1; // Pufferfish - initialize lightning tick -+ this.lightningTick = java.util.concurrent.ThreadLocalRandom.current().nextInt(100000) << 1; // Pufferfish - initialize lightning tick // Purpur - any random will do - } - - // CraftBukkit start -@@ -552,11 +552,11 @@ public class LevelChunk extends ChunkAccess { +@@ -447,11 +447,11 @@ public class LevelChunk extends ChunkAccess { if (LightEngine.hasDifferentLightProperties(this, blockposition, iblockdata1, iblockdata)) { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); @@ -19832,7 +19726,7 @@ index 3eeb1f0eac76efe9b7c24f6d5787018c7842d07a..c17b04880b4032984b43dd4fbe1c08f9 } boolean flag3 = iblockdata1.hasBlockEntity(); -@@ -895,7 +895,7 @@ public class LevelChunk extends ChunkAccess { +@@ -790,7 +790,7 @@ public class LevelChunk extends ChunkAccess { this.chunkHolder.getEntityChunk().callEntitiesLoadEvent(); // Paper - rewrite chunk system if (this.needsDecoration) { @@ -19841,7 +19735,7 @@ index 3eeb1f0eac76efe9b7c24f6d5787018c7842d07a..c17b04880b4032984b43dd4fbe1c08f9 this.needsDecoration = false; java.util.Random random = new java.util.Random(); random.setSeed(this.level.getSeed()); -@@ -915,7 +915,7 @@ public class LevelChunk extends ChunkAccess { +@@ -810,7 +810,7 @@ public class LevelChunk extends ChunkAccess { } } server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); @@ -19850,30 +19744,30 @@ index 3eeb1f0eac76efe9b7c24f6d5787018c7842d07a..c17b04880b4032984b43dd4fbe1c08f9 } } } -@@ -1270,10 +1270,10 @@ public class LevelChunk extends ChunkAccess { +@@ -1165,10 +1165,10 @@ public class LevelChunk extends ChunkAccess { if (LevelChunk.this.isTicking(blockposition)) { try { - ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); // Purpur ++ //ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); - gameprofilerfiller.push(this::getType); - this.blockEntity.tickTimer.startTiming(); // Spigot -+ //gameprofilerfiller.push(this::getType); // Purpur ++ //gameprofilerfiller.push(this::getType); + //this.blockEntity.tickTimer.startTiming(); // Spigot // Purpur BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); if (this.blockEntity.getType().isValid(iblockdata)) { -@@ -1284,7 +1284,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1179,7 +1179,7 @@ public class LevelChunk extends ChunkAccess { LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), iblockdata}); } - gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur ++ //gameprofilerfiller.pop(); } catch (Throwable throwable) { if (throwable instanceof ThreadDeath) throw throwable; // Paper // Paper start - Prevent tile entity and entity crashes -@@ -1295,7 +1295,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1190,7 +1190,7 @@ public class LevelChunk extends ChunkAccess { // Paper end // Spigot start } finally { @@ -19930,7 +19824,7 @@ index dfeb3e336e06ef01f5401a362755030db942bb07..f74c5eda91a3d521763ec7bc33f23e0c for (int l = 0; l < k; ++l) { // Paper start diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index 7d56693102ee558fe784e3a9b9fdcff4b7ad57b9..485bbec4b52f126393332d5cad2d97c2a220f91a 100644 +index 089f42d16b2e279fa0daefb8705867a4e9ed54d7..f48d32bf4d7f179e7ad21cf4f395de9180c6c8f0 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java @@ -227,7 +227,7 @@ public abstract class FlowingFluid extends Fluid { @@ -19942,7 +19836,7 @@ index 7d56693102ee558fe784e3a9b9fdcff4b7ad57b9..485bbec4b52f126393332d5cad2d97c2 BlockState iblockdata2 = world.getBlockState(pos.below()); FluidState fluid1 = iblockdata2.getFluidState(); -@@ -325,6 +325,12 @@ public abstract class FlowingFluid extends Fluid { +@@ -334,6 +334,12 @@ public abstract class FlowingFluid extends Fluid { protected abstract boolean canConvertToSource(Level world); @@ -20060,10 +19954,10 @@ index c461e0d04047db9c0c5ecc04063cebd38bf96ec2..e7554ec800f321e4e34c926c53f2375a private static final float SAFE_TRAVEL_MAX_ENTITY_XY = 4.0F; private static final double SAFE_TRAVEL_MAX_VERTICAL_DELTA = 1.0D; diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 50713f03c783c63f93710d986d94af544be0615a..e64921f454c88e2ca9e1396fcb1ca7c179ff71a7 100644 +index e4c4948e076cd64686dfd16ae0568fafc1437140..804c342783baccdc12e8ca49a362770e31596f6a 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -66,6 +66,7 @@ public class MapItemSavedData extends SavedData { +@@ -67,6 +67,7 @@ public class MapItemSavedData extends SavedData { private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper @@ -20072,10 +19966,10 @@ index 50713f03c783c63f93710d986d94af544be0615a..e64921f454c88e2ca9e1396fcb1ca7c1 // CraftBukkit start public final CraftMapView mapView; diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java -index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..15d8e9261a89da30529ac347462c520920ca4e7d 100644 +index 3fb1e558c3510243c94981211f9a0e5e0ef1895b..e5177e5ffcac360f935f2139db4554c6586b551e 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java -@@ -49,6 +49,13 @@ public class LootingEnchantFunction extends LootItemConditionalFunction { +@@ -57,6 +57,13 @@ public class LootingEnchantFunction extends LootItemConditionalFunction { if (entity instanceof LivingEntity) { int i = EnchantmentHelper.getMobLooting((LivingEntity) entity); @@ -20090,7 +19984,7 @@ index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..15d8e9261a89da30529ac347462c5209 if (context.hasParam(LootContextParams.LOOTING_MOD)) { i = context.getParamOrNull(LootContextParams.LOOTING_MOD); diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java -index ffc76354ead6937daf366c3d87bcb51d3e4c47f5..5b98d42b5d6bc07265fbb017e51a6281c148436a 100644 +index e3dbf3066337a482460238f8a94d854cf88adfa2..5c70aa2ce1a9e89c8c271201b6755ea1325058ac 100644 --- a/src/main/java/net/minecraft/world/phys/AABB.java +++ b/src/main/java/net/minecraft/world/phys/AABB.java @@ -374,4 +374,10 @@ public class AABB { @@ -20138,7 +20032,7 @@ index 1d7c663fa0e550bd0cfb9a4b83ccd7e2968666f0..0043c0087896a6df6910b0500da37d84 this.rescheduleLeftoverContainers(); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java -index c1b874cd6e0498fce3cd53fdbaca30d290e004d7..23087d511b609693f0bb06cbaac8b6cf8d0defe2 100644 +index 03fc90a470c0f63d44161843cac88bea09166858..88640ac32d70ced6e8b1984663e1c492dd673cb5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -567,4 +567,213 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa @@ -20356,10 +20250,10 @@ index c1b874cd6e0498fce3cd53fdbaca30d290e004d7..23087d511b609693f0bb06cbaac8b6cf + // Purpur end - OfflinePlayer API } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714f8ddd7ee 100644 +index 7f2f4f3d804832e314983ba78fe9c6cc3cfcdb1f..a7081f2ce7e001c9a75b620c55703a0218f6dc28 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -265,7 +265,7 @@ import javax.annotation.Nullable; // Paper +@@ -267,7 +267,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { @@ -20368,7 +20262,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); -@@ -397,6 +397,20 @@ public final class CraftServer implements Server { +@@ -399,6 +399,20 @@ public final class CraftServer implements Server { this.dataPackManager = new CraftDataPackManager(this.getServer().getPackRepository()); Bukkit.setServer(this); @@ -20389,7 +20283,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 CraftRegistry.setMinecraftRegistry(console.registryAccess()); -@@ -1037,6 +1051,7 @@ public final class CraftServer implements Server { +@@ -1039,6 +1053,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); @@ -20397,7 +20291,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1052,6 +1067,7 @@ public final class CraftServer implements Server { +@@ -1054,6 +1069,7 @@ public final class CraftServer implements Server { } } world.spigotConfig.init(); // Spigot @@ -20405,7 +20299,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper -@@ -1067,6 +1083,7 @@ public final class CraftServer implements Server { +@@ -1069,6 +1085,7 @@ public final class CraftServer implements Server { this.reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper @@ -20413,7 +20307,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -1532,6 +1549,55 @@ public final class CraftServer implements Server { +@@ -1534,6 +1551,55 @@ public final class CraftServer implements Server { return true; } @@ -20469,7 +20363,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 @Override public List getRecipesFor(ItemStack result) { Preconditions.checkArgument(result != null, "ItemStack cannot be null"); -@@ -2871,6 +2937,7 @@ public final class CraftServer implements Server { +@@ -2873,6 +2939,7 @@ public final class CraftServer implements Server { @Override public double[] getTPS() { return new double[] { @@ -20477,7 +20371,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 net.minecraft.server.MinecraftServer.getServer().tps1.getAverage(), net.minecraft.server.MinecraftServer.getServer().tps5.getAverage(), net.minecraft.server.MinecraftServer.getServer().tps15.getAverage() -@@ -2917,6 +2984,18 @@ public final class CraftServer implements Server { +@@ -2919,6 +2986,18 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -20496,7 +20390,7 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 @Override public void restart() { org.spigotmc.RestartCommand.restart(); -@@ -3130,4 +3209,16 @@ public final class CraftServer implements Server { +@@ -3132,4 +3211,16 @@ public final class CraftServer implements Server { } // Paper end @@ -20514,10 +20408,10 @@ index 0f89716d1131178bd7ac927ef68337357139e2b7..b21bc96232d0fd52e5dae7fa1c413714 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index f857f490ffba2f25f7c06c5fb1a1905f0b51fbe2..1392e483c363e25d1f16465d876cb7d7c70afa68 100644 +index 0e670de77a7f9926e295e1dd63d909bed1a959ca..52b48e40c3ee5f483c6cb04409459cf25abc3f0d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2290,6 +2290,48 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2289,6 +2289,48 @@ public class CraftWorld extends CraftRegionAccessor implements World { return (this.getHandle().getDragonFight() == null) ? null : new CraftDragonBattle(this.getHandle().getDragonFight()); } @@ -20567,7 +20461,7 @@ index f857f490ffba2f25f7c06c5fb1a1905f0b51fbe2..1392e483c363e25d1f16465d876cb7d7 public PersistentDataContainer getPersistentDataContainer() { return this.persistentDataContainer; diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 7c29d92362a82330440dff151bcf421f15c68f71..4bc0a370c7aec06d30b4ebf7fa7d73263d0543bc 100644 +index e7746952417a3ca4ea97103e38568db42039f717..e006351f07356fb42e5858bb3b8a74ffee215b35 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -173,6 +173,20 @@ public class Main { @@ -20582,10 +20476,10 @@ index 7c29d92362a82330440dff151bcf421f15c68f71..4bc0a370c7aec06d30b4ebf7fa7d7326 + .describedAs("Yml file"); + + acceptsAll(asList("pufferfish", "pufferfish-settings"), "File for pufferfish settings") -+ .withRequiredArg() -+ .ofType(File.class) -+ .defaultsTo(new File("pufferfish.yml")) -+ .describedAs("Yml file"); ++ .withRequiredArg() ++ .ofType(File.class) ++ .defaultsTo(new File("pufferfish.yml")) ++ .describedAs("Yml file"); + // Purpur end + // Paper start @@ -20750,11 +20644,11 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..985e9ec21c60a1f47973bd5fc53b96a6 // Paper start @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 2dbe8b870fd39b4d22e9725912f443757ae70761..8973c8a3bad120e55269bf1b7b810284ad0fe14c 100644 +index e932cfac619c30b8c7444a9fa41e0403a6eadf6a..236d753266943d8c64e1329336d28c50109d0886 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -224,6 +224,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - this.entityType = (type != null) ? type : EntityType.UNKNOWN; +@@ -223,6 +223,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { + this.entityType = CraftEntityType.minecraftToBukkit(entity.getType()); } + @Override @@ -20775,7 +20669,7 @@ index 2dbe8b870fd39b4d22e9725912f443757ae70761..8973c8a3bad120e55269bf1b7b810284 public static CraftEntity getEntity(CraftServer server, Entity entity) { /* * Order is *EXTREMELY* important -- keep it right! =D -@@ -601,6 +616,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -600,6 +615,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Paper end if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API @@ -20786,7 +20680,7 @@ index 2dbe8b870fd39b4d22e9725912f443757ae70761..8973c8a3bad120e55269bf1b7b810284 return false; } -@@ -1507,4 +1526,27 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -1506,4 +1525,27 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return this.getHandle().getScoreboardName(); } // Paper end - entity scoreboard name @@ -20815,7 +20709,7 @@ index 2dbe8b870fd39b4d22e9725912f443757ae70761..8973c8a3bad120e55269bf1b7b810284 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index 7db63d9ef93902872937b69f431137336e4abc3a..05ab5d0ae25f154d16c7bf107e93ed8e31e1f992 100644 +index 017e97c1618b8ee4640b36a0ec1b07026047bfc3..cf124ad445fd5e8adb1114aca5113e274d950a4a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -266,6 +266,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -20905,7 +20799,7 @@ index 5e83fabb20bc2b0668cbf48530053ca1bb9092f3..4ffb4046b63cbc140c76721f51c9a7a0 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index b25f5931f836fd4d8695120f0bcb7c52deff8583..b473f89c59c0fc080fadd0d4db320895e917fd41 100644 +index fe2124694eb080cab685a1ce1f6a66e2fcdf6a17..465e63a5849e224d86e82ef6c31c99846245e63b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -453,7 +453,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -20921,17 +20815,17 @@ index b25f5931f836fd4d8695120f0bcb7c52deff8583..b473f89c59c0fc080fadd0d4db320895 @Override public boolean addPotionEffect(PotionEffect effect, boolean force) { org.spigotmc.AsyncCatcher.catchOp("effect add"); // Paper -- this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon -+ this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon(), effect.getKey()), EntityPotionEffectEvent.Cause.PLUGIN); // Purpur - add key // Paper - Don't ignore icon +- this.getHandle().addEffect(new MobEffectInstance(CraftPotionEffectType.bukkitToMinecraft(effect.getType()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon ++ this.getHandle().addEffect(new MobEffectInstance(CraftPotionEffectType.bukkitToMinecraft(effect.getType()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon(), effect.getKey()), EntityPotionEffectEvent.Cause.PLUGIN); // Purpur - add key // Paper - Don't ignore icon return true; } @@ -486,7 +486,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public PotionEffect getPotionEffect(PotionEffectType type) { - MobEffectInstance handle = this.getHandle().getEffect(MobEffect.byId(type.getId())); -- return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffect.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible()); -+ return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffect.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible(), handle.getKey()); // Purpur - add key + MobEffectInstance handle = this.getHandle().getEffect(CraftPotionEffectType.bukkitToMinecraft(type)); +- return (handle == null) ? null : new PotionEffect(CraftPotionEffectType.minecraftToBukkit(handle.getEffect()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible()); ++ return (handle == null) ? null : new PotionEffect(CraftPotionEffectType.minecraftToBukkit(handle.getEffect()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible(), handle.getKey()); // Purpur - add key } @Override @@ -20939,8 +20833,8 @@ index b25f5931f836fd4d8695120f0bcb7c52deff8583..b473f89c59c0fc080fadd0d4db320895 public Collection getActivePotionEffects() { List effects = new ArrayList(); for (MobEffectInstance handle : this.getHandle().activeEffects.values()) { -- effects.add(new PotionEffect(PotionEffectType.getById(MobEffect.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible())); -+ effects.add(new PotionEffect(PotionEffectType.getById(MobEffect.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible(), handle.getKey())); // Purpur - add key +- effects.add(new PotionEffect(CraftPotionEffectType.minecraftToBukkit(handle.getEffect()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible())); ++ effects.add(new PotionEffect(CraftPotionEffectType.minecraftToBukkit(handle.getEffect()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible(), handle.getKey())); // Purpur - add key } return effects; } @@ -21008,10 +20902,10 @@ index 0ad16ee7b33582d214dab41eeee378d52c8e38ed..16bd1294c219f15ada653ef810bc2d74 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca42354519c742 100644 +index e188bb3ba5d2ec28421947c0b66b25eecb569bfe..28910943e5efcdf24865b961fba161b7d1e4a8f5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -517,10 +517,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -519,10 +519,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setPlayerListName(String name) { @@ -21028,7 +20922,7 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 for (ServerPlayer player : (List) server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this.getHandle())); -@@ -1350,6 +1355,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1352,6 +1357,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } if (entity.isVehicle() && !ignorePassengers) { // Paper - Teleport API @@ -21039,7 +20933,7 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 return false; } -@@ -2496,6 +2505,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2512,6 +2521,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.getHandle().getAbilities().walkingSpeed * 2f; } @@ -21068,7 +20962,7 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 private void validateSpeed(float value) { Preconditions.checkArgument(value <= 1f && value >= -1f, "Speed value (%s) need to be between -1f and 1f", value); } -@@ -3267,4 +3298,90 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3283,4 +3314,70 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.spigot; } // Spigot end @@ -21095,21 +20989,6 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 + } + + @Override -+ public boolean isSpawnInvulnerable() { -+ return getHandle().isSpawnInvulnerable(); -+ } -+ -+ @Override -+ public int getSpawnInvulnerableTicks() { -+ return getHandle().spawnInvulnerableTime; -+ } -+ -+ @Override -+ public void setSpawnInvulnerableTicks(int spawnInvulnerableTime) { -+ getHandle().spawnInvulnerableTime = spawnInvulnerableTime; -+ } -+ -+ @Override + public void sendBlockHighlight(Location location, int duration) { + sendBlockHighlight(location, duration, "", 0x6400FF00); + } @@ -21127,12 +21006,7 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 + @Override + public void sendBlockHighlight(Location location, int duration, String text, int argb) { + if (this.getHandle().connection == null) return; -+ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); -+ buf.writeBlockPos(io.papermc.paper.util.MCUtil.toBlockPosition(location)); -+ buf.writeInt(argb); -+ buf.writeUtf(text); -+ buf.writeInt(duration); -+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.DEBUG_GAME_TEST_ADD_MARKER, buf)); ++ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket(new net.minecraft.network.protocol.common.custom.GameTestAddMarkerDebugPayload(io.papermc.paper.util.MCUtil.toBlockPosition(location), argb, text, duration))); + } + + @Override @@ -21149,7 +21023,7 @@ index 3d5876cbadb5c8c02de751c3e15fc7f251ea7d35..720a81da72a8002ff02cc39e5fca4235 + @Override + public void clearBlockHighlights() { + if (this.getHandle().connection == null) return; -+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.DEBUG_GAME_TEST_CLEAR, new FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()))); ++ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket(new net.minecraft.network.protocol.common.custom.GameTestClearMarkersDebugPayload())); + } + + @Override @@ -21182,10 +21056,10 @@ index e4a14cdfeb91a3d32e622d27d612605b1bca08e2..898d934aafd6066df45f02fe3406fa83 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java -index f29e221e5b850516c169c03bfbd2b0885d1a841b..9e343d6e6393db17748fd13d76354464e128001f 100644 +index a67b5d20b956e0bf801c9eeb9330567c21927010..15c7dd5ae4ea040b91b665e5ce05c0d35ab1604e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java -@@ -216,4 +216,11 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { +@@ -252,4 +252,11 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { getHandle().getGossips().gossips.clear(); } // Paper end @@ -21241,10 +21115,10 @@ index e16459c9cfcac790edd6d912750d32c68387cbbc..890938ad866e2c588f3f819230ba121b + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 090b1ee57ddef58ca71469ad860960f66da7d5a2..5641df31686d6203a523b04406c2c85eab2240d2 100644 +index 50fed722bbba5c663e4be33a179ea75dfa2dd9e9..c3eaef001e6d7be7f16977c3f539d5d4a478c734 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -590,6 +590,15 @@ public class CraftEventFactory { +@@ -592,6 +592,15 @@ public class CraftEventFactory { // Paper end craftServer.getPluginManager().callEvent(event); @@ -21260,7 +21134,7 @@ index 090b1ee57ddef58ca71469ad860960f66da7d5a2..5641df31686d6203a523b04406c2c85e return event; } -@@ -1031,6 +1040,7 @@ public class CraftEventFactory { +@@ -1033,6 +1042,7 @@ public class CraftEventFactory { damageCause = DamageCause.ENTITY_EXPLOSION; } event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API @@ -21268,7 +21142,7 @@ index 090b1ee57ddef58ca71469ad860960f66da7d5a2..5641df31686d6203a523b04406c2c85e } event.setCancelled(cancelled); -@@ -1145,6 +1155,7 @@ public class CraftEventFactory { +@@ -1147,6 +1157,7 @@ public class CraftEventFactory { } else { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } @@ -21276,7 +21150,7 @@ index 090b1ee57ddef58ca71469ad860960f66da7d5a2..5641df31686d6203a523b04406c2c85e return event; } -@@ -1208,6 +1219,7 @@ public class CraftEventFactory { +@@ -1210,6 +1221,7 @@ public class CraftEventFactory { EntityDamageEvent event; if (damager != null) { event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions, critical); // Paper - add critical damage API @@ -21363,26 +21237,18 @@ index 88d3ca586ff6905f18a8ab9f0e229f440ed44088..27dd4eb4781a3c75772860c11db886e1 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java -index d94ab2607d1ab657a6b37924ce5ebcbbc3984011..f594596029513426f974ba820ed4702703b667a4 100644 +index 5a71efd27180004ee91495d9255867dbdfa1783e..1dcc3405393d11836a21aa16e435be64c04f6e7d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java -@@ -13,6 +13,7 @@ import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.ListTag; - import org.bukkit.Color; - import org.bukkit.Material; -+import org.bukkit.NamespacedKey; - import org.bukkit.configuration.serialization.DelegateDeserialization; - import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; - import org.bukkit.craftbukkit.potion.CraftPotionUtil; -@@ -42,6 +43,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { +@@ -43,6 +43,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { static final ItemMetaKey POTION_COLOR = new ItemMetaKey("CustomPotionColor", "custom-color"); - static final ItemMetaKey ID = new ItemMetaKey("Id", "potion-id"); + static final ItemMetaKey ID = new ItemMetaKey("id", "potion-id"); static final ItemMetaKey DEFAULT_POTION = new ItemMetaKey("Potion", "potion-type"); -+ static final ItemMetaKey KEY = new ItemMetaKey("Key", "namespacedkey"); // Purpur - add key ++ static final ItemMetaKey KEY = new ItemMetaKey("key", "namespacedkey"); // Purpur - add key // Having an initial "state" in ItemMeta seems bit dirty but the UNCRAFTABLE potion type // is treated as the empty form of the meta because it represents an empty potion with no effect -@@ -91,7 +93,13 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { +@@ -92,7 +93,13 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { boolean ambient = effect.getBoolean(AMBIENT.NBT); boolean particles = effect.contains(SHOW_PARTICLES.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_PARTICLES.NBT) : true; boolean icon = effect.contains(SHOW_ICON.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_ICON.NBT) : particles; @@ -21397,7 +21263,7 @@ index d94ab2607d1ab657a6b37924ce5ebcbbc3984011..f594596029513426f974ba820ed47027 } } } -@@ -138,6 +146,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { +@@ -139,6 +146,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { effectData.putBoolean(AMBIENT.NBT, effect.isAmbient()); effectData.putBoolean(SHOW_PARTICLES.NBT, effect.hasParticles()); effectData.putBoolean(SHOW_ICON.NBT, effect.hasIcon()); @@ -21409,7 +21275,7 @@ index d94ab2607d1ab657a6b37924ce5ebcbbc3984011..f594596029513426f974ba820ed47027 effectList.add(effectData); } } -@@ -199,7 +212,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { +@@ -200,7 +212,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { if (index != -1) { if (overwrite) { PotionEffect old = this.customEffects.get(index); @@ -21443,7 +21309,7 @@ index 2677e21d8239bf0361a3bc5c9a50c328e54d70f6..544a79d5da661aff19e2019f7b83a3a4 if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) { new Exception().printStackTrace(); diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java -index 9683d7d103af66fffd68c11abc38fb4fd2f99482..18a4de76021ff8b500801ef0121003f8dd62a961 100644 +index 2d2bf5c37709b8e747fbfa2db5ce86f258e86224..f6413ab181208d729afb532dca5e96e4c938e83c 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -46,4 +46,10 @@ public class CraftMapRenderer extends MapRenderer { @@ -21458,13 +21324,13 @@ index 9683d7d103af66fffd68c11abc38fb4fd2f99482..18a4de76021ff8b500801ef0121003f8 + // Purpur - end } diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java -index acb69821a99aa69bce6d127e10976089c85be223..c5abd73981c5f4b41605eba0d44e6573dfd2a77a 100644 +index 354393cbf0f113f14e936b40da56125a3130cbd9..a1ef7ecdf272546bdd76bb4b2ecd86a69c51c777 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java +++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java @@ -101,7 +101,7 @@ public class CraftPotionUtil { public static MobEffectInstance fromBukkit(PotionEffect effect) { - MobEffect type = MobEffect.byId(effect.getType().getId()); + MobEffect type = CraftPotionEffectType.bukkitToMinecraft(effect.getType()); - return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()); + return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.getKey()); // Purpur - add key } @@ -21544,7 +21410,7 @@ index 3f45bab0e9f7b3697e6d9d1092a1e6e579f7066f..4f1cf281c4bf68c37982d390da8779de long getCreatedAt() { diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java -index 500f2eb0df5a07637cd278c263e95592b0037eb6..895431584c476067790f1f131699d49eac3f4b8f 100644 +index 7a2f46579352870cfbb32c343d7c68919758ffe3..60b8331a4327cc276b88420254495455babbe3b0 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java @@ -115,7 +115,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { @@ -21566,10 +21432,10 @@ index 500f2eb0df5a07637cd278c263e95592b0037eb6..895431584c476067790f1f131699d49e // Paper end - add timings for scoreboard search } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 2b4581f92543c11f31bcc1417e90d7f90b2aea20..ffca5970a6259b024c9aa935e22cf72ed8cd8e9f 100644 +index 031e5acee0061d7f8050ea3a42f33b42112a3172..6eac7fcbc1c372675322c49f5557bf6be4dd1c31 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -470,7 +470,7 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -452,7 +452,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { @@ -21592,7 +21458,7 @@ index 80553face9c70c2a3d897681e7761df85b22d464..99597258e8e88cd9e2c901c4ac3ff7fa if (stream != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java -index 2959f713ce75a1df9c6c7cf5e021690cfcb6e1e7..3fa9539cfb2c35beeba6d44fa05cee971444b7d0 100644 +index 74ffea16027ba8eaa26716c3b6b78a8e83c9ed79..30567935db66eaa23614ad143cd8a45c596cae26 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java +++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java @@ -23,7 +23,15 @@ public final class CommandPermissions { @@ -22275,10 +22141,10 @@ index 0000000000000000000000000000000000000000..3633574e112f217b412217dd243a631d +} diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..078102e636803f38facc049952813ff2f8b63594 +index 0000000000000000000000000000000000000000..d4d9f748d259df8b6f4566efa21c15c470de5ba2 --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -0,0 +1,3239 @@ +@@ -0,0 +1,3235 @@ +package org.purpurmc.purpur; + +import net.minecraft.core.registries.BuiltInRegistries; @@ -22702,8 +22568,6 @@ index 0000000000000000000000000000000000000000..078102e636803f38facc049952813ff2 + public boolean idleTimeoutCountAsSleeping = false; + public boolean idleTimeoutUpdateTabList = false; + public boolean idleTimeoutTargetPlayer = true; -+ public int playerSpawnInvulnerableTicks = 60; -+ public boolean playerInvulnerableWhileAcceptingResourcePack = false; + public String playerDeathExpDropEquation = "expLevel * 7"; + public int playerDeathExpDropMax = 100; + public boolean teleportIfOutsideBorder = false; @@ -22734,8 +22598,6 @@ index 0000000000000000000000000000000000000000..078102e636803f38facc049952813ff2 + idleTimeoutCountAsSleeping = getBoolean("gameplay-mechanics.player.idle-timeout.count-as-sleeping", idleTimeoutCountAsSleeping); + idleTimeoutUpdateTabList = getBoolean("gameplay-mechanics.player.idle-timeout.update-tab-list", idleTimeoutUpdateTabList); + idleTimeoutTargetPlayer = getBoolean("gameplay-mechanics.player.idle-timeout.mobs-target", idleTimeoutTargetPlayer); -+ playerSpawnInvulnerableTicks = getInt("gameplay-mechanics.player.spawn-invulnerable-ticks", playerSpawnInvulnerableTicks); -+ playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack); + playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation); + playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax); + teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder); @@ -25635,7 +25497,7 @@ index 0000000000000000000000000000000000000000..235f3cd89f675b70a6152a00534608c0 +} diff --git a/src/main/java/org/purpurmc/purpur/command/PingCommand.java b/src/main/java/org/purpurmc/purpur/command/PingCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..179727c6b3171c040d1aaf069525f61a9a2d54d9 +index 0000000000000000000000000000000000000000..f202b98a194604e39798fdb8e417c6d2835f71c8 --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/command/PingCommand.java @@ -0,0 +1,33 @@ @@ -25666,7 +25528,7 @@ index 0000000000000000000000000000000000000000..179727c6b3171c040d1aaf069525f61a + + private static int execute(CommandSourceStack sender, Collection targets) { + for (ServerPlayer player : targets) { -+ String output = String.format(PurpurConfig.pingCommandOutput, player.getGameProfile().getName(), player.latency); ++ String output = String.format(PurpurConfig.pingCommandOutput, player.getGameProfile().getName(), player.connection.latency()); + sender.sendSuccess(output, false); + } + return targets.size(); @@ -27056,10 +26918,10 @@ index 0000000000000000000000000000000000000000..c038fb2bbb0f0e78380bc24bbd6348b8 +} diff --git a/src/main/java/org/purpurmc/purpur/task/BeehiveTask.java b/src/main/java/org/purpurmc/purpur/task/BeehiveTask.java new file mode 100644 -index 0000000000000000000000000000000000000000..2ebbaf5faa92a88bfb4d61298951e5b74157d1e1 +index 0000000000000000000000000000000000000000..8a5faed6c1ac6850b87405e774e4393877d61c92 --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/task/BeehiveTask.java -@@ -0,0 +1,81 @@ +@@ -0,0 +1,92 @@ +package org.purpurmc.purpur.task; + +import com.google.common.io.ByteArrayDataInput; @@ -27068,7 +26930,8 @@ index 0000000000000000000000000000000000000000..2ebbaf5faa92a88bfb4d61298951e5b7 +import io.netty.buffer.Unpooled; +import net.minecraft.core.BlockPos; +import net.minecraft.network.FriendlyByteBuf; -+import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; ++import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; ++import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.entity.BeehiveBlockEntity; @@ -27127,8 +26990,18 @@ index 0000000000000000000000000000000000000000..2ebbaf5faa92a88bfb4d61298951e5b7 + out.writeInt(beehive.getOccupantCount()); + out.writeLong(packedPos); + -+ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(out.toByteArray())); -+ serverPlayer.connection.send(new ClientboundCustomPayloadPacket(BEEHIVE_S2C, buf)); ++ FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(out.toByteArray())); ++ serverPlayer.connection.send(new ClientboundCustomPayloadPacket(new CustomPacketPayload() { ++ @Override ++ public void write(final FriendlyByteBuf buf) { ++ buf.writeBytes(byteBuf.copy()); ++ } ++ ++ @Override ++ public ResourceLocation id() { ++ return BEEHIVE_S2C; ++ } ++ })); + } + + @SuppressWarnings("UnstableApiUsage") @@ -27772,7 +27645,7 @@ index 0000000000000000000000000000000000000000..b7586f494528f30eb0da82420d3bcf5b + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 68557964e27fa1e5ba218178f9bcc0b28e3a78d9..43d9e7287cf0e498ccbff9b865bb813e7fb567c0 100644 +index acde675a8f1b84b686d53084d66dece3ad5f940e..062a793a134f774ebf918aab10443527c06c4fd1 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -15,6 +15,7 @@ import net.minecraft.world.entity.ambient.AmbientCreature; @@ -27800,7 +27673,7 @@ index 68557964e27fa1e5ba218178f9bcc0b28e3a78d9..43d9e7287cf0e498ccbff9b865bb813e // Paper start int worldHeight = world.getHeight(); ActivationRange.maxBB = player.getBoundingBox().inflate( maxRange, worldHeight, maxRange ); -@@ -243,7 +245,7 @@ public class ActivationRange +@@ -247,7 +249,7 @@ public class ActivationRange } // Paper end } @@ -27809,7 +27682,7 @@ index 68557964e27fa1e5ba218178f9bcc0b28e3a78d9..43d9e7287cf0e498ccbff9b865bb813e } /** -@@ -396,6 +398,7 @@ public class ActivationRange +@@ -400,6 +402,7 @@ public class ActivationRange */ public static boolean checkIfActive(Entity entity) { @@ -28416,10 +28289,10 @@ z&|M6FI|A*^d_U+Of-3`+w(c~-YsQby|NH)g|G7xv|Nek^|Jex)g~z+)I0xPC0460S LFIp>X81%mY^Bg|U diff --git a/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java b/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java -index b2d510459bcf90a3611f3d91dae4ccc3d29b4079..7a052f6deaa30f8a177a2aaf172f9da6c308a22b 100644 +index 654ed436e99dd56f1fe7c1d4f38da34d95ce9349..6453b1d4182a47367e89500ed4180ce75556b47d 100644 --- a/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java +++ b/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java -@@ -37,7 +37,7 @@ public class VanillaMobGoalTest { +@@ -36,7 +36,7 @@ public class VanillaMobGoalTest { } List> classes; @@ -28429,7 +28302,7 @@ index b2d510459bcf90a3611f3d91dae4ccc3d29b4079..7a052f6deaa30f8a177a2aaf172f9da6 } diff --git a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java -index 4f43882d930ab8816e75b216d9a61a06b79df265..40fc8b6579cc29e68720a99ac12f8adacc1d95be 100644 +index afeb4271fffb7546209f1e651214065187c88302..81bc3af856b8af019fd13e1da1f7cccd526b7cf0 100644 --- a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java +++ b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java @@ -45,6 +45,7 @@ public class MinecraftCommandPermissionsTest extends AbstractTestingBase { @@ -28467,7 +28340,7 @@ index 4f43882d930ab8816e75b216d9a61a06b79df265..40fc8b6579cc29e68720a99ac12f8ada ); diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java -index 83226ec2fa977819e12a499eb3765232543c17b3..a742774dabaee0629f4e6adabee5f3ec4b3be41c 100644 +index 70a655df7195da8e037c22064c4ebfe5d771e884..cfdf155af7ec29dd221989edbd8623d27529f9e6 100644 --- a/src/test/java/org/bukkit/potion/PotionTest.java +++ b/src/test/java/org/bukkit/potion/PotionTest.java @@ -9,6 +9,7 @@ import net.minecraft.resources.ResourceLocation; @@ -28475,11 +28348,11 @@ index 83226ec2fa977819e12a499eb3765232543c17b3..a742774dabaee0629f4e6adabee5f3ec import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.item.alchemy.Potion; +import org.bukkit.NamespacedKey; + import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.support.AbstractTestingBase; - import org.junit.Test; - -@@ -47,4 +48,27 @@ public class PotionTest extends AbstractTestingBase { - assertEquals("Same type not returned by name " + key, bukkit, byName); + import org.junit.jupiter.api.Test; +@@ -46,4 +47,27 @@ public class PotionTest extends AbstractTestingBase { + assertEquals(bukkit, byName, "Same type not returned by name " + key); } } + diff --git a/patches/server/0003-MC-Dev-fixes.patch b/patches/server/0003-MC-Dev-fixes.patch index d45880ad6..fffd4bfd5 100644 --- a/patches/server/0003-MC-Dev-fixes.patch +++ b/patches/server/0003-MC-Dev-fixes.patch @@ -4,8 +4,28 @@ Date: Tue, 30 May 2023 12:12:29 +0900 Subject: [PATCH] MC Dev fixes +diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java +index b0b2cbd8d9db1772d43a285eca9060f3879acab0..8cde30544e14f8fc2dac32966ae3c21f8cf3a551 100644 +--- a/src/main/java/com/destroystokyo/paper/Metrics.java ++++ b/src/main/java/com/destroystokyo/paper/Metrics.java +@@ -604,15 +604,6 @@ public class Metrics { + metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size())); + metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur + metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur +- final String paperVersion; +- final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion(); +- if (implVersion != null) { +- final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1); +- paperVersion = "git-Pufferfish-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Pufferfish +- } else { +- paperVersion = "unknown"; +- } +- metrics.addCustomChart(new Metrics.SimplePie("pufferfish_version", () -> paperVersion)); // Pufferfish + + metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { + Map> map = new HashMap<>(); diff --git a/src/main/java/net/minecraft/util/datafix/fixes/LeavesFix.java b/src/main/java/net/minecraft/util/datafix/fixes/LeavesFix.java -index 11ae164cce84081843518953bbeaf29904334fa9..131a0bb93c0711cc657c5571f3d8313b4bf154a8 100644 +index 733134401fcba393053c7a2dfa1d0d44f8f79ff5..17d931ef47846b59e28dc0c5b5ae91396a1d3e7d 100644 --- a/src/main/java/net/minecraft/util/datafix/fixes/LeavesFix.java +++ b/src/main/java/net/minecraft/util/datafix/fixes/LeavesFix.java @@ -71,14 +71,14 @@ public class LeavesFix extends DataFix { @@ -15,15 +35,15 @@ index 11ae164cce84081843518953bbeaf29904334fa9..131a0bb93c0711cc657c5571f3d8313b - Typed typed2 = typedx.updateTyped(opticFinder2, (typed) -> { - Int2ObjectMap int2ObjectMap = new Int2ObjectOpenHashMap<>(typed.getAllTyped(opticFinder3).stream().map((typedx) -> { - return new LeavesFix.LeavesSection(typedx, this.getInputSchema()); -+ Typed typed2 = typedx.updateTyped(opticFinder2, (typed2x) -> { -+ Int2ObjectMap int2ObjectMap = new Int2ObjectOpenHashMap<>(typed2x.getAllTyped(opticFinder3).stream().map((typedx2) -> { -+ return new LeavesFix.LeavesSection(typedx2, this.getInputSchema()); ++ Typed typed2 = typedx.updateTyped(opticFinder2, (typed2x) -> { // Plazma - decompile fix ++ Int2ObjectMap int2ObjectMap = new Int2ObjectOpenHashMap<>(typed2x.getAllTyped(opticFinder3).stream().map((typedx2) -> { // Plazma - decompile fix ++ return new LeavesFix.LeavesSection(typedx2, this.getInputSchema()); // Plazma - decompile fix }).collect(Collectors.toMap(LeavesFix.Section::getIndex, (leavesSection) -> { return leavesSection; }))); if (int2ObjectMap.values().stream().allMatch(LeavesFix.Section::isSkippable)) { - return typed; -+ return typed2x; ++ return typed2x; // Plazma - decompile fix } else { List list = Lists.newArrayList(); @@ -33,8 +53,8 @@ index 11ae164cce84081843518953bbeaf29904334fa9..131a0bb93c0711cc657c5571f3d8313b - return typed.updateTyped(opticFinder3, (typedx) -> { - return int2ObjectMap.get(typedx.get(DSL.remainderFinder()).get("Y").asInt(0)).write(typedx); -+ return typed.updateTyped(opticFinder3, (typedx2) -> { -+ return int2ObjectMap.get(typedx2.get(DSL.remainderFinder()).get("Y").asInt(0)).write(typedx2); ++ return typed.updateTyped(opticFinder3, (typedx2) -> { // Plazma - decompile fix ++ return int2ObjectMap.get(typedx2.get(DSL.remainderFinder()).get("Y").asInt(0)).write(typedx2); // Plazma - decompile fix }); } }); @@ -44,8 +64,8 @@ index 11ae164cce84081843518953bbeaf29904334fa9..131a0bb93c0711cc657c5571f3d8313b Optional>>> optional = typed.getOptional(this.paletteFinder); - this.palette = optional.map((list) -> { - return list.stream().map(Pair::getSecond).collect(Collectors.toList()); -+ this.palette = (java.util.List)optional.map((list) -> { -+ return (java.util.List)list.stream().map(Pair::getSecond).collect(Collectors.toList()); ++ this.palette = (List) optional.map((list) -> { // Plazma - decompile fix ++ return (List) list.stream().map(Pair::getSecond).collect(Collectors.toList()); // Plazma - decompile fix }).orElse(ImmutableList.of()); Dynamic dynamic = typed.get(DSL.remainderFinder()); this.index = dynamic.get("Y").asInt(0); @@ -54,22 +74,7 @@ index 11ae164cce84081843518953bbeaf29904334fa9..131a0bb93c0711cc657c5571f3d8313b return this.isSkippable() ? typed : typed.update(DSL.remainderFinder(), (dynamic) -> { return dynamic.set("BlockStates", dynamic.createLongList(Arrays.stream(this.storage.getRaw()))); - }).set(this.paletteFinder, this.palette.stream().map((dynamic) -> { -+ }).set(this.paletteFinder, (java.util.List)this.palette.stream().map((dynamic) -> { ++ }).set(this.paletteFinder, (List) this.palette.stream().map((dynamic) -> { // Plazma - decompile fix return Pair.of(References.BLOCK_STATE.typeName(), dynamic); }).collect(Collectors.toList())); } -diff --git a/src/main/java/net/minecraft/world/level/storage/loot/entries/EntryGroup.java b/src/main/java/net/minecraft/world/level/storage/loot/entries/EntryGroup.java -index 6e971a9891e43b971d439c3ca11eff8965f3dae9..da1b5c6b68f14969b85472826d3d36ca673a0e5a 100644 ---- a/src/main/java/net/minecraft/world/level/storage/loot/entries/EntryGroup.java -+++ b/src/main/java/net/minecraft/world/level/storage/loot/entries/EntryGroup.java -@@ -31,8 +31,8 @@ public class EntryGroup extends CompositeEntryBase { - }; - default: - return (context, lootChoiceExpander) -> { -- for(ComposableEntryContainer composableEntryContainer : children) { -- composableEntryContainer.expand(context, lootChoiceExpander); -+ for(ComposableEntryContainer composableEntryContainer3 : children) { // Plazma - decompile fix -+ composableEntryContainer3.expand(context, lootChoiceExpander); - } - - return true; diff --git a/patches/server/0004-Rebrand.patch b/patches/server/0004-Rebrand.patch index 6cb6bc9a4..081fd2724 100644 --- a/patches/server/0004-Rebrand.patch +++ b/patches/server/0004-Rebrand.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Rebrand diff --git a/build.gradle.kts b/build.gradle.kts -index 3d5397e2e7edf2ea1e1687c58126fd9a5d5d5736..8a12e0dda9d03f265603b80c9fa108eea736ae84 100644 +index 393dab1ece76e0ca1e0b58c0b2c72d5c1c41a84d..cfb74b11743ce2f7a78a6a8085f9dd05b65a3152 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating @@ -17,7 +17,7 @@ index 3d5397e2e7edf2ea1e1687c58126fd9a5d5d5736..8a12e0dda9d03f265603b80c9fa108ee implementation("io.papermc.paper:paper-mojangapi:${project.version}") { exclude("io.papermc.paper", "paper-api") } -@@ -95,7 +95,7 @@ tasks.jar { +@@ -87,7 +87,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -131,7 +131,7 @@ index 3cb56595822799926a8141e60a42f5d1edfc6de5..19d1d136fc28d6c114f6bc44c6450d2d .completer(new ConsoleCommandCompleter(this.server)) .option(LineReader.Option.COMPLETE_IN_WORD, true); diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java -index b5b6657e52e4f7a630229bd3ba433438af293e22..c468733f44ccb3ff4ba3c20921a4ec52658f0689 100644 +index ed3527612315e6e0649182ce4e1ae2834b0918a9..ae02c029f0169d30a34d4a4e65ea6cb4fa498111 100644 --- a/src/main/java/net/minecraft/CrashReport.java +++ b/src/main/java/net/minecraft/CrashReport.java @@ -35,7 +35,7 @@ public class CrashReport { @@ -153,10 +153,10 @@ index b5b6657e52e4f7a630229bd3ba433438af293e22..c468733f44ccb3ff4ba3c20921a4ec52 stringbuilder.append("// "); stringbuilder.append(CrashReport.getErrorComment()); diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index a7ebf851a65231074c89a24f30de4ac2fb5b63e4..ed7bcd832340a7a46897f0275c99e72b7247a5de 100644 +index 27a238cc56702297c88fde0f379178222ccf6c5b..30fc258faa6f087cf3c91411b48116a3ac416031 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java -@@ -111,6 +111,18 @@ public class Main { +@@ -108,6 +108,18 @@ public class Main { */ // CraftBukkit end try { @@ -176,10 +176,10 @@ index a7ebf851a65231074c89a24f30de4ac2fb5b63e4..ed7bcd832340a7a46897f0275c99e72b if (Boolean.getBoolean("Paper.isRunDev")) { net.minecraft.server.packs.VanillaPackResourcesBuilder.developmentConfig = builder -> { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index e6ddf69ade7ae51640569150f7db10d1afa63691..77b40f3d7162befe4da29a60b3de2b93b261412c 100644 +index 8c3942d9ce4f8a102a47bec74af5911760fda4e3..cf9f7d52b07cffd41293ba5a6fab3a7f77a2cf03 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -925,7 +925,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.function.Function plazmaLevelConfigurationCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.function.Function plazmaLevelConfigurationCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor // Plazma this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper + this.plazmaLevelConfiguration = plazmaLevelConfigurationCreator.apply(this.spigotConfig); // Plazma @@ -293,10 +289,10 @@ index c80d73035b05bfb6b3639175c51bb37c477c28d1..6d513c903e06fe79dffdffd02871d00c this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur this.generator = gen; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 875cc2357d17d37d8df921a84cf8af7b99d860f2..c43023fecf0882101248f625a28975586da05071 100644 +index 005c854a10f343cd7488b282de002249bf5c4ced..3e8f42811e9254567f2522e68b6018704bd63ae2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1051,6 +1051,7 @@ public final class CraftServer implements Server { +@@ -1053,6 +1053,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); @@ -304,7 +300,7 @@ index 875cc2357d17d37d8df921a84cf8af7b99d860f2..c43023fecf0882101248f625a2897558 org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty -@@ -2984,6 +2985,13 @@ public final class CraftServer implements Server { +@@ -2986,6 +2987,13 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -319,7 +315,7 @@ index 875cc2357d17d37d8df921a84cf8af7b99d860f2..c43023fecf0882101248f625a2897558 @Override public YamlConfiguration getPurpurConfig() { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 4bc0a370c7aec06d30b4ebf7fa7d73263d0543bc..206cec149875137836437bd237c2ff52baad4f0e 100644 +index e006351f07356fb42e5858bb3b8a74ffee215b35..8ecf47b458ace51df2bb9f76e1015bcefe882d7c 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -173,6 +173,14 @@ public class Main { @@ -582,7 +578,7 @@ index 0000000000000000000000000000000000000000..85002144e0b350c4ae044e1a4a4c1734 +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..6714947455c1e4c887a5f13ba1a3aeb57324ee0a +index 0000000000000000000000000000000000000000..31c98e2c869722ea7e396c245be2d0e8c6bb8feb --- /dev/null +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java @@ -0,0 +1,23 @@ @@ -592,10 +588,10 @@ index 0000000000000000000000000000000000000000..6714947455c1e4c887a5f13ba1a3aeb5 +import io.papermc.paper.configuration.ConfigurationPart; +import org.spongepowered.configurate.objectmapping.meta.Setting; + -+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) ++@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "InnerClassMayBeStatic"}) +public class GlobalConfiguration extends ConfigurationPart { + static final int CURRENT_VERSION = 1; -+ static final boolean DO_OPTIMIZE = !Boolean.getBoolean("Plazma.disableConfigOptimization"); ++ static final boolean DO_OPTIMIZE = PlazmaConfigurations.doOptimize(); + private static GlobalConfiguration instance; + + public static GlobalConfiguration get() { @@ -611,7 +607,7 @@ index 0000000000000000000000000000000000000000..6714947455c1e4c887a5f13ba1a3aeb5 +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..857ddc62dd9affbbebcd7cde8a6d675dbb5f68ae +index 0000000000000000000000000000000000000000..629322f0054dff8578ab6980d96db144c04a95f0 --- /dev/null +++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java @@ -0,0 +1,25 @@ @@ -623,10 +619,10 @@ index 0000000000000000000000000000000000000000..857ddc62dd9affbbebcd7cde8a6d675d +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.configurate.objectmapping.meta.Setting; + -+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) ++@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "InnerClassMayBeStatic"}) +public class LevelConfigurations extends ConfigurationPart { + public static final int CURRENT_VERSION = 1; -+ private static final boolean DO_OPTIMIZE = !Boolean.getBoolean("Plazma.disableConfigOptimization"); ++ private static final boolean DO_OPTIMIZE = PlazmaConfigurations.doOptimize(); + + private transient final ResourceLocation worldKey; + public LevelConfigurations(ResourceLocation worldKey) { @@ -642,10 +638,10 @@ index 0000000000000000000000000000000000000000..857ddc62dd9affbbebcd7cde8a6d675d +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca5751bc0b35 +index 0000000000000000000000000000000000000000..39db772735d57e12bbb26a6505ca7a5e360cdd78 --- /dev/null +++ b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java -@@ -0,0 +1,304 @@ +@@ -0,0 +1,309 @@ +package org.plazmamc.plazma.configurations; + +import com.google.common.collect.Table; @@ -675,6 +671,8 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; ++import org.jetbrains.annotations.Contract; ++import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.VisibleForTesting; +import org.slf4j.Logger; +import org.spongepowered.configurate.*; @@ -701,6 +699,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + static final String GLOBAL_CONFIGURATION_FILE_NAME= "plazma-global.yml"; + static final String LEVEL_DEFAULT_CONFIGURATION_FILE_NAME = "plazma-level-defaults.yml"; + static final String LEVEL_CONFIGURATION_FILE_NAME = "plazma-configuration.yml"; ++ static final boolean OPTIMIZE_CONFIG = !Boolean.getBoolean("Plazma.disableConfigOptimization"); + + private static final String HEADER_START = """ + # English @@ -725,8 +724,6 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + + Wiki: https://github.com/PlazmaMC/Plazma/wiki + Discord: https://discord.gg/MmfC52K8A8 -+ Twitter: *COMMING SOON* -+ Naver Cafe: *COMMING SOON* + """; + + private static final Function LEVEL_SPECIFIC_HEADER = map -> String.format(""" @@ -750,8 +747,6 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + + Wiki: https://github.com/PlazmaMC/Plazma/wiki + Discord: https://discord.gg/MmfC52K8A8 -+ Twitter: *COMMING SOON* -+ Naver Cafe: *COMMING SOON* + """, PaperConfigurations.CONFIG_DIR, LEVEL_DEFAULT_CONFIGURATION_FILE_NAME, PaperConfigurations.CONFIG_DIR, LEVEL_DEFAULT_CONFIGURATION_FILE_NAME, + map.require(WORLD_NAME), map.require(WORLD_KEY)); + @@ -782,7 +777,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + // Create Loader Builder -+ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) { ++ private static ConfigurationOptions defaultOptions(@NotNull ConfigurationOptions options) { + return options.serializers(builder -> builder + .register(MapSerializer.TYPE, new MapSerializer(false)) + .register(new EnumValueSerializer()) @@ -796,7 +791,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + // Create Global Object Mapper Factory Builder -+ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) { ++ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.@NotNull Builder builder) { + return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig()); + } + @@ -806,7 +801,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + // Create Global Loader Builder -+ private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) { ++ private static ConfigurationOptions defaultGlobalOptions(@NotNull ConfigurationOptions options) { + return options.header(GLOBAL_HEADER).serializers(builder -> builder.register(new PacketClassSerializer())); + } + @@ -859,7 +854,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + ); + } + -+ private void applyTransformations(final NodePath[] paths, final ConfigurationNode node) throws ConfigurateException { ++ private void applyTransformations(final NodePath @NotNull [] paths, final ConfigurationNode node) throws ConfigurateException { + if (paths.length > 0) { + ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + @@ -876,7 +871,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + @Override -+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException { ++ protected void applyWorldConfigTransformations(final @NotNull ContextMap contextMap, final @NotNull ConfigurationNode node) throws ConfigurateException { + final ConfigurationNode version = node.node(Configuration.VERSION_FIELD); + final String world = contextMap.require(WORLD_NAME); + @@ -903,7 +898,7 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + @Override -+ public LevelConfigurations createWorldConfig(final ContextMap contextMap) { ++ public LevelConfigurations createWorldConfig(final @NotNull ContextMap contextMap) { + final String levelName = contextMap.require(WORLD_NAME); + try { + return super.createWorldConfig(contextMap); @@ -923,14 +918,15 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + } + + @VisibleForTesting -+ static ConfigurationNode createForTesting() { ++ static @NotNull ConfigurationNode createForTesting() { + ObjectMapper.Factory factory = defaultGlobalFactoryBuilder(ObjectMapper.factoryBuilder()).build(); + ConfigurationOptions options = defaultGlobalOptions(defaultOptions(ConfigurationOptions.defaults())) + .serializers(builder -> builder.register(type -> ConfigurationPart.class.isAssignableFrom(erase(type)), factory.asTypeSerializer())); + return BasicConfigurationNode.root(options); + } + -+ public static PlazmaConfigurations setup(final Path configurationDir) throws Exception { ++ @Contract("_ -> new") ++ public static @NotNull PlazmaConfigurations setup(final Path configurationDir) throws Exception { + try { + PaperConfigurations.createDirectoriesSymlinkAware(configurationDir); + return new PlazmaConfigurations(configurationDir); @@ -949,6 +945,11 @@ index 0000000000000000000000000000000000000000..481392f3ed3b746172dbf319a583ca57 + throw new RuntimeException("Could not reload Plazma configuration files", e); + } + } ++ ++ public static boolean optimizeConfig() { ++ return OPTIMIZE_CONFIG; ++ } ++ +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java new file mode 100644 @@ -968,7 +969,7 @@ index 0000000000000000000000000000000000000000..469100cd86e6742eeebad22923097782 + +} diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java -index 52a6f1791c7de062d5d567d7cc9ee68731fd6e67..36ad8262b20cdd5ce4e94866c5d22cbdb5d5b385 100644 +index 8174b6bb78553cbe124b499ffa235368179d1564..a5f8a128b27906daba5aeb293851bb03402ca9c2 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -64,6 +64,7 @@ public abstract class AbstractTestingBase { diff --git a/patches/server/0007-Add-more-metrics.patch b/patches/server/0007-Add-more-metrics.patch index dca32d701..8a62d790b 100644 --- a/patches/server/0007-Add-more-metrics.patch +++ b/patches/server/0007-Add-more-metrics.patch @@ -1,65 +1,54 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Fri, 24 Mar 2023 23:54:51 +0900 +Date: Wed, 27 Sep 2023 16:02:29 +0900 Subject: [PATCH] Add more metrics diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 7d80d2cf5d607d6051e99e4b08bc1b76098a79da..067bcbcb81802a3a52ecff737ddf2c033696ecfb 100644 +index 7d80d2cf5d607d6051e99e4b08bc1b76098a79da..fa88d48adc3aefcd823f431f099e46c94fd071a1 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -636,12 +636,63 @@ public class Metrics { +@@ -636,16 +636,51 @@ public class Metrics { return map; })); -+ // Plazma start -+ metrics.addCustomChart(new Metrics.DrilldownPie("datapacks", () -> { -+ Map> map = new HashMap<>(); -+ int datapacks = Bukkit.getServer().getDatapackManager().getEnabledPacks().size(); -+ Map entry = new HashMap<>(); -+ entry.put(String.valueOf(datapacks), 1); ++ // Plazma start - Add more metrics ++ metrics.addCustomChart(new DrilldownPie("datapacks", () -> { ++ int datapacks = Bukkit.getDatapackManager().getEnabledPacks().size(); ++ Map entry = Collections.singletonMap(String.valueOf(datapacks), 1); + -+ if (datapacks == 0) -+ map.put("0", entry); -+ else if (datapacks <= 5) -+ map.put("1-5", entry); -+ else if (datapacks <= 10) -+ map.put("6-10", entry); -+ else if (datapacks <= 25) -+ map.put("11-25", entry); -+ else -+ map.put("26+", entry); -+ -+ return map; ++ if (datapacks == 0) return Collections.singletonMap("0", entry); ++ else if (datapacks <= 5) return Collections.singletonMap("1-5", entry); ++ else if (datapacks <= 10) return Collections.singletonMap("6-10", entry); ++ else if (datapacks <= 25) return Collections.singletonMap("11-25", entry); ++ else if (datapacks <= 50) return Collections.singletonMap("26-50", entry); ++ return Collections.singletonMap("50+", entry); + })); -+ -+ List plugins = new ArrayList<>(); -+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { -+ if (plugin.isEnabled()) { -+ plugins.add(plugin); -+ } -+ } + -+ metrics.addCustomChart(new Metrics.DrilldownPie("plugins", () -> { -+ Map> map = new HashMap<>(); -+ int plugins1 = plugins.size(); -+ Map entry = new HashMap<>(); -+ entry.put(String.valueOf(plugins1), 1); ++ List plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).toList(); + -+ if (plugins1 == 0) -+ map.put("0", entry); -+ else if (plugins1 <= 5) -+ map.put("1-5", entry); -+ else if (plugins1 <= 10) -+ map.put("6-10", entry); -+ else if (plugins1 <= 25) -+ map.put("11-25", entry); -+ else if (plugins1 <= 50) -+ map.put("26-50", entry); -+ else -+ map.put("51+", entry); ++ metrics.addCustomChart(new DrilldownPie("plugins", () -> { ++ int pluginCount = (int) plugins.stream().filter(Plugin::isEnabled).count(); ++ Map entry = Collections.singletonMap(String.valueOf(pluginCount), 1); + -+ return map; ++ if (pluginCount == 0) return Collections.singletonMap("0", entry); ++ else if (pluginCount <= 5) return Collections.singletonMap("1-5", entry); ++ else if (pluginCount <= 10) return Collections.singletonMap("6-10", entry); ++ else if (pluginCount <= 25) return Collections.singletonMap("11-25", entry); ++ else if (pluginCount <= 50) return Collections.singletonMap("26-50", entry); ++ return Collections.singletonMap("50+", entry); ++ })); ++ ++ metrics.addCustomChart(new DrilldownPie("disabled_plugins", () -> { ++ int disabled = (int) plugins.stream().filter(java.util.function.Predicate.not(Plugin::isEnabled)).count(); ++ Map entry = Collections.singletonMap(String.valueOf(disabled), 1); ++ ++ if (disabled == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); ++ else if (disabled <= 5) return Collections.singletonMap("1-5", entry); ++ else if (disabled <= 10) return Collections.singletonMap("6-10", entry); ++ else if (disabled <= 25) return Collections.singletonMap("11-25", entry); ++ else if (disabled <= 50) return Collections.singletonMap("26-50", entry); ++ return Collections.singletonMap("50+ \uD83D\uDE2D", entry); + })); + // Plazma end + @@ -67,9 +56,13 @@ index 7d80d2cf5d607d6051e99e4b08bc1b76098a79da..067bcbcb81802a3a52ecff737ddf2c03 Map> map = new HashMap<>(); // count legacy plugins - int legacy = 0; +- int legacy = 0; - for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { -+ for (Plugin plugin : plugins) { // Plazma - if (CraftMagicNumbers.isLegacy(plugin.getDescription())) { - legacy++; - } +- if (CraftMagicNumbers.isLegacy(plugin.getDescription())) { +- legacy++; +- } +- } ++ int legacy = (int) plugins.stream().filter(p -> CraftMagicNumbers.isLegacy(p.getDescription())).count(); // Plazma + + // insert real value as lower dimension + Map entry = new HashMap<>(); diff --git a/patches/server/0008-Optimize-Default-Configurations.patch b/patches/server/0008-Optimize-default-configurations.patch similarity index 58% rename from patches/server/0008-Optimize-Default-Configurations.patch rename to patches/server/0008-Optimize-default-configurations.patch index 60691e274..bf2d7a08b 100644 --- a/patches/server/0008-Optimize-Default-Configurations.patch +++ b/patches/server/0008-Optimize-default-configurations.patch @@ -1,70 +1,73 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: IPECTER -Date: Tue, 7 Mar 2023 12:28:34 +0900 -Subject: [PATCH] Optimize Default Configurations +From: AlphaKR93 +Date: Wed, 27 Sep 2023 16:42:17 +0900 +Subject: [PATCH] Optimize default configurations -Original: YouHaveTrouble/minecraft-optimization, AkiraDevelopment/SimplyMC -Copyright (C) 2023 YouHaveTrouble, AkiraDevelopment +Reference: YouHaveTrouble/minecraft-optimization, AkiraDevelopment/SimplyMC diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -index 3e36958365bc136516bafbaad0c168f7956406f1..b5eca4a809d5e7c77de9737941f3f6c35e4fc796 100644 +index 5f223856b06e901b100fcca8e6dd968e0b2e3a8e..13df89e7cc219cdb80c4114d05148c685ad2ecee 100644 --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -@@ -211,8 +211,8 @@ public class PufferfishConfig { +@@ -72,7 +72,7 @@ public class PufferfishConfig { + getString("info.version", "1.0"); + setComment("info", + "Pufferfish Configuration", +- "Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host", ++ //"Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host", // Plazma - no advertisement + "Join our Discord for support: https://discord.gg/reZw4vQV9H", + "Download new builds at https://ci.pufferfish.host/job/Pufferfish"); + +@@ -219,7 +219,7 @@ public class PufferfishConfig { public static int maxProjectileLoadsPerTick; public static int maxProjectileLoadsPerProjectile; private static void projectileLoading() { - maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); -- maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed."); -+ maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10 : 8, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma -+ maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed."); ++ maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 8 : 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma - Optimize default configurations + maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed."); setComment("projectile", "Optimizes projectile settings"); - } -@@ -225,16 +225,16 @@ public class PufferfishConfig { +@@ -233,7 +233,7 @@ public class PufferfishConfig { public static int activationDistanceMod; private static void dynamicActivationOfBrains() throws IOException { - dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", false); // Purpur -- startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12, -+ dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", !Boolean.getBoolean("Plazma.disableConfigOptimization")); // Purpur // Plazma -+ startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12, ++ dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()); // Purpur // Plazma - Optimize default configurations + startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12, "This value determines how far away an entity has to be", "from the player to start being effected by DEAR."); - startDistanceSquared = startDistance * startDistance; +@@ -241,7 +241,7 @@ public class PufferfishConfig { maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", 20, "This value defines how often in ticks, the furthest entity", "will get their pathfinders and behaviors ticked. 20 = 1s"); - activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", 8, -- "This value defines how much distance modifies an entity's", -+ activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 8 : 7, // Plazma -+ "This value defines how much distance modifies an entity's", ++ activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 7 : 8, // Plazma - Optimize default configurations + "This value defines how much distance modifies an entity's", "tick frequency. freq = (distanceToPlayer^2) / (2^value)", "If you want further away entities to tick less often, use 7.", - "If you want further away entities to tick more often, try 9."); diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 3bc7230ca62ebe3426da293e436a962bb0134f85..1a4b5dc4c5340de66553936bbbc074d1654a3ef8 100644 +index c69892a5f31895b85e530beadd8864ac32470ba7..5f652268dadaca96a98203ad12d7a0ba0b19563b 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -143,7 +143,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -154,7 +154,7 @@ public class GlobalConfiguration extends ConfigurationPart { public class Watchdog extends ConfigurationPart { public int earlyWarningEvery = 5000; - public int earlyWarningDelay = 10000; -+ public int earlyWarningDelay = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10000 : 180000; // Plazma - Optimize Default Configurations ++ public int earlyWarningDelay = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 180000 : 10000; // Plazma - Optimize default configurations } public SpamLimiter spamLimiter; diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede28867892a301 100644 +index ec5e23136423e42e4f55e6ea646b8285c1ca14e2..a1d22ad65fc751fa93384f59853434ab65836133 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -@@ -88,15 +88,15 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -88,15 +88,27 @@ public class WorldConfiguration extends ConfigurationPart { public class AntiXray extends ConfigurationPart { public boolean enabled = false; - public EngineMode engineMode = EngineMode.HIDE; -+ public EngineMode engineMode = Boolean.getBoolean("Plazma.disableConfigOptimization") ? EngineMode.HIDE : EngineMode.OBFUSCATE_LAYER; // Plazma - Optimize Default Configurations ++ public EngineMode engineMode = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? EngineMode.OBFUSCATE_LAYER : EngineMode.HIDE; // Plazma - Optimize default configurations public int maxBlockHeight = 64; public int updateRadius = 2; public boolean lavaObscures = false; @@ -73,52 +76,73 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886 - "coal_ore", "deepslate_coal_ore", "lapis_ore", "deepslate_lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", "deepslate_diamond_ore", - "redstone_ore", "deepslate_redstone_ore", "clay", "emerald_ore", "deepslate_emerald_ore", "ender_chest"); // TODO update type to List - public List replacementBlocks = List.of("stone", "oak_planks", "deepslate"); // TODO update type to List -+ // Plazma start - Optimize Default Configurations -+ public List hiddenBlocks = List.of("air", "copper_ore", "deepslate_copper_ore", "raw_copper_block", "diamond_ore", "deepslate_diamond_ore", "gold_ore", "deepslate_gold_ore", "iron_ore", "deepslate_iron_ore", "raw_iron_block", "lapis_ore", "deepslate_lapis_ore", "redstone_ore", "deepslate_redstone_ore"); // TODO update type to List -+ public List replacementBlocks = List.of("chest", "amethyst_block", "andesite", "budding_amethyst", "calcite", "coal_ore", "deepslate_coal_ore", "deepslate", "diorite", "dirt", "emerald_ore", "deepslate_emerald_ore", "granite", "gravel", "oak_planks", "smooth_basalt", "stone", "tuff"); // TODO update type to List ++ // Plazma start - Optimize default configurations ++ public List hiddenBlocks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? ++ List.of("air", "copper_ore", "deepslate_copper_ore", "raw_copper_block", "iron_ore", ++ "deepslate_iron_ore", "raw_iron_block", "gold_ore", "deepslate_gold_ore", "raw_gold_block", ++ "lapis_ore", "deepslate_lapis_ore", "redstone_ore", "deepslate_redstone_ore", "diamond_ore", ++ "deepslate_diamond_ore") : ++ List.of("copper_ore", "deepslate_copper_ore","gold_ore", "deepslate_gold_ore", ++ "iron_ore", "deepslate_iron_ore", "coal_ore", "deepslate_coal_ore", "lapis_ore", ++ "deepslate_lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", ++ "deepslate_diamond_ore", "redstone_ore", "deepslate_redstone_ore", "clay", "emerald_ore", ++ "deepslate_emerald_ore", "ender_chest");; // TODO update type to List ++ public List replacementBlocks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? ++ List.of("chest", "amethyst_block", "andesite", "budding_amethyst", "calcite", "coal_ore", ++ "deepslate_coal_ore", "deepslate", "diorite", "dirt", "emerald_ore", "granite", "gravel", ++ "oak_planks", "smooth_basalt", "stone", "tuff") : List.of("stone", "oak_planks", "deepslate"); // TODO update type to List + // Plazma end } } -@@ -150,7 +150,7 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -150,7 +162,7 @@ public class WorldConfiguration extends ConfigurationPart { @MergeMap public Reference2IntMap spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1))); @MergeMap - public Map despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), category.getDespawnDistance()))); -+ public Map despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), Boolean.getBoolean("Plazma.disableConfigOptimization") ? category.getDespawnDistance() : (net.minecraft.server.MinecraftServer.getServer().server.getSimulationDistance() * 16) + 8))); // Plazma - Optimize Default Configurations ++ public Map despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? (net.minecraft.server.MinecraftServer.getServer().server.getSimulationDistance() * 16) + 8 : category.getDespawnDistance()))); // Plazma - Optimize default configurations @ConfigSerializable public record DespawnRange(@Required int soft, @Required int hard) { -@@ -372,7 +372,7 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -375,7 +387,7 @@ public class WorldConfiguration extends ConfigurationPart { public class Environment extends ConfigurationPart { public boolean disableThunder = false; public boolean disableIceAndSnow = false; - public boolean optimizeExplosions = false; -+ public boolean optimizeExplosions = !Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations ++ public boolean optimizeExplosions = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public boolean disableExplosionKnockback = false; public boolean generateFlatBedrock = false; public FrostedIce frostedIce; -@@ -452,9 +452,9 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -427,7 +439,7 @@ public class WorldConfiguration extends ConfigurationPart { + public Fixes fixes; + + public class Fixes extends ConfigurationPart { +- public boolean fixItemsMergingThroughWalls = false; ++ public boolean fixItemsMergingThroughWalls = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations + public boolean disableUnloadedChunkEnderpearlExploit = true; + public boolean preventTntFromMovingInWater = false; + public boolean splitOverstackedLoot = true; +@@ -455,9 +467,9 @@ public class WorldConfiguration extends ConfigurationPart { public class Collisions extends ConfigurationPart { public boolean onlyPlayersCollide = false; public boolean allowVehicleCollisions = true; - public boolean fixClimbingBypassingCrammingRule = false; -+ public boolean fixClimbingBypassingCrammingRule = !Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations ++ public boolean fixClimbingBypassingCrammingRule = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations @RequiresSpigotInitialization(MaxEntityCollisionsInitializer.class) - public int maxEntityCollisions = 8; -+ public int maxEntityCollisions = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 8 : 2; // Plazma - Optimize Default Configurations ++ public int maxEntityCollisions = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 2 : 8; // Plazma - Optimize default configurations public boolean allowPlayerCrammingDamage = false; } -@@ -462,18 +462,40 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -465,18 +477,40 @@ public class WorldConfiguration extends ConfigurationPart { public class Chunks extends ConfigurationPart { public AutosavePeriod autoSaveInterval = AutosavePeriod.def(); - public int maxAutoSaveChunksPerTick = 24; -+ public int maxAutoSaveChunksPerTick = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 24 : 8; // Plazma - Optimize Default Configurations ++ public int maxAutoSaveChunksPerTick = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 8 : 24; // Plazma - Optimize default configurations public int fixedChunkInhabitedTime = -1; - public boolean preventMovingIntoUnloadedChunks = false; -+ public boolean preventMovingIntoUnloadedChunks = !Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations ++ public boolean preventMovingIntoUnloadedChunks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public Duration delayChunkUnloadsBy = Duration.of("10s"); public Reference2IntMap> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> { - map.defaultReturnValue(-1); @@ -128,8 +152,8 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886 - map.put(EntityType.ARROW, -1); - map.put(EntityType.FIREBALL, -1); - map.put(EntityType.SMALL_FIREBALL, -1); -+ // Plazma start - Optimize Default Configurations -+ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) { ++ // Plazma start - Optimize default configurations ++ if (org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()) { + map.put(EntityType.AREA_EFFECT_CLOUD, 8); + map.put(EntityType.ARROW, 16); + map.put(EntityType.DRAGON_FIREBALL, 3); @@ -160,76 +184,77 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886 }); public boolean flushRegionsOnSave = false; } -@@ -488,9 +510,9 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -491,9 +525,9 @@ public class WorldConfiguration extends ConfigurationPart { public TickRates tickRates; public class TickRates extends ConfigurationPart { - public int grassSpread = 1; -+ public int grassSpread = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 1 : 4; // Plazma - Optimize Default Configurations ++ public int grassSpread = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 4 : 1; // Plazma - Optimize default configurations public int containerUpdate = 1; - public int mobSpawner = 1; -+ public int mobSpawner = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 1 : 2; // Plazma - Optimize Default Configurations ++ public int mobSpawner = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 2 : 1; // Plazma - Optimize default configurations public Table, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40)); public Table, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "validatenearbypoi", -1)); } -@@ -514,9 +536,9 @@ public class WorldConfiguration extends ConfigurationPart { +@@ -517,9 +551,9 @@ public class WorldConfiguration extends ConfigurationPart { public class Misc extends ConfigurationPart { public int lightQueueSize = 20; - public boolean updatePathfindingOnBlockUpdate = true; -+ public boolean updatePathfindingOnBlockUpdate = Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations ++ public boolean updatePathfindingOnBlockUpdate = !org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public boolean showSignClickCommandFailureMsgsToPlayer = false; - public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA; -+ public RedstoneImplementation redstoneImplementation = Boolean.getBoolean("Plazma.disableConfigOptimization") ? RedstoneImplementation.VANILLA : RedstoneImplementation.ALTERNATE_CURRENT; // Plazma - Optimize Default Configurations ++ public RedstoneImplementation redstoneImplementation = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? RedstoneImplementation.ALTERNATE_CURRENT : RedstoneImplementation.VANILLA; // Plazma - Optimize default configurations public boolean disableEndCredits = false; public float maxLeashDistance = 10f; public boolean disableSprintInterruptionOnAttack = false; diff --git a/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java b/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java -index 24763d3d270c29c95e0b3e85111145234f660a62..18bc271a34ffba8c83743fef7eaf4a2c1a2bfdec 100644 +index 24763d3d270c29c95e0b3e85111145234f660a62..ba7cf430cdff947a74ae067fc79020ae01e7e457 100644 --- a/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java +++ b/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java @@ -29,6 +29,7 @@ public class ArrowDespawnRate extends FallbackValue.Int { @Override protected int fallback() { -+ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) return 100; // Plazma - Optimize Default Configurations ++ if (org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()) return 100; // Plazma - Optimize default configurations return this.get(FallbackValue.SPIGOT_WORLD_CONFIG).arrowDespawnRate; } diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index ed7bcd832340a7a46897f0275c99e72b7247a5de..65e0a4c04b91e6fd6d2959927bdb75a4fcf8f86b 100644 +index 30fc258faa6f087cf3c91411b48116a3ac416031..a32a1787cbcacb0d3ed6f0d751a04e8fa9d11dd6 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java -@@ -166,7 +166,7 @@ public class Main { +@@ -163,7 +163,7 @@ public class Main { File configFile = (File) optionset.valueOf("bukkit-settings"); YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile); configuration.options().copyDefaults(true); - configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); -+ configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream(Boolean.getBoolean("Plazma.disableConfigOptimization") ? "configurations/bukkit.yml" : "configurations/bukkit_optimized.yml"), Charsets.UTF_8))); // Plazma - Optimize Default Configurations ++ configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream(org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? "configurations/bukkit_optimized.yml" : "configurations/bukkit.yml"), Charsets.UTF_8))); configuration.save(configFile); File commandFile = (File) optionset.valueOf("commands-settings"); +@@ -177,8 +177,7 @@ public class Main { + } + + // Spigot Start +- boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ); +- eulaAgreed = eulaAgreed || Boolean.getBoolean("Paper.isRunDev"); ++ boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ) || Boolean.getBoolean("Paper.isRunDev"); // Plazma + if ( eulaAgreed ) + { + System.err.println( "You have used the Spigot command line EULA agreement flag." ); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index 1ea3012995c738c67b31e997c138f824f9e69ba1..8ed00a650b712cbf4bc8796165a539d76d390d0f 100644 +index cda4544ae96a4fcb5c6c4483df67a59f1b53fd27..54f2c5187322c6dea70c4e0e63cce2e68e7ac647 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -120,7 +120,7 @@ public class DedicatedServerProperties extends Settings { return Mth.clamp(integer, 1, 29999984); }, 29999984); - this.syncChunkWrites = this.get("sync-chunk-writes", true) && Boolean.getBoolean("Paper.enable-sync-chunk-writes"); // Paper - hide behind flag -+ this.syncChunkWrites = Boolean.getBoolean("Paper.enable-sync-chunk-writes"); // Paper - hide behind flag // Plazma - Optimize Default Configurations ++ this.syncChunkWrites = this.get("sync-chunk-writes", Boolean.getBoolean("Paper.enable-sync-chunk-writes")); // Paper - hide behind flag // Plazma - Optimize default configurations this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false); this.enableStatus = this.get("enable-status", true); this.hideOnlinePlayers = this.get("hide-online-players", false); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c43023fecf0882101248f625a28975586da05071..6b092fec6e8c468f3ecd2fc150f5463447ce2c58 100644 +index 3e8f42811e9254567f2522e68b6018704bd63ae2..f8805e11551fddfda44aa36ba4e83f3df2f87500 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -429,7 +429,7 @@ public final class CraftServer implements Server { +@@ -431,7 +431,7 @@ public final class CraftServer implements Server { this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile()); this.configuration.options().copyDefaults(true); - this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); -+ this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(Boolean.getBoolean("Plazma.disableConfigOptimization") ? "configurations/bukkit.yml" : "configurations/bukkit_optimized.yml"), Charsets.UTF_8))); // Plazma - Optimize Default Configurations ++ this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? "configurations/bukkit_optimized.yml" : "configurations/bukkit.yml"), Charsets.UTF_8))); // Plazma - Optimize default configurations ConfigurationSection legacyAlias = null; if (!this.configuration.isString("aliases")) { legacyAlias = this.configuration.getConfigurationSection("aliases"); +diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java +index 39db772735d57e12bbb26a6505ca7a5e360cdd78..eabd643bf096786285ee21e898b2bf8460cd5a26 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java +@@ -302,7 +302,7 @@ public class PlazmaConfigurations extends Configurations -Date: Thu, 23 Mar 2023 14:25:09 +0900 -Subject: [PATCH] ChunkSending Configuration - - -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 857ddc62dd9affbbebcd7cde8a6d675dbb5f68ae..7df971a1bd47862918f4c7342eae19226c4c9fbe 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -22,4 +22,12 @@ public class LevelConfigurations extends ConfigurationPart { - - @Setting(Configuration.VERSION_FIELD) - public int version = CURRENT_VERSION; -+ -+ public ChunkSending chunkSending; -+ public class ChunkSending extends ConfigurationPart { -+ -+ public boolean enabled = DO_OPTIMIZE; -+ public int maxChunksPerTick = 5; -+ -+ } - } diff --git a/patches/server/0012-Console-log-tweaks.patch b/patches/server/0009-Console-logging-tweaks.patch similarity index 72% rename from patches/server/0012-Console-log-tweaks.patch rename to patches/server/0009-Console-logging-tweaks.patch index 0cb975847..ed502672c 100644 --- a/patches/server/0012-Console-log-tweaks.patch +++ b/patches/server/0009-Console-logging-tweaks.patch @@ -1,17 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Fri, 10 Mar 2023 21:45:37 +0900 -Subject: [PATCH] Console log tweaks +From: AlphaKR93 +Date: Wed, 27 Sep 2023 16:55:12 +0900 +Subject: [PATCH] Console logging tweaks -[Offine Warning Configuration Patch] -Original by Irochi -Licensed under the GPL 3.0 diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index e6f14bb0825e3b6987ebb2ec782c8316e3b7c094..191bebab12c94756e9f98cfacbf06eb9a7c2f2f9 100644 +index a970e00482952318c258fc406cb7c39a229b65bc..3fb6225335060b34b5c541e24dd3a261f24ddeb5 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -180,16 +180,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -180,16 +174,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } @@ -28,26 +25,26 @@ index e6f14bb0825e3b6987ebb2ec782c8316e3b7c094..191bebab12c94756e9f98cfacbf06eb9 DedicatedServer.LOGGER.info("Loading properties"); DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties(); -@@ -321,7 +311,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -318,6 +302,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end -- if (!this.usesAuthentication()) { -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.enableOfflineWarnings && !this.usesAuthentication()) { // Plazma ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.offlineWarnings) // Plazma - Console logging tweaks + if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); - // Spigot start -@@ -334,9 +324,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -331,9 +316,21 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); } // Spigot end - DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); -+ DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the \"server.properties\" file or set \"console-logs.offline-warning\" to \"false\" in the \"config/plazma-global.yml\" file."); // Plazma ++ DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file or set \"console-logs.offline-warning\" to \"false\" in the config/plazma-global.yml file."); // Plazma } -+ // Plazma start - Moved down ++ // Plazma start - Console logging tweaks ++ // Moved down + // Paper start - detect running as root -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.enableRootUserWarnings && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.rootUserWarnings && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { + DedicatedServer.LOGGER.warn("****************************"); + DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); + DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); @@ -60,15 +57,19 @@ index e6f14bb0825e3b6987ebb2ec782c8316e3b7c094..191bebab12c94756e9f98cfacbf06eb9 if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 3c70653b720d3d55be199e000e89c627b90e65da..122482e1fae7d6ac8e6b32ebdcf3e611d47901c4 100644 +index 31c98e2c869722ea7e396c245be2d0e8c6bb8feb..ac7089a174365a0e31cfa9eb7bd79148622e1b0c 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -24,6 +24,8 @@ public class GlobalConfiguration extends ConfigurationPart { - public ConsoleLogs consoleLogs; - public class ConsoleLogs extends ConfigurationPart { +@@ -20,4 +20,12 @@ public class GlobalConfiguration extends ConfigurationPart { -+ public boolean enableOfflineWarnings = true; -+ public boolean enableRootUserWarnings = true; - - } + @Setting(Configuration.VERSION_FIELD) + public int version = CURRENT_VERSION; ++ ++ public ConsoleLogs consoleLogs; ++ public class ConsoleLogs extends ConfigurationPart { ++ ++ public boolean offlineWarnings = true; ++ public boolean rootUserWarnings = true; ++ ++ } } diff --git a/patches/server/0010-Implement-ChunkSending.patch b/patches/server/0010-Implement-ChunkSending.patch deleted file mode 100644 index fb436c9ae..000000000 --- a/patches/server/0010-Implement-ChunkSending.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: IPECTER -Date: Thu, 23 Mar 2023 14:32:26 +0900 -Subject: [PATCH] Implement ChunkSending - -Original: someaddons/chunksending -Copyright (C) 2023 someaddons - -diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index e2202389a2c4133a183cca59c4e909fc419379ab..b3e731c122b315d28ae51d32b798f818e270c7ff 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkHolder.java -+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -398,9 +398,12 @@ public class ChunkHolder { - // Paper end - rewrite chunk system - - private void broadcast(List players, Packet packet) { -- players.forEach((entityplayer) -> { -- entityplayer.connection.send(packet); -- }); -+ // Plazma start -+ for (ServerPlayer player : players) { -+ if (this.chunkMap.level.plazmaLevelConfiguration().chunkSending.enabled && player.attachToPending(pos, packet)) continue; -+ player.connection.send(packet); -+ } -+ // Plazma end - } - - // Paper - rewrite chunk system -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 0249eeb3937cf48cea13846a7e39b248947e21a4..f39b3f1b5b37d1939766952a985684279cb2bf2d 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -772,7 +772,35 @@ public class ServerPlayer extends Player { - } - } - // Purpur end -+ // Plazma start - Implement ChunkSending -+ if (this.level().plazmaLevelConfiguration().chunkSending.enabled) { -+ if (chunksToSend.isEmpty()) return; -+ -+ if (disconnected) { -+ chunksToSend.clear(); -+ return; -+ } -+ -+ final List>>> packets = new java.util.ArrayList<>(chunksToSend.entrySet()); -+ packets.sort(java.util.Comparator.comparingDouble(e -> e.getKey().getMiddleBlockPosition(getBlockY()).distSqr(blockPosition()))); -+ -+ for (int i = 0; i < packets.size() && i < this.level().plazmaLevelConfiguration().chunkSending.maxChunksPerTick + packets.size() / 100; i++) { -+ final java.util.Map.Entry>> entry = packets.get(i); -+ for (final Packet packet : entry.getValue()) { -+ connection.send(packet); -+ } -+ chunksToSend.remove(entry.getKey()); -+ } -+ } -+ } -+ -+ public boolean attachToPending(final ChunkPos pos, final Packet packet) { -+ final List> packetList = chunksToSend.get(pos); -+ if (packetList == null) return false; -+ packetList.add(packet); -+ return true; - } -+ // Plazma end - - public void doTick() { - try { -@@ -2437,7 +2465,14 @@ public class ServerPlayer extends Player { - return true; // Paper - } - -+ // Plazma start - Implement ChunkSending -+ private final java.util.Map>> chunksToSend = java.util.Collections.synchronizedMap(new java.util.HashMap<>()); - public void trackChunk(ChunkPos chunkPos, Packet chunkDataPacket) { -+ if (this.level().plazmaLevelConfiguration().chunkSending.enabled) { -+ List> packetList = chunksToSend.computeIfAbsent(chunkPos, k -> new java.util.ArrayList<>()); -+ packetList.add(chunkDataPacket); -+ } -+ // Plazma end - this.connection.send(chunkDataPacket); - // Paper start - if(io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0){ diff --git a/patches/server/0013-Player-configuration-section.patch b/patches/server/0010-Player-configuration-section.patch similarity index 63% rename from patches/server/0013-Player-configuration-section.patch rename to patches/server/0010-Player-configuration-section.patch index 0aa466532..7970e78b6 100644 --- a/patches/server/0013-Player-configuration-section.patch +++ b/patches/server/0010-Player-configuration-section.patch @@ -1,23 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Thu, 23 Mar 2023 21:18:47 +0900 +Date: Wed, 27 Sep 2023 16:56:09 +0900 Subject: [PATCH] Player configuration section diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 122482e1fae7d6ac8e6b32ebdcf3e611d47901c4..61f364abb094a1d137478c106fefa22ceb057ed2 100644 +index ac7089a174365a0e31cfa9eb7bd79148622e1b0c..aa6e455f9f94e33085a7c29ec3b5222eb24957df 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -27,5 +27,12 @@ public class GlobalConfiguration extends ConfigurationPart { - public boolean enableOfflineWarnings = true; - public boolean enableRootUserWarnings = true; +@@ -28,4 +28,9 @@ public class GlobalConfiguration extends ConfigurationPart { + public boolean rootUserWarnings = true; -+ } + } + + public Player player; + public class Player extends ConfigurationPart { + -+ -+ - } ++ } } diff --git a/patches/server/0014-Add-option-to-allow-any-usernames.patch b/patches/server/0011-Add-option-to-allow-any-usernames.patch similarity index 68% rename from patches/server/0014-Add-option-to-allow-any-usernames.patch rename to patches/server/0011-Add-option-to-allow-any-usernames.patch index b694fa4ad..b74f340d1 100644 --- a/patches/server/0014-Add-option-to-allow-any-usernames.patch +++ b/patches/server/0011-Add-option-to-allow-any-usernames.patch @@ -1,32 +1,30 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Thu, 23 Mar 2023 21:20:20 +0900 +Date: Wed, 27 Sep 2023 16:59:14 +0900 Subject: [PATCH] Add option to allow any usernames diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 01d5fa265fb2818465b5a71a2e2efeec751a7a05..0f1ebdc20460da22c1ff2fee2ff6428654139969 100644 +index b875f4af9dcb45bcad0ee59a958442ba673268fe..d38685f82d2e6c4e71179bf3a85a8b183aa6c44b 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -240,7 +240,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -161,6 +161,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void handleHello(ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); -- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); -+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.allowAnyUsername) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Plazma ++ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.allowAnyUsername) // Plazma - Add option to allow any usernames + Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper start - validate usernames if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) { - if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) { diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 61f364abb094a1d137478c106fefa22ceb057ed2..a45ff31d08129c0d5f159615d934a4450d54146e 100644 +index aa6e455f9f94e33085a7c29ec3b5222eb24957df..1c6ab6665788ac4484ff7cda0488604a01e53214 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -32,7 +32,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -32,5 +32,7 @@ public class GlobalConfiguration extends ConfigurationPart { public Player player; public class Player extends ConfigurationPart { -- + public boolean allowAnyUsername = false; - ++ } } diff --git a/patches/server/0011-Console-Log-Configuration.patch b/patches/server/0011-Console-Log-Configuration.patch deleted file mode 100644 index 2ae75176d..000000000 --- a/patches/server/0011-Console-Log-Configuration.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Fri, 10 Mar 2023 20:35:27 +0900 -Subject: [PATCH] Console Log Configuration - - -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 6714947455c1e4c887a5f13ba1a3aeb57324ee0a..3c70653b720d3d55be199e000e89c627b90e65da 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -20,4 +20,10 @@ public class GlobalConfiguration extends ConfigurationPart { - - @Setting(Configuration.VERSION_FIELD) - public int version = CURRENT_VERSION; -+ -+ public ConsoleLogs consoleLogs; -+ public class ConsoleLogs extends ConfigurationPart { -+ -+ -+ } - } diff --git a/patches/server/0016-Add-missing-purpur-configuration-options.patch b/patches/server/0012-Add-missing-purpur-configuration-options.patch similarity index 90% rename from patches/server/0016-Add-missing-purpur-configuration-options.patch rename to patches/server/0012-Add-missing-purpur-configuration-options.patch index 6409360dc..2b2911745 100644 --- a/patches/server/0016-Add-missing-purpur-configuration-options.patch +++ b/patches/server/0012-Add-missing-purpur-configuration-options.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add missing purpur configuration options diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 7166f4a39fd615e10d7b1f53c57363832a41f365..599eeb043bba787b88003ad2ac128e8d7f3e69c6 100644 +index c783ce59ea766e6c46a3313628b961f27e01ee8b..3f36eedeae4b94ca684c57f4ec8d2d1ab5c51aae 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -151,6 +151,23 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -150,6 +150,23 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS protected void registerGoals() { this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur } @@ -33,10 +33,10 @@ index 7166f4a39fd615e10d7b1f53c57363832a41f365..599eeb043bba787b88003ad2ac128e8d @Override diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -index 9f19ebfa6392a080672c472e08f755379e9776b4..e5aa7d1cf2e3178f7117e40f2df444963af43d67 100644 +index 1d84135c709a90843b1ee34fb47508e78a7ce95d..c97ef420581803b569d130b58a97f67d1fee54f2 100644 --- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java +++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -@@ -93,6 +93,18 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider +@@ -95,6 +95,18 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl public int getPurpurBreedTime() { return this.level().purpurConfig.camelBreedingTicks; } @@ -56,10 +56,10 @@ index 9f19ebfa6392a080672c472e08f755379e9776b4..e5aa7d1cf2e3178f7117e40f2df44496 @Override diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index dc1e8bcd8049d79c0e383ccd6a5697f79a3a2ebd..c0fce0582530e24d25368a9600b4f8c06d4f8286 100644 +index 9417ce67cc231d5bfa6813f78ec27196eed423c8..4e471e4a259a64c44da5ab450f0137691428ff6a 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java +++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -@@ -134,6 +134,23 @@ public class Frog extends Animal implements VariantHolder { +@@ -136,6 +136,23 @@ public class Frog extends Animal implements VariantHolder { public float getJumpPower() { return (getRider() != null && isControllable()) ? level().purpurConfig.frogRidableJumpHeight * this.getBlockJumpFactor() : super.getJumpPower(); } @@ -112,10 +112,10 @@ index 6b012bea26e8ef0c04571f43da67f6e108188830..7c816b879d47a1b8a480f4237d1ff0e1 @Override diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -index 552777d7ef6a1190a3b84bdf2f130f735c61d275..87f56c75742d856cdae24f525eac72aa5bce5ce2 100644 +index dcb10e2ea1e0c7d0479adae5bc2ff57ece172aad..795c93352dfa69fad0e034a8377eceb6dc1e81da 100644 --- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -105,6 +105,18 @@ public class Sniffer extends Animal { +@@ -106,6 +106,18 @@ public class Sniffer extends Animal { public boolean isControllable() { return level().purpurConfig.snifferControllable; } @@ -135,10 +135,10 @@ index 552777d7ef6a1190a3b84bdf2f130f735c61d275..87f56c75742d856cdae24f525eac72aa @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 3fa46affc4d77d01909cfeaeaba6e06ba9fd5592..6d3373393e38f0ee530baab0d828e7c2722e9b9b 100644 +index 5e66c2bd3807619cadee5b7081d93d21886e2806..66d47c1613532189e761c0f48d893652c17fe240 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -145,6 +145,23 @@ public class Warden extends Monster implements VibrationSystem { +@@ -146,6 +146,23 @@ public class Warden extends Monster implements VibrationSystem { this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur } @@ -185,10 +185,10 @@ index e88c39d405fc7068db64ad34a03dec8d559e749e..bb5d42ca73722f3a02154ed889625ded @Override diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java -index d0968eeb0f9edeee43394da8a32d3ee8d491737b..00e4bea74de63da5dc174febe6d6473729ddf8ac 100644 +index 5f0b10932f8dda09131ba68207cbfea4715e0f33..92cb442d9326b4fd47cd6ec0425192f751d3e538 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java -@@ -331,6 +331,7 @@ public class PurpurConfig { +@@ -329,6 +329,7 @@ public class PurpurConfig { } public static int barrelRows = 3; @@ -196,7 +196,7 @@ index d0968eeb0f9edeee43394da8a32d3ee8d491737b..00e4bea74de63da5dc174febe6d64737 public static boolean enderChestSixRows = false; public static boolean enderChestPermissionRows = false; public static boolean cryingObsidianValidForPortalFrame = false; -@@ -371,6 +372,7 @@ public class PurpurConfig { +@@ -369,6 +370,7 @@ public class PurpurConfig { case 1 -> 9; default -> 27; }); @@ -205,10 +205,10 @@ index d0968eeb0f9edeee43394da8a32d3ee8d491737b..00e4bea74de63da5dc174febe6d64737 org.bukkit.event.inventory.InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27); enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73fa3d505f3 100644 +index d65d3fd4572a4f5c9b3d2d4e2c0a907aae824cde..1ea0fe11fd9e9a8f300efc85926b9724ab4f69a7 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1117,7 +1117,15 @@ public class PurpurWorldConfig { +@@ -1113,7 +1113,15 @@ public class PurpurWorldConfig { public boolean allayRidableInWater = true; public boolean allayControllable = true; public List allayRespectNBT = new ArrayList<>(); @@ -224,7 +224,7 @@ index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73f allayRidable = getBoolean("mobs.allay.ridable", allayRidable); allayRidableInWater = getBoolean("mobs.allay.ridable-in-water", allayRidableInWater); allayControllable = getBoolean("mobs.allay.controllable", allayControllable); -@@ -1236,7 +1244,15 @@ public class PurpurWorldConfig { +@@ -1232,7 +1240,15 @@ public class PurpurWorldConfig { public double camelMovementSpeedMin = 0.09D; public double camelMovementSpeedMax = 0.09D; public int camelBreedingTicks = 6000; @@ -240,7 +240,7 @@ index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73f camelRidableInWater = getBoolean("mobs.camel.ridable-in-water", camelRidableInWater); camelMaxHealthMin = getDouble("mobs.camel.attributes.max_health.min", camelMaxHealthMin); camelMaxHealthMax = getDouble("mobs.camel.attributes.max_health.max", camelMaxHealthMax); -@@ -1664,7 +1680,15 @@ public class PurpurWorldConfig { +@@ -1660,7 +1676,15 @@ public class PurpurWorldConfig { public boolean frogControllable = true; public float frogRidableJumpHeight = 0.65F; public int frogBreedingTicks = 6000; @@ -256,7 +256,7 @@ index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73f frogRidable = getBoolean("mobs.frog.ridable", frogRidable); frogRidableInWater = getBoolean("mobs.frog.ridable-in-water", frogRidableInWater); frogControllable = getBoolean("mobs.frog.controllable", frogControllable); -@@ -2617,7 +2641,13 @@ public class PurpurWorldConfig { +@@ -2613,7 +2637,13 @@ public class PurpurWorldConfig { public boolean snifferControllable = true; public double snifferMaxHealth = 14.0D; public int snifferBreedingTicks = 6000; @@ -270,7 +270,7 @@ index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73f snifferRidable = getBoolean("mobs.sniffer.ridable", snifferRidable); snifferRidableInWater = getBoolean("mobs.sniffer.ridable-in-water", snifferRidableInWater); snifferControllable = getBoolean("mobs.sniffer.controllable", snifferControllable); -@@ -2716,7 +2746,15 @@ public class PurpurWorldConfig { +@@ -2712,7 +2742,15 @@ public class PurpurWorldConfig { public boolean tadpoleRidable = false; public boolean tadpoleRidableInWater = true; public boolean tadpoleControllable = true; @@ -286,7 +286,7 @@ index 16c3a06df8575a4fecd1967cf18854cb6267a4f7..9c7fd73a30edbf826c8670ac6141c73f tadpoleRidable = getBoolean("mobs.tadpole.ridable", tadpoleRidable); tadpoleRidableInWater = getBoolean("mobs.tadpole.ridable-in-water", tadpoleRidableInWater); tadpoleControllable = getBoolean("mobs.tadpole.controllable", tadpoleControllable); -@@ -2926,7 +2964,15 @@ public class PurpurWorldConfig { +@@ -2922,7 +2960,15 @@ public class PurpurWorldConfig { public boolean wardenRidable = false; public boolean wardenRidableInWater = true; public boolean wardenControllable = true; diff --git a/patches/server/0013-Completely-remove-Mojang-Profiler.patch b/patches/server/0013-Completely-remove-Mojang-Profiler.patch new file mode 100644 index 000000000..84d3162f7 --- /dev/null +++ b/patches/server/0013-Completely-remove-Mojang-Profiler.patch @@ -0,0 +1,944 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 17:52:52 +0900 +Subject: [PATCH] Completely remove Mojang Profiler + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 11de2f237e6dd950b8ddba3d5cfe9066d09f0903..44248dc470d0882b7287debd1993cedf0f238aca 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -113,16 +113,16 @@ import net.minecraft.util.Unit; + import net.minecraft.util.datafix.DataFixers; + import net.minecraft.util.profiling.EmptyProfileResults; + import net.minecraft.util.profiling.ProfileResults; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.util.profiling.ResultField; +-import net.minecraft.util.profiling.SingleTickProfiler; ++//import net.minecraft.util.profiling.SingleTickProfiler; // Plazma - Completely remove profiler + import net.minecraft.util.profiling.jfr.JvmProfiler; + import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; +-import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider; +-import net.minecraft.util.profiling.metrics.storage.MetricsPersister; ++//import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; // Plazma - Completely remove profiler ++//import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder; // Plazma - Completely remove profiler ++//import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder; // Plazma - Completely remove profiler ++//import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider; // Plazma - Completely remove profiler ++//import net.minecraft.util.profiling.metrics.storage.MetricsPersister; // Plazma - Completely remove profiler + import net.minecraft.util.thread.ReentrantBlockableEventLoop; + import net.minecraft.world.Difficulty; + import net.minecraft.world.RandomSequences; +@@ -214,11 +214,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); +- private MetricsRecorder metricsRecorder; +- private ProfilerFiller profiler; +- private Consumer onMetricsRecordingStopped; +- private Consumer onMetricsRecordingFinished; +- private boolean willStartRecordingMetrics; ++ //private MetricsRecorder metricsRecorder; // Plazma - Completely remove profiler ++ //private ProfilerFiller profiler; // Plazma - Completely remove profiler ++ //private Consumer onMetricsRecordingStopped; // Plazma - Completely remove profiler ++ //private Consumer onMetricsRecordingFinished; // Plazma - Completely remove profiler ++ //private boolean willStartRecordingMetrics; // Plazma - Completely remove profiler + @Nullable + private MinecraftServer.TimeProfiler debugCommandProfiler; + private boolean debugCommandProfilerDelayStart; +@@ -2309,10 +2309,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop prepared, ResourceManager manager, ProfilerFiller profiler) { ++ protected void apply(Map prepared, ResourceManager manager/*, ProfilerFiller profiler*/) { // Plazma - Completely remove profiler + Builder builder = ImmutableMap.builder(); + + prepared.forEach((minecraftkey, jsonelement) -> { +diff --git a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java +index 975422a57b83a31e63a600bb4ff9c4e2baaf6da7..6783dc11a321c244296e84223c51cd1a489a9b96 100644 +--- a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java ++++ b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java +@@ -25,7 +25,7 @@ import net.minecraft.server.packs.resources.PreparableReloadListener; + import net.minecraft.server.packs.resources.Resource; + import net.minecraft.server.packs.resources.ResourceManager; + import net.minecraft.tags.TagLoader; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.entity.Entity; + import net.minecraft.world.phys.Vec2; + import net.minecraft.world.phys.Vec3; +@@ -62,7 +62,7 @@ public class ServerFunctionLibrary implements PreparableReloadListener { + } + + @Override +- public CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { ++ public CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor) { // Plazma - Completely remove profiler + CompletableFuture>> completableFuture = CompletableFuture.supplyAsync(() -> { + return this.tagsLoader.load(manager); + }, prepareExecutor); +diff --git a/src/main/java/net/minecraft/server/ServerFunctionManager.java b/src/main/java/net/minecraft/server/ServerFunctionManager.java +index 097ac55028d66ef9ab430ff5dd103db6e3b99fc7..2993e9f326c43ef3f06d5e332899f9fad1f03718 100644 +--- a/src/main/java/net/minecraft/server/ServerFunctionManager.java ++++ b/src/main/java/net/minecraft/server/ServerFunctionManager.java +@@ -19,7 +19,7 @@ import net.minecraft.commands.FunctionInstantiationException; + import net.minecraft.nbt.CompoundTag; + import net.minecraft.network.chat.Component; + import net.minecraft.resources.ResourceLocation; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.level.GameRules; + + public class ServerFunctionManager { +diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java +index 3f4df62773dfe1045914325ce5bc13162192679c..0f27bdc25dc5246d98358a26e1d01e17bc779c2d 100644 +--- a/src/main/java/net/minecraft/server/level/ChunkMap.java ++++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +@@ -68,7 +68,7 @@ import net.minecraft.server.level.progress.ChunkProgressListener; + import net.minecraft.server.network.ServerPlayerConnection; + import net.minecraft.util.CsvOutput; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.util.thread.BlockableEventLoop; + import net.minecraft.util.thread.ProcessorHandle; + import net.minecraft.util.thread.ProcessorMailbox; +diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +index 6255960ae70e14eb11da5043eb003575e300ddf6..999f57366cad34f92a1f80437bf7bd84b40c0e6b 100644 +--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java ++++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +@@ -24,7 +24,7 @@ import net.minecraft.core.SectionPos; + import net.minecraft.network.protocol.Packet; + import net.minecraft.server.level.progress.ChunkProgressListener; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.util.thread.BlockableEventLoop; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.ai.village.poi.PoiManager; +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index e7efdd572716e50ecca217898b8a368e5829f925..72c2af8638d71b92a9762dedb0efec53ce8094f7 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -77,7 +77,7 @@ import net.minecraft.util.Mth; + import net.minecraft.util.ProgressListener; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.util.valueproviders.IntProvider; + import net.minecraft.util.valueproviders.UniformInt; + import net.minecraft.world.DifficultyInstance; +@@ -694,15 +694,15 @@ public class ServerLevel extends Level implements WorldGenLevel { + // Holder holder = worlddimension.type(); // CraftBukkit - decompile error + + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error +- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), spigotConfig -> minecraftserver.plazmaConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor // Plazma ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type()/*, minecraftserver::getProfiler*/, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), spigotConfig -> minecraftserver.plazmaConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor // Plazma // Plazma - Completely remove profiler + this.pvpMode = minecraftserver.isPvpAllowed(); + this.convertable = convertable_conversionsession; + this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); + // CraftBukkit end + this.players = Lists.newArrayList(); + this.entityTickList = new EntityTickList(); +- this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); +- this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); ++ this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded/*, this.getProfilerSupplier()*/); // Plazma - Completely remove profiler ++ this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded/*, this.getProfilerSupplier()*/); // Plazma - Completely remove profiler + this.navigatingMobs = new ObjectOpenHashSet(); + this.blockEvents = new ObjectLinkedOpenHashSet(); + this.blockEventsToReschedule = new ArrayList(64); +diff --git a/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java +index 828196decc89e7e03f88c4a3208ee1ab2bb69242..c0088e0e566abb928c8dcd6f819d82cc1122589b 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java ++++ b/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java +@@ -2,10 +2,10 @@ package net.minecraft.server.packs.resources; + + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + + public interface PreparableReloadListener { +- CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor); ++ CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor); // Plazma - Completely remove profiler + + default String getName() { + return this.getClass().getSimpleName(); +diff --git a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +index 7383c7d3820dce06108eaafd236a7c6c06a10a42..4e1f4e026cd7c566468a58b2ea232d5dee80b86f 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java ++++ b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +@@ -3,11 +3,11 @@ package net.minecraft.server.packs.resources; + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + + public interface ResourceManagerReloadListener extends PreparableReloadListener { + @Override +- default CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { ++ default CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor) { // Plazma - Completely remove profiler + return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> { + //applyProfiler.startTick(); // Purpur + //applyProfiler.push("listener"); // Purpur +diff --git a/src/main/java/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +index 9cc09f0415a09299102dbcf022326944368ea033..2e9e63f3ee6268cafa3b90666cf31019e7341dbb 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java ++++ b/src/main/java/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +@@ -11,7 +11,7 @@ import java.util.Map; + import net.minecraft.resources.FileToIdConverter; + import net.minecraft.resources.ResourceLocation; + import net.minecraft.util.GsonHelper; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import org.slf4j.Logger; + + public abstract class SimpleJsonResourceReloadListener extends SimplePreparableReloadListener> { +@@ -25,7 +25,7 @@ public abstract class SimpleJsonResourceReloadListener extends SimplePreparableR + } + + @Override +- protected Map prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller) { ++ protected Map prepare(ResourceManager resourceManager/*, ProfilerFiller profilerFiller*/) { // Plazma - Completely remove Profiler + Map map = new HashMap<>(); + scanDirectory(resourceManager, this.directory, this.gson, map); + return map; +diff --git a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +index 7ab57748b2f2aea1003d9b7e70e76c372aa1e432..da21380a84d4dcbeaf965b2202e5209b82a82529 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java ++++ b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +@@ -2,19 +2,19 @@ package net.minecraft.server.packs.resources; + + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + + public abstract class SimplePreparableReloadListener implements PreparableReloadListener { + @Override +- public final CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { ++ public final CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor) { + return CompletableFuture.supplyAsync(() -> { +- return this.prepare(manager, prepareProfiler); ++ return this.prepare(manager/*, prepareProfiler*/); + }, prepareExecutor).thenCompose(synchronizer::wait).thenAcceptAsync((prepared) -> { +- this.apply(prepared, manager, applyProfiler); ++ this.apply(prepared, manager/*, applyProfiler*/); + }, applyExecutor); + } + +- protected abstract T prepare(ResourceManager manager, ProfilerFiller profiler); ++ protected abstract T prepare(ResourceManager manager/*, ProfilerFiller profiler*/); + +- protected abstract void apply(T prepared, ResourceManager manager, ProfilerFiller profiler); ++ protected abstract void apply(T prepared, ResourceManager manager/*, ProfilerFiller profiler*/); + } +diff --git a/src/main/java/net/minecraft/server/packs/resources/SimpleReloadInstance.java b/src/main/java/net/minecraft/server/packs/resources/SimpleReloadInstance.java +index de2ecc7c69fb870f843f60596115866214267ee4..05a731dec4aec1d3cf61a761bda018cc8c46afde 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/SimpleReloadInstance.java ++++ b/src/main/java/net/minecraft/server/packs/resources/SimpleReloadInstance.java +@@ -26,7 +26,7 @@ public class SimpleReloadInstance implements ReloadInstance { + + public static SimpleReloadInstance of(ResourceManager manager, List reloaders, Executor prepareExecutor, Executor applyExecutor, CompletableFuture initialStage) { + return new SimpleReloadInstance<>(prepareExecutor, applyExecutor, manager, reloaders, (synchronizer, resourceManager, reloader, prepare, apply) -> { +- return reloader.reload(synchronizer, resourceManager, InactiveProfiler.INSTANCE, InactiveProfiler.INSTANCE, prepareExecutor, apply); ++ return reloader.reload(synchronizer, resourceManager/*, InactiveProfiler.INSTANCE, InactiveProfiler.INSTANCE*/, prepareExecutor, apply); // Plazma - Completely remove Profiler + }, initialStage); + } + +diff --git a/src/main/java/net/minecraft/tags/TagManager.java b/src/main/java/net/minecraft/tags/TagManager.java +index 60ed9413c32d91ce33583cc24998d08869d07a23..67c0d8f7294e18c7b2107b82219bc106608a21f0 100644 +--- a/src/main/java/net/minecraft/tags/TagManager.java ++++ b/src/main/java/net/minecraft/tags/TagManager.java +@@ -14,7 +14,7 @@ import net.minecraft.resources.ResourceKey; + import net.minecraft.resources.ResourceLocation; + import net.minecraft.server.packs.resources.PreparableReloadListener; + import net.minecraft.server.packs.resources.ResourceManager; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + + public class TagManager implements PreparableReloadListener { + private static final Map>, String> CUSTOM_REGISTRY_DIRECTORIES = Map.of(Registries.BLOCK, "tags/blocks", Registries.ENTITY_TYPE, "tags/entity_types", Registries.FLUID, "tags/fluids", Registries.GAME_EVENT, "tags/game_events", Registries.ITEM, "tags/items"); +@@ -35,7 +35,7 @@ public class TagManager implements PreparableReloadListener { + } + + @Override +- public CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { ++ public CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor) { // Plazma - Completely remove profiler + List>> list = this.registryAccess.registries().map((registry) -> { + return this.createLoader(manager, prepareExecutor, registry); + }).toList(); +diff --git a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java b/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java +deleted file mode 100644 +index c6c30d99399c5cde2b0ec2f320d81d952b422d78..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java ++++ /dev/null +@@ -1,208 +0,0 @@ +-package net.minecraft.util.profiling; +- +-import com.google.common.collect.Lists; +-import com.google.common.collect.Maps; +-import com.mojang.logging.LogUtils; +-import it.unimi.dsi.fastutil.longs.LongArrayList; +-import it.unimi.dsi.fastutil.longs.LongList; +-import it.unimi.dsi.fastutil.objects.Object2LongMap; +-import it.unimi.dsi.fastutil.objects.Object2LongMaps; +-import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +-import it.unimi.dsi.fastutil.objects.ObjectArraySet; +-import java.time.Duration; +-import java.util.List; +-import java.util.Map; +-import java.util.Set; +-import java.util.function.IntSupplier; +-import java.util.function.LongSupplier; +-import java.util.function.Supplier; +-import javax.annotation.Nullable; +-import net.minecraft.Util; +-import net.minecraft.util.profiling.metrics.MetricCategory; +-import org.apache.commons.lang3.tuple.Pair; +-import org.slf4j.Logger; +- +-public class ActiveProfiler implements ProfileCollector { +- private static final long WARNING_TIME_NANOS = Duration.ofMillis(100L).toNanos(); +- private static final Logger LOGGER = LogUtils.getLogger(); +- private final List paths = Lists.newArrayList(); +- private final LongList startTimes = new LongArrayList(); +- private final Map entries = Maps.newHashMap(); +- private final IntSupplier getTickTime; +- private final LongSupplier getRealTime; +- private final long startTimeNano; +- private final int startTimeTicks; +- private String path = ""; +- private boolean started; +- @Nullable +- private ActiveProfiler.PathEntry currentEntry; +- private final boolean warn; +- private final Set> chartedPaths = new ObjectArraySet<>(); +- +- public ActiveProfiler(LongSupplier timeGetter, IntSupplier tickGetter, boolean checkTimeout) { +- this.startTimeNano = timeGetter.getAsLong(); +- this.getRealTime = timeGetter; +- this.startTimeTicks = tickGetter.getAsInt(); +- this.getTickTime = tickGetter; +- this.warn = checkTimeout; +- } +- +- @Override +- public void startTick() { +- if (this.started) { +- LOGGER.error("Profiler tick already started - missing endTick()?"); +- } else { +- this.started = true; +- this.path = ""; +- this.paths.clear(); +- //this.push("root"); // Purpur +- } +- } +- +- @Override +- public void endTick() { +- if (!this.started) { +- LOGGER.error("Profiler tick already ended - missing startTick()?"); +- } else { +- //this.pop(); // Purpur +- this.started = false; +- if (!this.path.isEmpty()) { +- LOGGER.error("Profiler tick ended before path was fully popped (remainder: '{}'). Mismatched push/pop?", LogUtils.defer(() -> { +- return ProfileResults.demanglePath(this.path); +- })); +- } +- +- } +- } +- +- @Override +- public void push(String location) { +- if (!this.started) { +- LOGGER.error("Cannot push '{}' to profiler if profiler tick hasn't started - missing startTick()?", (Object)location); +- } else { +- if (!this.path.isEmpty()) { +- this.path = this.path + "\u001e"; +- } +- +- this.path = this.path + location; +- this.paths.add(this.path); +- this.startTimes.add(Util.getNanos()); +- this.currentEntry = null; +- } +- } +- +- @Override +- public void push(Supplier locationGetter) { +- //this.push(locationGetter.get()); // Purpur +- } +- +- @Override +- public void markForCharting(MetricCategory type) { +- this.chartedPaths.add(Pair.of(this.path, type)); +- } +- +- @Override +- public void pop() { +- if (!this.started) { +- LOGGER.error("Cannot pop from profiler if profiler tick hasn't started - missing startTick()?"); +- } else if (this.startTimes.isEmpty()) { +- LOGGER.error("Tried to pop one too many times! Mismatched push() and pop()?"); +- } else { +- long l = Util.getNanos(); +- long m = this.startTimes.removeLong(this.startTimes.size() - 1); +- this.paths.remove(this.paths.size() - 1); +- long n = l - m; +- ActiveProfiler.PathEntry pathEntry = this.getCurrentEntry(); +- pathEntry.accumulatedDuration += n; +- ++pathEntry.count; +- pathEntry.maxDuration = Math.max(pathEntry.maxDuration, n); +- pathEntry.minDuration = Math.min(pathEntry.minDuration, n); +- if (this.warn && n > WARNING_TIME_NANOS) { +- LOGGER.warn("Something's taking too long! '{}' took aprox {} ms", LogUtils.defer(() -> { +- return ProfileResults.demanglePath(this.path); +- }), LogUtils.defer(() -> { +- return (double)n / 1000000.0D; +- })); +- } +- +- this.path = this.paths.isEmpty() ? "" : this.paths.get(this.paths.size() - 1); +- this.currentEntry = null; +- } +- } +- +- @Override +- public void popPush(String location) { +- //this.pop(); // Purpur +- //this.push(location); // Purpur +- } +- +- @Override +- public void popPush(Supplier locationGetter) { +- //this.pop(); // Purpur +- //this.push(locationGetter); // Purpur +- } +- +- private ActiveProfiler.PathEntry getCurrentEntry() { +- if (this.currentEntry == null) { +- this.currentEntry = this.entries.computeIfAbsent(this.path, (k) -> { +- return new ActiveProfiler.PathEntry(); +- }); +- } +- +- return this.currentEntry; +- } +- +- @Override +- public void incrementCounter(String marker, int num) { +- this.getCurrentEntry().counters.addTo(marker, (long)num); +- } +- +- @Override +- public void incrementCounter(Supplier markerGetter, int num) { +- this.getCurrentEntry().counters.addTo(markerGetter.get(), (long)num); +- } +- +- @Override +- public ProfileResults getResults() { +- return new FilledProfileResults(this.entries, this.startTimeNano, this.startTimeTicks, this.getRealTime.getAsLong(), this.getTickTime.getAsInt()); +- } +- +- @Nullable +- @Override +- public ActiveProfiler.PathEntry getEntry(String name) { +- return this.entries.get(name); +- } +- +- @Override +- public Set> getChartedPaths() { +- return this.chartedPaths; +- } +- +- public static class PathEntry implements ProfilerPathEntry { +- long maxDuration = Long.MIN_VALUE; +- long minDuration = Long.MAX_VALUE; +- long accumulatedDuration; +- long count; +- final Object2LongOpenHashMap counters = new Object2LongOpenHashMap<>(); +- +- @Override +- public long getDuration() { +- return this.accumulatedDuration; +- } +- +- @Override +- public long getMaxDuration() { +- return this.maxDuration; +- } +- +- @Override +- public long getCount() { +- return this.count; +- } +- +- @Override +- public Object2LongMap getCounters() { +- return Object2LongMaps.unmodifiable(this.counters); +- } +- } +-} +diff --git a/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java b/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java +deleted file mode 100644 +index 863343a87fe34d72f04af89d75268b477b2adc7a..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java ++++ /dev/null +@@ -1,116 +0,0 @@ +-package net.minecraft.util.profiling; +- +-import java.util.function.Supplier; +-import net.minecraft.util.profiling.metrics.MetricCategory; +- +-public interface ProfilerFiller { +- String ROOT = "root"; +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void startTick(); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void endTick(); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void push(String location); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void push(Supplier locationGetter); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void pop(); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void popPush(String location); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void popPush(Supplier locationGetter); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void markForCharting(MetricCategory type); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- default void incrementCounter(String marker) { +- //this.incrementCounter(marker, 1); // Purpur +- } +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void incrementCounter(String marker, int num); +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- default void incrementCounter(Supplier markerGetter) { +- //this.incrementCounter(markerGetter, 1); // Purpur +- } +- +- @io.papermc.paper.annotation.DoNotUse // Purpur +- void incrementCounter(Supplier markerGetter, int num); +- +- static ProfilerFiller tee(final ProfilerFiller a, final ProfilerFiller b) { +- if (a == InactiveProfiler.INSTANCE) { +- return b; +- } else { +- return b == InactiveProfiler.INSTANCE ? a : new ProfilerFiller() { +- @Override +- public void startTick() { +- //a.startTick(); // Purpur +- //b.startTick(); // Purpur +- } +- +- @Override +- public void endTick() { +- //a.endTick(); // Purpur +- //b.endTick(); // Purpur +- } +- +- @Override +- public void push(String location) { +- //a.push(location); // Purpur +- //b.push(location); // Purpur +- } +- +- @Override +- public void push(Supplier locationGetter) { +- //a.push(locationGetter); // Purpur +- //b.push(locationGetter); // Purpur +- } +- +- @Override +- public void markForCharting(MetricCategory type) { +- //a.markForCharting(type); // Purpur +- //b.markForCharting(type); // Purpur +- } +- +- @Override +- public void pop() { +- //a.pop(); // Purpur +- //b.pop(); // Purpur +- } +- +- @Override +- public void popPush(String location) { +- //a.popPush(location); // Purpur +- //b.popPush(location); // Purpur +- } +- +- @Override +- public void popPush(Supplier locationGetter) { +- //a.popPush(locationGetter); // Purpur +- //b.popPush(locationGetter); // Purpur +- } +- +- @Override +- public void incrementCounter(String marker, int num) { +- //a.incrementCounter(marker, num); // Purpur +- //b.incrementCounter(marker, num); // Purpur +- } +- +- @Override +- public void incrementCounter(Supplier markerGetter, int num) { +- //a.incrementCounter(markerGetter, num); // Purpur +- //b.incrementCounter(markerGetter, num); // Purpur +- } +- }; +- } +- } +-} +diff --git a/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java +deleted file mode 100644 +index 729ebd1b2433327de243d0168289e180a841f47c..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java ++++ /dev/null +@@ -1,24 +0,0 @@ +-package net.minecraft.util.profiling.metrics.profiling; +- +-import net.minecraft.util.profiling.ProfilerFiller; +- +-@Deprecated(forRemoval = true) +-public interface MetricsRecorder { +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- void end(); +- +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- void cancel(); +- +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- void startTick(); +- +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- boolean isRecording(); +- +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- ProfilerFiller getProfiler(); +- +- @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Purpur +- void endTick(); +-} +diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java +index d35afa8f8648bbcbfc044323bcda1b1182d7dce4..fb5c21ba15995d00da87ee6ef9e4ab8f6678d67f 100644 +--- a/src/main/java/net/minecraft/world/entity/Mob.java ++++ b/src/main/java/net/minecraft/world/entity/Mob.java +@@ -147,8 +147,8 @@ public abstract class Mob extends LivingEntity implements Targeting { + this.pathfindingMalus = Maps.newEnumMap(BlockPathTypes.class); + this.restrictCenter = BlockPos.ZERO; + this.restrictRadius = -1.0F; +- this.goalSelector = new GoalSelector(world.getProfilerSupplier()); +- this.targetSelector = new GoalSelector(world.getProfilerSupplier()); ++ this.goalSelector = new GoalSelector(/*world.getProfilerSupplier()*/); // Plazma - Completely remove profiler ++ this.targetSelector = new GoalSelector(/*world.getProfilerSupplier()*/); // Plazma - Completely remove profiler + this.lookControl = new org.purpurmc.purpur.controller.LookControllerWASD(this); // Purpur + this.moveControl = new org.purpurmc.purpur.controller.MoveControllerWASD(this); // Purpur + this.jumpControl = new JumpControl(this); +diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +index 02978315bc2b828cc603ce7478408f3f82c249c2..4f9b19c45afd6b26833ba892a90d3a9559d5d859 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java ++++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +@@ -11,7 +11,7 @@ import java.util.Set; + import java.util.function.Predicate; + import java.util.function.Supplier; + import java.util.stream.Stream; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import org.slf4j.Logger; + + public class GoalSelector { +@@ -29,7 +29,7 @@ public class GoalSelector { + }; + private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); + private final Set availableGoals = Sets.newLinkedHashSet(); +- private final Supplier profiler; ++ //private final Supplier profiler; // Plazma - Completely remove profiler + private final EnumSet disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be. + private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector + private int tickCount; +@@ -37,9 +37,11 @@ public class GoalSelector { + private int curRate; + private static final Goal.Flag[] GOAL_FLAG_VALUES = Goal.Flag.values(); // Paper - remove streams from pathfindergoalselector + ++ /* // Plazma - Completely remove profiler + public GoalSelector(Supplier profiler) { + this.profiler = profiler; + } ++ */ // Plazma - Completely remove profiler + + public void addGoal(int priority, Goal goal) { + this.availableGoals.add(new WrappedGoal(priority, goal)); +diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +index 666fc85bc2079cb367b340f2605f29fe002f4d22..36c60716c6aaa446ff7123a3babafb2edd2266ac 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java ++++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +@@ -31,7 +31,7 @@ import net.minecraft.resources.ResourceLocation; + import net.minecraft.server.packs.resources.ResourceManager; + import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; + import net.minecraft.util.GsonHelper; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.Container; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.Level; +@@ -51,7 +51,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { + super(RecipeManager.GSON, "recipes"); + } + +- protected void apply(Map prepared, ResourceManager manager, ProfilerFiller profiler) { ++ protected void apply(Map prepared, ResourceManager manager/*, ProfilerFiller profiler*/) { // Plazma - Completely remove Profiler + this.hasErrors = false; + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable + Map, Object2ObjectLinkedOpenHashMap>> map1 = Maps.newHashMap(); +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index e45a5282dc0ea3a35da24c7c3a0c7cda9a773f0c..1a5880ae3c3b17d49f0b083dff66e5619c08ec20 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -39,7 +39,7 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.util.AbortableIterationConsumer; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.damagesource.DamageSources; +@@ -137,7 +137,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + private final ResourceKey dimensionTypeId; + private final Holder dimensionTypeRegistration; + public final WritableLevelData levelData; +- private final Supplier profiler; ++ //private final Supplier profiler; // Plazma - Completely remove profiler + public final boolean isClientSide; + private final WorldBorder worldBorder; + private final BiomeManager biomeManager; +@@ -259,7 +259,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + + public abstract ResourceKey getTypeKey(); + +- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.function.Function plazmaLevelConfigurationCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor // Plazma ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder/*, Supplier supplier*/, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.function.Function plazmaLevelConfigurationCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor // Plazma // Plazma - Completely remove profiler + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper + this.plazmaLevelConfiguration = plazmaLevelConfigurationCreator.apply(this.spigotConfig); // Plazma +@@ -276,7 +276,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + } + + // CraftBukkit end +- this.profiler = supplier; ++ //this.profiler = supplier; // Plazma - Completely remove profiler + this.levelData = worlddatamutable; + this.dimensionTypeRegistration = holder; + this.dimensionTypeId = (ResourceKey) holder.unwrapKey().orElseThrow(() -> { +@@ -1830,6 +1830,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + return false; + } + ++ /* // Plazma - Completely remove profiler + public ProfilerFiller getProfiler() { + if (true || gg.pufferfish.pufferfish.PufferfishConfig.disableMethodProfiler) return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Pufferfish // Purpur + return (ProfilerFiller) this.profiler.get(); +@@ -1838,6 +1839,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public Supplier getProfilerSupplier() { + return this.profiler; + } ++ */ // Plazma - Completely remove profiler + + @Override + public BiomeManager getBiomeManager() { +diff --git a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java +index 0f1025495237aebe30132ace0832aa5718d6f9bb..0226280bbdb9d63831d93f980ee117da1eac08aa 100644 +--- a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java ++++ b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java +@@ -8,7 +8,7 @@ import net.minecraft.core.BlockPos; + import net.minecraft.core.Holder; + import net.minecraft.core.SectionPos; + import net.minecraft.core.registries.Registries; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.server.level.ServerLevel; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.level.biome.Biome; +@@ -155,7 +155,9 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { + return this.level.getHeight(); + } + ++ /* // Plazma - Completely remove profiler + public ProfilerFiller getProfiler() { + return this.level.getProfiler(); + } ++ */ // Plazma - Completely remove profiler + } +diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +index 8d385708df97d47881929d4352f1b90286aad1a2..a25b93f98b2c525b146c979df2a95a9a749300a8 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +@@ -25,7 +25,7 @@ import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; + import net.minecraft.server.level.FullChunkStatus; + import net.minecraft.server.level.ServerLevel; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.entity.Entity; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.Level; +@@ -445,7 +445,7 @@ public class LevelChunk extends ChunkAccess { + } + + if (LightEngine.hasDifferentLightProperties(this, blockposition, iblockdata1, iblockdata)) { +- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); ++ //ProfilerFiller gameprofilerfiller = this.level.getProfiler(); // Plazma - Completely remove profiler + + //gameprofilerfiller.push("updateSkyLightSources"); // Purpur + this.skyLightSources.update(this, j, i, l); +diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +index a8af51a25b0f99c3a64d9150fdfcd6b818aa7581..b9689131a7a46b46c0b75b86f2bb163d7de74921 100644 +--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java ++++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +@@ -12,7 +12,7 @@ import java.util.function.Function; + import java.util.stream.Collectors; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.util.profiling.metrics.MetricCategory; + import net.minecraft.world.entity.Mob; + import net.minecraft.world.level.PathNavigationRegion; +@@ -44,7 +44,7 @@ public class PathFinder { + map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); + } + // Paper end +- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); ++ Path path = this.findPath(/*world.getProfiler(), */node, map, followRange, distance, rangeMultiplier); // Plazma - Completely remove profiler + this.nodeEvaluator.done(); + return path; + } +@@ -52,7 +52,7 @@ public class PathFinder { + + @Nullable + // Paper start - optimize collection +- private Path findPath(ProfilerFiller profiler, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { ++ private Path findPath(/*ProfilerFiller profiler, */Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { // Plazma - Completely remove profiler + //profiler.push("find_path"); // Purpur + //profiler.markForCharting(MetricCategory.PATH_FINDING); // Purpur + // Set set = positions.keySet(); +diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +index dd375fffa727db76fa989248b9b836960974c372..45161f960a29395538c67461ebf864e595f6737f 100644 +--- a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java ++++ b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +@@ -19,7 +19,7 @@ import net.minecraft.resources.ResourceLocation; + import net.minecraft.server.packs.resources.PreparableReloadListener; + import net.minecraft.server.packs.resources.ResourceManager; + import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; + import org.slf4j.Logger; + +@@ -35,7 +35,7 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv + public LootDataManager() {} + + @Override +- public final CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { ++ public final CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager/*, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler*/, Executor prepareExecutor, Executor applyExecutor) { // Plazma - Completely remove profiler + Map, Map> map = new HashMap(); + CompletableFuture[] acompletablefuture = (CompletableFuture[]) LootDataType.values().map((lootdatatype) -> { + return LootDataManager.scheduleElementParse(lootdatatype, manager, prepareExecutor, map); +diff --git a/src/main/java/net/minecraft/world/ticks/LevelTicks.java b/src/main/java/net/minecraft/world/ticks/LevelTicks.java +index 0043c0087896a6df6910b0500da37d84b287c901..a7b4d38bf7d2f8c1ba42d64b7ffd577d6fca5378 100644 +--- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java ++++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java +@@ -23,7 +23,7 @@ import net.minecraft.Util; + import net.minecraft.core.BlockPos; + import net.minecraft.core.SectionPos; + import net.minecraft.core.Vec3i; +-import net.minecraft.util.profiling.ProfilerFiller; ++//import net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.levelgen.structure.BoundingBox; + +@@ -32,7 +32,7 @@ public class LevelTicks implements LevelTickAccess { + return ScheduledTick.INTRA_TICK_DRAIN_ORDER.compare(a.peek(), b.peek()); + }; + private final LongPredicate tickCheck; +- private final Supplier profiler; ++ //private final Supplier profiler; // Plazma - Completely remove profiler + private final Long2ObjectMap> allContainers = new Long2ObjectOpenHashMap<>(); + private final Long2LongMap nextTickForContainer = Util.make(new Long2LongOpenHashMap(), (map) -> { + map.defaultReturnValue(Long.MAX_VALUE); +@@ -48,9 +48,9 @@ public class LevelTicks implements LevelTickAccess { + + }; + +- public LevelTicks(LongPredicate tickingFutureReadyPredicate, Supplier profilerGetter) { ++ public LevelTicks(LongPredicate tickingFutureReadyPredicate/*, Supplier profilerGetter*/) { + this.tickCheck = tickingFutureReadyPredicate; +- this.profiler = profilerGetter; ++ //this.profiler = profilerGetter; // Plazma - Completely remove profiler + } + + public void addContainer(ChunkPos pos, LevelChunkTicks scheduler) { +@@ -88,7 +88,7 @@ public class LevelTicks implements LevelTickAccess { + public void tick(long time, int maxTicks, BiConsumer ticker) { + //ProfilerFiller profilerFiller = this.profiler.get(); // Purpur + //profilerFiller.push("collect"); // Purpur +- this.collectTicks(time, maxTicks, null); // Purpur ++ this.collectTicks(time, maxTicks); // Purpur // Plazma - Completely remove profiler + //profilerFiller.popPush("run"); // Purpur + //profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size()); // Purpur + this.runCollectedTicks(ticker); +@@ -97,7 +97,7 @@ public class LevelTicks implements LevelTickAccess { + //profilerFiller.pop(); // Purpur + } + +- private void collectTicks(long time, int maxTicks, ProfilerFiller profiler) { ++ private void collectTicks(long time, int maxTicks/*, ProfilerFiller profiler*/) { // Plazma - Completely remove profiler + this.sortContainersToTick(time); + //profiler.incrementCounter("containersToTick", this.containersToTick.size()); // Purpur + this.drainContainers(time, maxTicks); diff --git a/patches/server/0015-Add-permission-to-bypass-reducedDebugInfo-gamerule.patch b/patches/server/0015-Add-permission-to-bypass-reducedDebugInfo-gamerule.patch deleted file mode 100644 index bd4ed3702..000000000 --- a/patches/server/0015-Add-permission-to-bypass-reducedDebugInfo-gamerule.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Thu, 23 Mar 2023 21:35:15 +0900 -Subject: [PATCH] Add permission to bypass reducedDebugInfo gamerule - - -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 824f31b68b38f2f8642fb9d59a123cfdaffbb7b2..86932974a9101779691de336a8c45c464158fca8 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -282,7 +282,7 @@ public abstract class PlayerList { - ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player); - GameRules gamerules = worldserver1.getGameRules(); - boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); -- boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); -+ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) && !(org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.enableBypassReducedDebugInfoPermission && player.getBukkitEntity().hasPermission("plazma.bypass-reduced-debug-info-gamerule")); // Plazma - - // Spigot - view distance - playerconnection.send(new ClientboundLoginPacket(player.getId(), worlddata.isHardcore(), player.gameMode.getGameModeForPlayer(), player.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), worldserver1.getWorld().getSendViewDistance(), worldserver1.getWorld().getSimulationDistance(), flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), player.getLastDeathLocation(), player.getPortalCooldown())); // Paper - replace old player chunk management -@@ -1315,7 +1315,7 @@ public abstract class PlayerList { - player.getEntityData().refresh(player); // CraftBukkkit - SPIGOT-7218: sync metadata - player.connection.send(new ClientboundSetCarriedItemPacket(player.getInventory().selected)); - // CraftBukkit start - from GameRules -- int i = player.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; -+ int i = player.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) && !(org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.enableBypassReducedDebugInfoPermission && player.getBukkitEntity().hasPermission("plazma.bypass-reduced-debug-info-gamerule")) ? 22 : 23; - player.connection.send(new ClientboundEntityEventPacket(player, (byte) i)); - float immediateRespawn = player.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, immediateRespawn)); -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index a45ff31d08129c0d5f159615d934a4450d54146e..4f54ae58bd20481f02aaec3f8406996a5e01b24f 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -33,6 +33,7 @@ public class GlobalConfiguration extends ConfigurationPart { - public class Player extends ConfigurationPart { - - public boolean allowAnyUsername = false; -+ public boolean enableBypassReducedDebugInfoPermission = true; // TODO: Move to Player.Permissions class - - } - } diff --git a/patches/server/0017-Structure-Configuration.patch b/patches/unapplied/server/0017-Structure-Configuration.patch similarity index 100% rename from patches/server/0017-Structure-Configuration.patch rename to patches/unapplied/server/0017-Structure-Configuration.patch diff --git a/patches/server/0018-Configurable-nether-portal-size.patch b/patches/unapplied/server/0018-Configurable-nether-portal-size.patch similarity index 100% rename from patches/server/0018-Configurable-nether-portal-size.patch rename to patches/unapplied/server/0018-Configurable-nether-portal-size.patch diff --git a/patches/server/0019-Misc-configuration.patch b/patches/unapplied/server/0019-Misc-configuration.patch similarity index 100% rename from patches/server/0019-Misc-configuration.patch rename to patches/unapplied/server/0019-Misc-configuration.patch diff --git a/patches/server/0020-Reduce-create-random-instance.patch b/patches/unapplied/server/0020-Reduce-create-random-instance.patch similarity index 100% rename from patches/server/0020-Reduce-create-random-instance.patch rename to patches/unapplied/server/0020-Reduce-create-random-instance.patch diff --git a/patches/server/0021-Entity-Configuration.patch b/patches/unapplied/server/0021-Entity-Configuration.patch similarity index 100% rename from patches/server/0021-Entity-Configuration.patch rename to patches/unapplied/server/0021-Entity-Configuration.patch diff --git a/patches/server/0022-Various-Optimizations.patch b/patches/unapplied/server/0022-Various-Optimizations.patch similarity index 100% rename from patches/server/0022-Various-Optimizations.patch rename to patches/unapplied/server/0022-Various-Optimizations.patch diff --git a/patches/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch b/patches/unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch similarity index 100% rename from patches/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch rename to patches/unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch diff --git a/patches/server/0024-Apply-faster-random.patch b/patches/unapplied/server/0024-Apply-faster-random.patch similarity index 100% rename from patches/server/0024-Apply-faster-random.patch rename to patches/unapplied/server/0024-Apply-faster-random.patch diff --git a/patches/server/0025-Do-not-send-useless-entity-packets.patch b/patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch similarity index 100% rename from patches/server/0025-Do-not-send-useless-entity-packets.patch rename to patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch diff --git a/patches/server/0026-No-Chat-Reports-Configuration.patch b/patches/unapplied/server/0026-No-Chat-Reports-Configuration.patch similarity index 100% rename from patches/server/0026-No-Chat-Reports-Configuration.patch rename to patches/unapplied/server/0026-No-Chat-Reports-Configuration.patch diff --git a/patches/server/0027-Implement-No-Chat-Reports.patch b/patches/unapplied/server/0027-Implement-No-Chat-Reports.patch similarity index 100% rename from patches/server/0027-Implement-No-Chat-Reports.patch rename to patches/unapplied/server/0027-Implement-No-Chat-Reports.patch diff --git a/patches/server/0028-FixMySpawnR-Configuration.patch b/patches/unapplied/server/0028-FixMySpawnR-Configuration.patch similarity index 100% rename from patches/server/0028-FixMySpawnR-Configuration.patch rename to patches/unapplied/server/0028-FixMySpawnR-Configuration.patch diff --git a/patches/server/0029-Implement-FixMySpawnR.patch b/patches/unapplied/server/0029-Implement-FixMySpawnR.patch similarity index 100% rename from patches/server/0029-Implement-FixMySpawnR.patch rename to patches/unapplied/server/0029-Implement-FixMySpawnR.patch diff --git a/patches/server/0030-Implement-MemoryLeakFix.patch b/patches/unapplied/server/0030-Implement-MemoryLeakFix.patch similarity index 100% rename from patches/server/0030-Implement-MemoryLeakFix.patch rename to patches/unapplied/server/0030-Implement-MemoryLeakFix.patch diff --git a/patches/server/0031-Reduce-Sensor-Work.patch b/patches/unapplied/server/0031-Reduce-Sensor-Work.patch similarity index 100% rename from patches/server/0031-Reduce-Sensor-Work.patch rename to patches/unapplied/server/0031-Reduce-Sensor-Work.patch diff --git a/patches/server/0032-Configurable-Sensor-Tick.patch b/patches/unapplied/server/0032-Configurable-Sensor-Tick.patch similarity index 100% rename from patches/server/0032-Configurable-Sensor-Tick.patch rename to patches/unapplied/server/0032-Configurable-Sensor-Tick.patch diff --git a/patches/server/0033-Optimize-VarInts.patch b/patches/unapplied/server/0033-Optimize-VarInts.patch similarity index 100% rename from patches/server/0033-Optimize-VarInts.patch rename to patches/unapplied/server/0033-Optimize-VarInts.patch diff --git a/patches/server/0034-Variable-entity-wakeup-duration.patch b/patches/unapplied/server/0034-Variable-entity-wakeup-duration.patch similarity index 100% rename from patches/server/0034-Variable-entity-wakeup-duration.patch rename to patches/unapplied/server/0034-Variable-entity-wakeup-duration.patch diff --git a/patches/server/0035-More-optimise-state-lookup.patch b/patches/unapplied/server/0035-More-optimise-state-lookup.patch similarity index 100% rename from patches/server/0035-More-optimise-state-lookup.patch rename to patches/unapplied/server/0035-More-optimise-state-lookup.patch diff --git a/patches/server/0036-Suppress-Error-From-DirtyAttributes.patch b/patches/unapplied/server/0036-Suppress-Error-From-DirtyAttributes.patch similarity index 100% rename from patches/server/0036-Suppress-Error-From-DirtyAttributes.patch rename to patches/unapplied/server/0036-Suppress-Error-From-DirtyAttributes.patch diff --git a/patches/server/0037-Implement-FerriteCore.patch b/patches/unapplied/server/0037-Implement-FerriteCore.patch similarity index 100% rename from patches/server/0037-Implement-FerriteCore.patch rename to patches/unapplied/server/0037-Implement-FerriteCore.patch diff --git a/patches/server/0038-Skip-event-if-no-listeners.patch b/patches/unapplied/server/0038-Skip-event-if-no-listeners.patch similarity index 100% rename from patches/server/0038-Skip-event-if-no-listeners.patch rename to patches/unapplied/server/0038-Skip-event-if-no-listeners.patch diff --git a/patches/server/0039-Optimize-spigot-event-bus.patch b/patches/unapplied/server/0039-Optimize-spigot-event-bus.patch similarity index 100% rename from patches/server/0039-Optimize-spigot-event-bus.patch rename to patches/unapplied/server/0039-Optimize-spigot-event-bus.patch diff --git a/patches/server/0040-Reduce-allocations.patch b/patches/unapplied/server/0040-Reduce-allocations.patch similarity index 100% rename from patches/server/0040-Reduce-allocations.patch rename to patches/unapplied/server/0040-Reduce-allocations.patch diff --git a/patches/server/0041-CarpetFixes-Configuration.patch b/patches/unapplied/server/0041-CarpetFixes-Configuration.patch similarity index 100% rename from patches/server/0041-CarpetFixes-Configuration.patch rename to patches/unapplied/server/0041-CarpetFixes-Configuration.patch diff --git a/patches/server/0042-CarpetFixes-Optimizations-BiomeManager.patch b/patches/unapplied/server/0042-CarpetFixes-Optimizations-BiomeManager.patch similarity index 100% rename from patches/server/0042-CarpetFixes-Optimizations-BiomeManager.patch rename to patches/unapplied/server/0042-CarpetFixes-Optimizations-BiomeManager.patch diff --git a/patches/server/0043-CarpetFixes-Optimizations-RecipeManager.patch b/patches/unapplied/server/0043-CarpetFixes-Optimizations-RecipeManager.patch similarity index 100% rename from patches/server/0043-CarpetFixes-Optimizations-RecipeManager.patch rename to patches/unapplied/server/0043-CarpetFixes-Optimizations-RecipeManager.patch diff --git a/patches/server/0044-CarpetFixes-Optimizations-Sheep.patch b/patches/unapplied/server/0044-CarpetFixes-Optimizations-Sheep.patch similarity index 100% rename from patches/server/0044-CarpetFixes-Optimizations-Sheep.patch rename to patches/unapplied/server/0044-CarpetFixes-Optimizations-Sheep.patch diff --git a/patches/server/0045-Async-PathProcessing.patch b/patches/unapplied/server/0045-Async-PathProcessing.patch similarity index 100% rename from patches/server/0045-Async-PathProcessing.patch rename to patches/unapplied/server/0045-Async-PathProcessing.patch