Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -0,0 +1,18 @@
--- a/net/minecraft/world/item/component/BlocksAttacks.java
+++ b/net/minecraft/world/item/component/BlocksAttacks.java
@@ -86,10 +_,14 @@
);
}
- public void disable(ServerLevel level, LivingEntity entity, float duration, ItemStack stack) {
+ public void disable(ServerLevel level, LivingEntity entity, float duration, ItemStack stack, LivingEntity attacker) { // Paper
int i = this.disableBlockingForTicks(duration);
if (i > 0) {
if (entity instanceof Player player) {
+ // Paper start
+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), attacker.getBukkitEntity(), i);
+ if (!shieldDisableEvent.callEvent()) return;
+ // Paper end
player.getCooldowns().addCooldown(stack, i);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/component/ChargedProjectiles.java
+++ b/net/minecraft/world/item/component/ChargedProjectiles.java
@@ -16,6 +_,7 @@
@@ -22,6 +_,7 @@
.xmap(ChargedProjectiles::new, chargedProjectiles -> chargedProjectiles.items);
public static final StreamCodec<RegistryFriendlyByteBuf, ChargedProjectiles> STREAM_CODEC = ItemStack.STREAM_CODEC
.apply(ByteBufCodecs.list())

View File

@@ -1,13 +1,13 @@
--- a/net/minecraft/world/item/component/CustomData.java
+++ b/net/minecraft/world/item/component/CustomData.java
@@ -34,7 +_,17 @@
@@ -33,7 +_,17 @@
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<CustomData> CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.AS_CODEC)
- public static final Codec<CustomData> CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.FLATTENED_CODEC)
+ // Paper start - Item serialization as json
+ public static ThreadLocal<Boolean> SERIALIZE_CUSTOM_AS_SNBT = ThreadLocal.withInitial(() -> false);
+ public static final Codec<CustomData> CODEC = Codec.either(CompoundTag.CODEC, TagParser.AS_CODEC)
+ public static final Codec<CustomData> CODEC = Codec.either(CompoundTag.CODEC, TagParser.FLATTENED_CODEC)
+ .xmap(com.mojang.datafixers.util.Either::unwrap, data -> { // Both will be used for deserialization, but we decide which one to use for serialization
+ if (!SERIALIZE_CUSTOM_AS_SNBT.get()) {
+ return com.mojang.datafixers.util.Either.left(data); // First codec
@@ -15,7 +15,7 @@
+ return com.mojang.datafixers.util.Either.right(data); // Second codec
+ }
+ })
+ // Paper end - Item serialization as json
+ // Paper end - Item serialization as json
.xmap(CustomData::new, customData -> customData.tag);
public static final Codec<CustomData> CODEC_WITH_ID = CODEC.validate(
data -> data.getUnsafe().contains("id", 8) ? DataResult.success(data) : DataResult.error(() -> "Missing id for entity in: " + data)
data -> data.getUnsafe().getString("id").isPresent() ? DataResult.success(data) : DataResult.error(() -> "Missing id for entity in: " + data)

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/component/ItemContainerContents.java
+++ b/net/minecraft/world/item/component/ItemContainerContents.java
@@ -22,6 +_,7 @@
@@ -28,6 +_,7 @@
.xmap(ItemContainerContents::fromSlots, ItemContainerContents::asSlots);
public static final StreamCodec<RegistryFriendlyByteBuf, ItemContainerContents> STREAM_CODEC = ItemStack.OPTIONAL_STREAM_CODEC
.apply(ByteBufCodecs.list(256))

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/component/OminousBottleAmplifier.java
+++ b/net/minecraft/world/item/component/OminousBottleAmplifier.java
@@ -28,8 +_,15 @@
@@ -29,8 +_,15 @@
@Override
public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consumable consumable) {
@@ -17,4 +17,4 @@
+ // Paper end - properly resend entities - collect packets for bundle
@Override
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag tooltipFlag) {
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/component/SuspiciousStewEffects.java
+++ b/net/minecraft/world/item/component/SuspiciousStewEffects.java
@@ -41,6 +_,15 @@
@@ -42,6 +_,15 @@
}
}
@@ -14,5 +14,5 @@
+ // CraftBukkit end
+
@Override
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag tooltipFlag) {
if (tooltipFlag.isCreative()) {
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) {
if (flag.isCreative()) {

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/component/WrittenBookContent.java
+++ b/net/minecraft/world/item/component/WrittenBookContent.java
@@ -94,7 +_,7 @@
public static boolean resolveForItem(ItemStack stack, CommandSourceStack source, @Nullable Player player) {
WrittenBookContent writtenBookContent = stack.get(DataComponents.WRITTEN_BOOK_CONTENT);
- if (writtenBookContent != null && !writtenBookContent.resolved()) {
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && writtenBookContent != null && !writtenBookContent.resolved()) { // Paper - Disable component selector resolving in books by default
WrittenBookContent writtenBookContent1 = writtenBookContent.resolve(source, player);
if (writtenBookContent1 != null) {
stack.set(DataComponents.WRITTEN_BOOK_CONTENT, writtenBookContent1);