From a894c3a43799d65d94c7ca3d15fd46a3d5187e03 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 3 Dec 2024 20:58:25 +0100 Subject: [PATCH] Some fixes, start updating CustomModelData API --- patches/api/DataComponent-API.patch | 37 +++++++++++++++---- ...ew-bypassEnchantmentLevelRestriction.patch | 0 .../server/Add-FeatureFlag-API.patch | 0 .../server/Add-Offline-PDC-API.patch | 0 .../Add-PlayerInsertLecternBookEvent.patch | 0 ...Levels-with-enchantment-registry-set.patch | 0 .../Add-enchantment-seed-update-API.patch | 0 ...d-proper-async-player-disconnections.patch | 0 .../server/Add-recipeBrewTime.patch | 0 .../Call-bucket-events-for-cauldrons.patch | 0 .../server/Check-dead-flag-in-isAlive.patch | 2 +- .../server/DataComponent-API.patch | 20 +++++++++- ...etty-printing-for-advancement-saving.patch | 0 ...Fire-BlockExpEvent-on-grindstone-use.patch | 0 .../server/Fix-CraftBukkit-drag-system.patch | 0 .../Fix-InventoryOpenEvent-cancellation.patch | 0 ...ndPreprocessEvent-on-signed-commands.patch | 0 ...vent-firing-for-block-entity-loading.patch | 0 .../server/Fix-a-bunch-of-vanilla-bugs.patch | 2 +- ...sending-chat-to-client-with-updating.patch | 0 .../server/Improve-entity-effect-API.patch | 0 .../server/Item-serialization-as-json.patch | 4 +- ...e-lootable-item-function-from-compas.patch | 0 ...all-time-unused-skip-tick-protection.patch | 0 .../server/Tag-Lifecycle-Events.patch | 4 +- ...date-slot-in-PlayerInventory-setSlot.patch | 0 .../Void-damage-configuration-API.patch | 0 .../optimize-dirt-and-snow-spreading.patch | 3 +- 28 files changed, 56 insertions(+), 16 deletions(-) rename patches/{unapplied => }/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch (100%) rename patches/{unapplied => }/server/Add-FeatureFlag-API.patch (100%) rename patches/{unapplied => }/server/Add-Offline-PDC-API.patch (100%) rename patches/{unapplied => }/server/Add-PlayerInsertLecternBookEvent.patch (100%) rename patches/{unapplied => }/server/Add-enchantWithLevels-with-enchantment-registry-set.patch (100%) rename patches/{unapplied => }/server/Add-enchantment-seed-update-API.patch (100%) rename patches/{unapplied => }/server/Add-proper-async-player-disconnections.patch (100%) rename patches/{unapplied => }/server/Add-recipeBrewTime.patch (100%) rename patches/{unapplied => }/server/Call-bucket-events-for-cauldrons.patch (100%) rename patches/{unapplied => }/server/Check-dead-flag-in-isAlive.patch (93%) rename patches/{unapplied => }/server/DataComponent-API.patch (99%) rename patches/{unapplied => }/server/Disable-pretty-printing-for-advancement-saving.patch (100%) rename patches/{unapplied => }/server/Fire-BlockExpEvent-on-grindstone-use.patch (100%) rename patches/{unapplied => }/server/Fix-CraftBukkit-drag-system.patch (100%) rename patches/{unapplied => }/server/Fix-InventoryOpenEvent-cancellation.patch (100%) rename patches/{unapplied => }/server/Fix-PlayerCommandPreprocessEvent-on-signed-commands.patch (100%) rename patches/{unapplied => }/server/Fix-SculkBloomEvent-firing-for-block-entity-loading.patch (100%) rename patches/{unapplied => }/server/Fix-synchronise-sending-chat-to-client-with-updating.patch (100%) rename patches/{unapplied => }/server/Improve-entity-effect-API.patch (100%) rename patches/{unapplied => }/server/Item-serialization-as-json.patch (98%) rename patches/{unapplied => }/server/Remove-set-damage-lootable-item-function-from-compas.patch (100%) rename patches/{unapplied => }/server/Remove-wall-time-unused-skip-tick-protection.patch (100%) rename patches/{unapplied => }/server/Tag-Lifecycle-Events.patch (99%) rename patches/{unapplied => }/server/Validate-slot-in-PlayerInventory-setSlot.patch (100%) rename patches/{unapplied => }/server/Void-damage-configuration-API.patch (100%) diff --git a/patches/api/DataComponent-API.patch b/patches/api/DataComponent-API.patch index 0a838cc6f7..948ca41188 100644 --- a/patches/api/DataComponent-API.patch +++ b/patches/api/DataComponent-API.patch @@ -859,12 +859,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.datacomponent.item; + ++import java.util.List; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +/** + * Holds the custom model data. ++ * + * @see io.papermc.paper.datacomponent.DataComponentTypes#CUSTOM_MODEL_DATA + */ +@NullMarked @@ -872,18 +874,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +@ApiStatus.NonExtendable +public interface CustomModelData { + -+ @Contract(value = "_ -> new", pure = true) -+ static CustomModelData customModelData(final int id) { -+ return ItemComponentTypesBridge.bridge().customModelData(id); -+ } ++ // TODO + + /** -+ * Gets the custom model data id. ++ * Gets the custom model data float values. + * -+ * @return the id ++ * @return the float values + */ + @Contract(pure = true) -+ int id(); ++ List floats(); ++ ++ /** ++ * Gets the custom model data boolean values. ++ * ++ * @return the boolean values ++ */ ++ @Contract(pure = true) ++ List flags(); ++ ++ /** ++ * Gets the custom model data string values. ++ * ++ * @return the string values ++ */ ++ @Contract(pure = true) ++ List strings(); ++ ++ /** ++ * Gets the custom model data color values. ++ * ++ * @return the color values ++ */ ++ @Contract(pure = true) ++ List colors(); +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/DamageResistant.java b/src/main/java/io/papermc/paper/datacomponent/item/DamageResistant.java new file mode 100644 diff --git a/patches/unapplied/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch b/patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch similarity index 100% rename from patches/unapplied/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch rename to patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch diff --git a/patches/unapplied/server/Add-FeatureFlag-API.patch b/patches/server/Add-FeatureFlag-API.patch similarity index 100% rename from patches/unapplied/server/Add-FeatureFlag-API.patch rename to patches/server/Add-FeatureFlag-API.patch diff --git a/patches/unapplied/server/Add-Offline-PDC-API.patch b/patches/server/Add-Offline-PDC-API.patch similarity index 100% rename from patches/unapplied/server/Add-Offline-PDC-API.patch rename to patches/server/Add-Offline-PDC-API.patch diff --git a/patches/unapplied/server/Add-PlayerInsertLecternBookEvent.patch b/patches/server/Add-PlayerInsertLecternBookEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerInsertLecternBookEvent.patch rename to patches/server/Add-PlayerInsertLecternBookEvent.patch diff --git a/patches/unapplied/server/Add-enchantWithLevels-with-enchantment-registry-set.patch b/patches/server/Add-enchantWithLevels-with-enchantment-registry-set.patch similarity index 100% rename from patches/unapplied/server/Add-enchantWithLevels-with-enchantment-registry-set.patch rename to patches/server/Add-enchantWithLevels-with-enchantment-registry-set.patch diff --git a/patches/unapplied/server/Add-enchantment-seed-update-API.patch b/patches/server/Add-enchantment-seed-update-API.patch similarity index 100% rename from patches/unapplied/server/Add-enchantment-seed-update-API.patch rename to patches/server/Add-enchantment-seed-update-API.patch diff --git a/patches/unapplied/server/Add-proper-async-player-disconnections.patch b/patches/server/Add-proper-async-player-disconnections.patch similarity index 100% rename from patches/unapplied/server/Add-proper-async-player-disconnections.patch rename to patches/server/Add-proper-async-player-disconnections.patch diff --git a/patches/unapplied/server/Add-recipeBrewTime.patch b/patches/server/Add-recipeBrewTime.patch similarity index 100% rename from patches/unapplied/server/Add-recipeBrewTime.patch rename to patches/server/Add-recipeBrewTime.patch diff --git a/patches/unapplied/server/Call-bucket-events-for-cauldrons.patch b/patches/server/Call-bucket-events-for-cauldrons.patch similarity index 100% rename from patches/unapplied/server/Call-bucket-events-for-cauldrons.patch rename to patches/server/Call-bucket-events-for-cauldrons.patch diff --git a/patches/unapplied/server/Check-dead-flag-in-isAlive.patch b/patches/server/Check-dead-flag-in-isAlive.patch similarity index 93% rename from patches/unapplied/server/Check-dead-flag-in-isAlive.patch rename to patches/server/Check-dead-flag-in-isAlive.patch index 6f85870075..8c01488f5a 100644 --- a/patches/unapplied/server/Check-dead-flag-in-isAlive.patch +++ b/patches/server/Check-dead-flag-in-isAlive.patch @@ -26,4 +26,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead } - public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, Predicate predicate, DoubleSupplier... entityYChecks) { + public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, double... checkedYs) { diff --git a/patches/unapplied/server/DataComponent-API.patch b/patches/server/DataComponent-API.patch similarity index 99% rename from patches/unapplied/server/DataComponent-API.patch rename to patches/server/DataComponent-API.patch index c7fe50a063..4bb18e9de4 100644 --- a/patches/unapplied/server/DataComponent-API.patch +++ b/patches/server/DataComponent-API.patch @@ -969,6 +969,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.datacomponent.item; + ++import java.util.List; +import org.bukkit.craftbukkit.util.Handleable; + +public record PaperCustomModelData( @@ -981,8 +982,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public int id() { -+ return this.impl.value(); ++ public List floats() { ++ return this.impl.floats(); ++ } ++ ++ @Override ++ public List flags() { ++ return this.impl.flags(); ++ } ++ ++ @Override ++ public List strings() { ++ return this.impl.strings(); ++ } ++ ++ @Override ++ public List colors() { ++ return this.impl.colors(); + } +} diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java diff --git a/patches/unapplied/server/Disable-pretty-printing-for-advancement-saving.patch b/patches/server/Disable-pretty-printing-for-advancement-saving.patch similarity index 100% rename from patches/unapplied/server/Disable-pretty-printing-for-advancement-saving.patch rename to patches/server/Disable-pretty-printing-for-advancement-saving.patch diff --git a/patches/unapplied/server/Fire-BlockExpEvent-on-grindstone-use.patch b/patches/server/Fire-BlockExpEvent-on-grindstone-use.patch similarity index 100% rename from patches/unapplied/server/Fire-BlockExpEvent-on-grindstone-use.patch rename to patches/server/Fire-BlockExpEvent-on-grindstone-use.patch diff --git a/patches/unapplied/server/Fix-CraftBukkit-drag-system.patch b/patches/server/Fix-CraftBukkit-drag-system.patch similarity index 100% rename from patches/unapplied/server/Fix-CraftBukkit-drag-system.patch rename to patches/server/Fix-CraftBukkit-drag-system.patch diff --git a/patches/unapplied/server/Fix-InventoryOpenEvent-cancellation.patch b/patches/server/Fix-InventoryOpenEvent-cancellation.patch similarity index 100% rename from patches/unapplied/server/Fix-InventoryOpenEvent-cancellation.patch rename to patches/server/Fix-InventoryOpenEvent-cancellation.patch diff --git a/patches/unapplied/server/Fix-PlayerCommandPreprocessEvent-on-signed-commands.patch b/patches/server/Fix-PlayerCommandPreprocessEvent-on-signed-commands.patch similarity index 100% rename from patches/unapplied/server/Fix-PlayerCommandPreprocessEvent-on-signed-commands.patch rename to patches/server/Fix-PlayerCommandPreprocessEvent-on-signed-commands.patch diff --git a/patches/unapplied/server/Fix-SculkBloomEvent-firing-for-block-entity-loading.patch b/patches/server/Fix-SculkBloomEvent-firing-for-block-entity-loading.patch similarity index 100% rename from patches/unapplied/server/Fix-SculkBloomEvent-firing-for-block-entity-loading.patch rename to patches/server/Fix-SculkBloomEvent-firing-for-block-entity-loading.patch diff --git a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch index eac5af64a9..e0ca5f1f08 100644 --- a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch @@ -123,7 +123,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } - } -+ } else { this.player.containerMenu.sendAllDataToRemote(); } // Paper - Fix inventory desync; MC-99075 ++ } else { this.player.containerMenu.sendAllDataToRemote(); } // Paper - Fix inventory desync; MC-99075 } else { MutableComponent ichatmutablecomponent1 = Component.translatable("build.tooHigh", i).withStyle(ChatFormatting.RED); diff --git a/patches/unapplied/server/Fix-synchronise-sending-chat-to-client-with-updating.patch b/patches/server/Fix-synchronise-sending-chat-to-client-with-updating.patch similarity index 100% rename from patches/unapplied/server/Fix-synchronise-sending-chat-to-client-with-updating.patch rename to patches/server/Fix-synchronise-sending-chat-to-client-with-updating.patch diff --git a/patches/unapplied/server/Improve-entity-effect-API.patch b/patches/server/Improve-entity-effect-API.patch similarity index 100% rename from patches/unapplied/server/Improve-entity-effect-API.patch rename to patches/server/Improve-entity-effect-API.patch diff --git a/patches/unapplied/server/Item-serialization-as-json.patch b/patches/server/Item-serialization-as-json.patch similarity index 98% rename from patches/unapplied/server/Item-serialization-as-json.patch rename to patches/server/Item-serialization-as-json.patch index 368d4b33c6..a0e792e96e 100644 --- a/patches/unapplied/server/Item-serialization-as-json.patch +++ b/patches/server/Item-serialization-as-json.patch @@ -8,10 +8,10 @@ diff --git a/src/main/java/net/minecraft/world/item/component/CustomData.java b/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/component/CustomData.java +++ b/src/main/java/net/minecraft/world/item/component/CustomData.java -@@ -0,0 +0,0 @@ import org.slf4j.Logger; - public final class CustomData { +@@ -0,0 +0,0 @@ public final class CustomData { private static final Logger LOGGER = LogUtils.getLogger(); public static final CustomData EMPTY = new CustomData(new CompoundTag()); + private static final String TYPE_TAG = "id"; - public static final Codec CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.AS_CODEC) + // Paper start - Item serialization as json + public static ThreadLocal SERIALIZE_CUSTOM_AS_SNBT = ThreadLocal.withInitial(() -> false); diff --git a/patches/unapplied/server/Remove-set-damage-lootable-item-function-from-compas.patch b/patches/server/Remove-set-damage-lootable-item-function-from-compas.patch similarity index 100% rename from patches/unapplied/server/Remove-set-damage-lootable-item-function-from-compas.patch rename to patches/server/Remove-set-damage-lootable-item-function-from-compas.patch diff --git a/patches/unapplied/server/Remove-wall-time-unused-skip-tick-protection.patch b/patches/server/Remove-wall-time-unused-skip-tick-protection.patch similarity index 100% rename from patches/unapplied/server/Remove-wall-time-unused-skip-tick-protection.patch rename to patches/server/Remove-wall-time-unused-skip-tick-protection.patch diff --git a/patches/unapplied/server/Tag-Lifecycle-Events.patch b/patches/server/Tag-Lifecycle-Events.patch similarity index 99% rename from patches/unapplied/server/Tag-Lifecycle-Events.patch rename to patches/server/Tag-Lifecycle-Events.patch index 88a2703fd1..05147cdf12 100644 --- a/patches/unapplied/server/Tag-Lifecycle-Events.patch +++ b/patches/server/Tag-Lifecycle-Events.patch @@ -491,8 +491,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ReloadableServerRegistries.java +++ b/src/main/java/net/minecraft/server/ReloadableServerRegistries.java @@ -0,0 +0,0 @@ public class ReloadableServerRegistries { - String string = Registries.elementsDirPath(type.registryKey()); - SimpleJsonResourceReloadListener.scanDirectory(resourceManager, string, ops, type.codec(), map); + Map map = new HashMap<>(); + SimpleJsonResourceReloadListener.scanDirectory(resourceManager, type.registryKey(), ops, type.codec(), map); map.forEach((id, value) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, ResourceKey.create(type.registryKey(), id), value, DEFAULT_REGISTRATION_INFO, conversions)); // Paper - register with listeners - TagLoader.loadTagsForRegistry(resourceManager, writableRegistry); + TagLoader.loadTagsForRegistry(resourceManager, writableRegistry, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.RELOAD); // Paper - tag life cycle - reload diff --git a/patches/unapplied/server/Validate-slot-in-PlayerInventory-setSlot.patch b/patches/server/Validate-slot-in-PlayerInventory-setSlot.patch similarity index 100% rename from patches/unapplied/server/Validate-slot-in-PlayerInventory-setSlot.patch rename to patches/server/Validate-slot-in-PlayerInventory-setSlot.patch diff --git a/patches/unapplied/server/Void-damage-configuration-API.patch b/patches/server/Void-damage-configuration-API.patch similarity index 100% rename from patches/unapplied/server/Void-damage-configuration-API.patch rename to patches/server/Void-damage-configuration-API.patch diff --git a/patches/server/optimize-dirt-and-snow-spreading.patch b/patches/server/optimize-dirt-and-snow-spreading.patch index 2d220d6694..96ce135e74 100644 --- a/patches/server/optimize-dirt-and-snow-spreading.patch +++ b/patches/server/optimize-dirt-and-snow-spreading.patch @@ -59,6 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 BlockPos blockposition1 = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); - if (world.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(iblockdata1, world, blockposition1)) { +- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(world.getBlockState(blockposition1.above())))); // CraftBukkit + // Paper start - Perf: optimize dirt and snow spreading + if (pos.getX() == blockposition1.getX() && pos.getY() == blockposition1.getY() && pos.getZ() == blockposition1.getZ()) { + continue; @@ -71,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + access = world.getChunkAt(blockposition1); + } + if (access.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(access, iblockdata1, world, blockposition1)) { - org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(world.getBlockState(blockposition1.above())))); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(access.getBlockState(blockposition1.above())))); // CraftBukkit + // Paper end - Perf: optimize dirt and snow spreading } }