From 21581c811194f9f0ff55c123b573f39c0c58505b Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Wed, 24 Apr 2024 16:25:57 -0700 Subject: [PATCH] 955 --- .../server/Add-PlayerShieldDisableEvent.patch | 53 ++++++++++++ .../server/Add-Structure-check-API.patch | 0 .../Add-UUID-attribute-modifier-API.patch | 0 .../server/Add-drops-to-shear-events.patch | 16 ++-- .../server/Add-experience-points-API.patch | 0 ...sh-event-for-all-player-interactions.patch | 8 +- ...n-t-fire-sync-events-during-worldgen.patch | 12 +-- .../Dont-resend-blocks-on-interactions.patch | 2 +- .../Expose-LootTable-of-DecoratedPot.patch | 0 ...m-getAttributeModifier-duplication-c.patch | 0 ...-on-null-loc-for-EntityTeleportEvent.patch | 0 ...g-event-call-for-entity-teleport-API.patch | 0 .../server/Fix-potions-splash-events.patch | 4 +- ...several-issues-with-EntityBreedEvent.patch | 0 .../server/Fixup-NamespacedKey-handling.patch | 53 ++++++------ .../server/Improve-Registry.patch | 0 ...ly-create-LootContext-for-criterions.patch | 0 patches/server/More-Projectile-API.patch | 6 +- ...e-experience-dropping-on-block-break.patch | 0 ...llocation-of-Vec3D-by-entity-tracker.patch | 0 ...estore-vanilla-entity-drops-behavior.patch | 8 +- ...date-ResourceLocation-in-NBT-reading.patch | 18 ++--- .../server/add-more-scoreboard-API.patch | 0 .../server/Add-PlayerShieldDisableEvent.patch | 80 ------------------- 24 files changed, 117 insertions(+), 143 deletions(-) create mode 100644 patches/server/Add-PlayerShieldDisableEvent.patch rename patches/{unapplied => }/server/Add-Structure-check-API.patch (100%) rename patches/{unapplied => }/server/Add-UUID-attribute-modifier-API.patch (100%) rename patches/{unapplied => }/server/Add-drops-to-shear-events.patch (97%) rename patches/{unapplied => }/server/Add-experience-points-API.patch (100%) rename patches/{unapplied => }/server/Add-hand-to-fish-event-for-all-player-interactions.patch (95%) rename patches/{unapplied => }/server/Don-t-fire-sync-events-during-worldgen.patch (93%) rename patches/{unapplied => }/server/Dont-resend-blocks-on-interactions.patch (99%) rename patches/{unapplied => }/server/Expose-LootTable-of-DecoratedPot.patch (100%) rename patches/{unapplied => }/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch (100%) rename patches/{unapplied => }/server/Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch (100%) rename patches/{unapplied => }/server/Fix-missing-event-call-for-entity-teleport-API.patch (100%) rename patches/{unapplied => }/server/Fix-several-issues-with-EntityBreedEvent.patch (100%) rename patches/{unapplied => }/server/Fixup-NamespacedKey-handling.patch (72%) rename patches/{unapplied => }/server/Improve-Registry.patch (100%) rename patches/{unapplied => }/server/Lazily-create-LootContext-for-criterions.patch (100%) rename patches/{unapplied => }/server/Properly-handle-experience-dropping-on-block-break.patch (100%) rename patches/{unapplied => }/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch (100%) rename patches/{unapplied => }/server/Restore-vanilla-entity-drops-behavior.patch (98%) rename patches/{unapplied => }/server/Validate-ResourceLocation-in-NBT-reading.patch (87%) rename patches/{unapplied => }/server/add-more-scoreboard-API.patch (100%) delete mode 100644 patches/unapplied/server/Add-PlayerShieldDisableEvent.patch diff --git a/patches/server/Add-PlayerShieldDisableEvent.patch b/patches/server/Add-PlayerShieldDisableEvent.patch new file mode 100644 index 0000000000..180adfc264 --- /dev/null +++ b/patches/server/Add-PlayerShieldDisableEvent.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite <cryptite@gmail.com> +Date: Mon, 1 May 2023 16:22:43 -0500 +Subject: [PATCH] Add PlayerShieldDisableEvent + +Called whenever a players shield is disabled. This is mainly caused by +attacking players or monsters that carry axes. + +The event, while similar to the PlayerItemCooldownEvent, offers other +behaviour and can hence not be implemented as a childtype of said event. +Specifically, cancelling the event prevents the game events from being +sent to the player. + +Plugins listening to just the PlayerItemCooldownEvent may not want said +sideeffects, meaning the disable event cannot share a handlerlist with +the cooldown event + +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { + protected void blockUsingShield(LivingEntity attacker) { + super.blockUsingShield(attacker); + if (attacker.canDisableShield()) { +- this.disableShield(); ++ this.disableShield(attacker); // Paper - Add PlayerShieldDisableEvent + } + + } +@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { + this.attack(target); + } + ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerShieldDisableEvent + public void disableShield() { +- this.getCooldowns().addCooldown(Items.SHIELD, 100); ++ // Paper start - Add PlayerShieldDisableEvent ++ this.disableShield(null); ++ } ++ public void disableShield(@Nullable LivingEntity attacker) { ++ final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null; ++ if (finalAttacker != null) { ++ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100); ++ if (!shieldDisableEvent.callEvent()) return; ++ this.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown()); ++ } else { ++ this.getCooldowns().addCooldown(Items.SHIELD, 100); ++ } ++ // Paper end - Add PlayerShieldDisableEvent + this.stopUsingItem(); + this.level().broadcastEntityEvent(this, (byte) 30); + } diff --git a/patches/unapplied/server/Add-Structure-check-API.patch b/patches/server/Add-Structure-check-API.patch similarity index 100% rename from patches/unapplied/server/Add-Structure-check-API.patch rename to patches/server/Add-Structure-check-API.patch diff --git a/patches/unapplied/server/Add-UUID-attribute-modifier-API.patch b/patches/server/Add-UUID-attribute-modifier-API.patch similarity index 100% rename from patches/unapplied/server/Add-UUID-attribute-modifier-API.patch rename to patches/server/Add-UUID-attribute-modifier-API.patch diff --git a/patches/unapplied/server/Add-drops-to-shear-events.patch b/patches/server/Add-drops-to-shear-events.patch similarity index 97% rename from patches/unapplied/server/Add-drops-to-shear-events.patch rename to patches/server/Add-drops-to-shear-events.patch index ad1d73998f..1d340c81a0 100644 --- a/patches/unapplied/server/Add-drops-to-shear-events.patch +++ b/patches/server/Add-drops-to-shear-events.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java @@ -0,0 +0,0 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { - + if (entityliving instanceof Shearable ishearable) { if (ishearable.readyForShearing()) { // CraftBukkit start - if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) { @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit end - ishearable.shear(SoundSource.BLOCKS); + ishearable.shear(SoundSource.BLOCKS, CraftItemStack.asNMSCopy(event.getDrops())); // Paper - Add drops to shear events - worldserver.gameEvent((Entity) null, GameEvent.SHEAR, blockposition); + worldserver.gameEvent((Entity) null, (Holder) GameEvent.SHEAR, blockposition); return true; } diff --git a/src/main/java/net/minecraft/world/entity/Shearable.java b/src/main/java/net/minecraft/world/entity/Shearable.java @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.shear(SoundSource.PLAYERS, drops); // Paper - custom shear drops this.gameEvent(GameEvent.SHEAR, player); if (!this.level().isClientSide) { - itemstack.hurtAndBreak(1, player, (entityhuman1) -> { + itemstack.hurtAndBreak(1, player, getSlotForHand(hand)); @@ -0,0 +0,0 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo @Override @@ -139,8 +139,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.shear(SoundSource.PLAYERS); + this.shear(SoundSource.PLAYERS, drops); // Paper this.gameEvent(GameEvent.SHEAR, player); - itemstack.hurtAndBreak(1, player, (entityhuman1) -> { - entityhuman1.broadcastBreakEvent(hand); + itemstack.hurtAndBreak(1, player, getSlotForHand(hand)); + return InteractionResult.SUCCESS; @@ -0,0 +0,0 @@ public class Sheep extends Animal implements Shearable { @Override @@ -199,7 +199,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.shear(SoundSource.PLAYERS, drops); // Paper this.gameEvent(GameEvent.SHEAR, player); if (!this.level().isClientSide) { - itemstack.hurtAndBreak(1, player, (entityhuman1) -> { + itemstack.hurtAndBreak(1, player, getSlotForHand(hand)); @@ -0,0 +0,0 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM @Override @@ -220,12 +220,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!this.level().isClientSide()) { this.setPumpkin(false); - this.forceDrops = true; // CraftBukkit -- this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F); +- this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), this.getEyeHeight()); - this.forceDrops = false; // CraftBukkit + // Paper start - custom shear drops (moved drop generation to separate method) + for (final ItemStack drop : drops) { + this.forceDrops = true; -+ this.spawnAtLocation(drop, 1.7F); ++ this.spawnAtLocation(drop, this.getEyeHeight()); + this.forceDrops = false; + } + // Paper end - custom shear drops diff --git a/patches/unapplied/server/Add-experience-points-API.patch b/patches/server/Add-experience-points-API.patch similarity index 100% rename from patches/unapplied/server/Add-experience-points-API.patch rename to patches/server/Add-experience-points-API.patch diff --git a/patches/unapplied/server/Add-hand-to-fish-event-for-all-player-interactions.patch b/patches/server/Add-hand-to-fish-event-for-all-player-interactions.patch similarity index 95% rename from patches/unapplied/server/Add-hand-to-fish-event-for-all-player-interactions.patch rename to patches/server/Add-hand-to-fish-event-for-all-player-interactions.patch index f25f1a4006..0436d7f462 100644 --- a/patches/unapplied/server/Add-hand-to-fish-event-for-all-player-interactions.patch +++ b/patches/server/Add-hand-to-fish-event-for-all-player-interactions.patch @@ -64,12 +64,12 @@ diff --git a/src/main/java/net/minecraft/world/item/FishingRodItem.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/FishingRodItem.java +++ b/src/main/java/net/minecraft/world/item/FishingRodItem.java -@@ -0,0 +0,0 @@ public class FishingRodItem extends Item implements Vanishable { +@@ -0,0 +0,0 @@ public class FishingRodItem extends Item { if (user.fishing != null) { if (!world.isClientSide) { - i = user.fishing.retrieve(itemstack); + i = user.fishing.retrieve(hand, itemstack); // Paper - Add hand parameter to PlayerFishEvent - itemstack.hurtAndBreak(i, user, (entityhuman1) -> { - entityhuman1.broadcastBreakEvent(hand); - }); + itemstack.hurtAndBreak(i, user, LivingEntity.getSlotForHand(hand)); + } + diff --git a/patches/unapplied/server/Don-t-fire-sync-events-during-worldgen.patch b/patches/server/Don-t-fire-sync-events-during-worldgen.patch similarity index 93% rename from patches/unapplied/server/Don-t-fire-sync-events-during-worldgen.patch rename to patches/server/Don-t-fire-sync-events-during-worldgen.patch index 37749405df..d57c3fb213 100644 --- a/patches/unapplied/server/Don-t-fire-sync-events-during-worldgen.patch +++ b/patches/server/Don-t-fire-sync-events-during-worldgen.patch @@ -34,7 +34,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (pose == this.getPose()) { return; } @@ -98,8 +98,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (mobeffect1 == null) { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.onEffectAdded(mobeffect, entity); flag = true; + mobeffect.onEffectAdded(this); // CraftBukkit start - } else if (event.isOverride()) { + } else if (override) { // Paper - Don't fire sync event during generation @@ -111,11 +111,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Spider.java +++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java @@ -0,0 +0,0 @@ public class Spider extends Monster { - MobEffect mobeffectlist = entityspider_groupdataspider.effect; + Holder<MobEffect> holder = entityspider_groupdataspider.effect; - if (mobeffectlist != null) { -- this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit -+ this.addEffect(new MobEffectInstance(mobeffectlist, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit // Paper - Don't fire sync event during generation; only if this is happening in a ServerLevel + if (holder != null) { +- this.addEffect(new MobEffectInstance(holder, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit ++ this.addEffect(new MobEffectInstance(holder, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit } } diff --git a/patches/unapplied/server/Dont-resend-blocks-on-interactions.patch b/patches/server/Dont-resend-blocks-on-interactions.patch similarity index 99% rename from patches/unapplied/server/Dont-resend-blocks-on-interactions.patch rename to patches/server/Dont-resend-blocks-on-interactions.patch index c88f3274ca..085c871563 100644 --- a/patches/unapplied/server/Dont-resend-blocks-on-interactions.patch +++ b/patches/server/Dont-resend-blocks-on-interactions.patch @@ -152,7 +152,7 @@ diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ public final class ItemStack { +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { world.preventPoiUpdated = false; // Brute force all possible updates diff --git a/patches/unapplied/server/Expose-LootTable-of-DecoratedPot.patch b/patches/server/Expose-LootTable-of-DecoratedPot.patch similarity index 100% rename from patches/unapplied/server/Expose-LootTable-of-DecoratedPot.patch rename to patches/server/Expose-LootTable-of-DecoratedPot.patch diff --git a/patches/unapplied/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch b/patches/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch similarity index 100% rename from patches/unapplied/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch rename to patches/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch diff --git a/patches/unapplied/server/Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch b/patches/server/Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch similarity index 100% rename from patches/unapplied/server/Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch rename to patches/server/Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch diff --git a/patches/unapplied/server/Fix-missing-event-call-for-entity-teleport-API.patch b/patches/server/Fix-missing-event-call-for-entity-teleport-API.patch similarity index 100% rename from patches/unapplied/server/Fix-missing-event-call-for-entity-teleport-API.patch rename to patches/server/Fix-missing-event-call-for-entity-teleport-API.patch diff --git a/patches/server/Fix-potions-splash-events.patch b/patches/server/Fix-potions-splash-events.patch index 91aa865b38..d9481f9a93 100644 --- a/patches/server/Fix-potions-splash-events.patch +++ b/patches/server/Fix-potions-splash-events.patch @@ -22,10 +22,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (true || potioncontents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply if (this.isLingering()) { - this.makeAreaOfEffectCloud(potioncontents, hitResult); // CraftBukkit - Pass MovingObjectPosition -+ showParticles = this.makeAreaOfEffectCloud(itemstack, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper ++ showParticles = this.makeAreaOfEffectCloud(potioncontents, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper } else { - this.applySplash(potioncontents.getAllEffects(), hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition -+ showParticles = this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper ++ showParticles = this.applySplash(potioncontents.getAllEffects(), hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper } } diff --git a/patches/unapplied/server/Fix-several-issues-with-EntityBreedEvent.patch b/patches/server/Fix-several-issues-with-EntityBreedEvent.patch similarity index 100% rename from patches/unapplied/server/Fix-several-issues-with-EntityBreedEvent.patch rename to patches/server/Fix-several-issues-with-EntityBreedEvent.patch diff --git a/patches/unapplied/server/Fixup-NamespacedKey-handling.patch b/patches/server/Fixup-NamespacedKey-handling.patch similarity index 72% rename from patches/unapplied/server/Fixup-NamespacedKey-handling.patch rename to patches/server/Fixup-NamespacedKey-handling.patch index 9469e9647b..ceedecdc39 100644 --- a/patches/unapplied/server/Fixup-NamespacedKey-handling.patch +++ b/patches/server/Fixup-NamespacedKey-handling.patch @@ -51,29 +51,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java @@ -0,0 +0,0 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { - if (tag.contains(CraftMetaArmor.TRIM.NBT)) { - CompoundTag trimCompound = tag.getCompound(CraftMetaArmor.TRIM.NBT); + super(tag); -- if (trimCompound.contains(CraftMetaArmor.TRIM_MATERIAL.NBT) && trimCompound.contains(CraftMetaArmor.TRIM_PATTERN.NBT)) { -- TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_MATERIAL.NBT))); -- TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_PATTERN.NBT))); -+ // Paper start - Fixup NamedspacedKey handling -+ if (trimCompound.contains(CraftMetaArmor.TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(CraftMetaArmor.TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // TODO Can also be inlined in a compound tag -+ TrimMaterial trimMaterial = registryEntry(Registry.TRIM_MATERIAL, trimCompound.getString(TRIM_MATERIAL.NBT)); -+ TrimPattern trimPattern = registryEntry(Registry.TRIM_PATTERN, trimCompound.getString(TRIM_PATTERN.NBT)); + getOrEmpty(tag, CraftMetaArmor.TRIM).ifPresent((trimCompound) -> { +- TrimMaterial trimMaterial = CraftTrimMaterial.minecraftHolderToBukkit(trimCompound.material()); +- TrimPattern trimPattern = CraftTrimPattern.minecraftHolderToBukkit(trimCompound.pattern()); ++ TrimMaterial trimMaterial = this.unwrapAndConvertHolder(Registry.TRIM_MATERIAL, trimCompound.material()); // Paper - fix upstream not being correct ++ TrimPattern trimPattern = this.unwrapAndConvertHolder(Registry.TRIM_PATTERN, trimCompound.pattern()); // Paper - fix upstream not being correct ++ if (trimMaterial == null || trimPattern == null) return; // Paper - just delete the trim because upstream is not doing this right -- this.trim = new ArmorTrim(trimMaterial, trimPattern); -+ this.trim = trimMaterial != null && trimPattern != null ? new ArmorTrim(trimMaterial, trimPattern) : null; -+ // Paper end - Fixup NamedspacedKey handling + this.trim = new ArmorTrim(trimMaterial, trimPattern); + +@@ -0,0 +0,0 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { } - } + }); } -+ // Paper start - Fixup NamedspacedKey handling -+ private <T extends org.bukkit.Keyed> T registryEntry(final Registry<T> registry, final String value) { -+ final NamespacedKey key = NamespacedKey.fromString(value); -+ return key != null ? registry.get(key) : null; ++ // Paper start - fixup upstream being dum ++ private <T extends org.bukkit.Keyed, M> T unwrapAndConvertHolder(final Registry<T> registry, final net.minecraft.core.Holder<M> value) { ++ return value.unwrap().map(key -> registry.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location())), v -> null); + } -+ // Paper end - Fixup NamedspacedKey handling ++ // Paper end - fixup upstream being dum CraftMetaArmor(Map<String, Object> map) { super(map); @@ -82,17 +79,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java @@ -0,0 +0,0 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst + super(tag); - if (tag.contains(CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT.NBT)) { - String string = tag.getString(CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT.NBT); -- this.instrument = Registry.INSTRUMENT.get(NamespacedKey.fromString(string)); -+ // Paper start - Fixup NamespacedKey handling -+ final NamespacedKey key = NamespacedKey.fromString(string); -+ this.instrument = key != null ? Registry.INSTRUMENT.get(key) : null; -+ // Paper end - Fixup NamespacedKey handling - } + getOrEmpty(tag, CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT).ifPresent((instrument) -> { +- this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(instrument); ++ this.instrument = this.unwrapAndConvertHolder(Registry.INSTRUMENT, instrument); // Paper - fix upstream not handling custom instruments + }); } ++ // Paper start - fixup upstream being dum ++ private <T extends org.bukkit.Keyed, M> T unwrapAndConvertHolder(final Registry<T> registry, final net.minecraft.core.Holder<M> value) { ++ return value.unwrap().map(key -> registry.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location())), v -> null); ++ } ++ // Paper end - fixup upstream being dum + CraftMetaMusicInstrument(Map<String, Object> map) { + super(map); diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java diff --git a/patches/unapplied/server/Improve-Registry.patch b/patches/server/Improve-Registry.patch similarity index 100% rename from patches/unapplied/server/Improve-Registry.patch rename to patches/server/Improve-Registry.patch diff --git a/patches/unapplied/server/Lazily-create-LootContext-for-criterions.patch b/patches/server/Lazily-create-LootContext-for-criterions.patch similarity index 100% rename from patches/unapplied/server/Lazily-create-LootContext-for-criterions.patch rename to patches/server/Lazily-create-LootContext-for-criterions.patch diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index c986637302..fdfe3a7d70 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -37,10 +37,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 PotionContents potioncontents = (PotionContents) itemstack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); @@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie if (this.isLingering()) { - showParticles = this.makeAreaOfEffectCloud(itemstack, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper + showParticles = this.makeAreaOfEffectCloud(potioncontents, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper } else { -- showParticles = this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper -+ showParticles = this.applySplash(list, hitResult != null && hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API +- showParticles = this.applySplash(potioncontents.getAllEffects(), hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper ++ showParticles = this.applySplash(potioncontents.getAllEffects(), hitResult != null && hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API } } diff --git a/patches/unapplied/server/Properly-handle-experience-dropping-on-block-break.patch b/patches/server/Properly-handle-experience-dropping-on-block-break.patch similarity index 100% rename from patches/unapplied/server/Properly-handle-experience-dropping-on-block-break.patch rename to patches/server/Properly-handle-experience-dropping-on-block-break.patch diff --git a/patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch similarity index 100% rename from patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch rename to patches/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch diff --git a/patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch similarity index 98% rename from patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch rename to patches/server/Restore-vanilla-entity-drops-behavior.patch index 8ef1e5e243..baeb345791 100644 --- a/patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -53,7 +53,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Nullable public ItemEntity spawnAtLocation(ItemStack stack, float yOffset) { @@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (stack.isEmpty()) { return null; } else if (this.level().isClientSide) { -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } else { // CraftBukkit start - Capture drops for death event if (this instanceof net.minecraft.world.entity.LivingEntity && !((net.minecraft.world.entity.LivingEntity) this).forceDrops) { @@ -138,9 +138,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { - itemstack.setHoverName(this.getCustomName()); - } + ItemStack itemstack = new ItemStack(Items.ARMOR_STAND); + itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName()); - this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops + this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior return this.brokenByAnything(damageSource); // Paper diff --git a/patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch similarity index 87% rename from patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch rename to patches/server/Validate-ResourceLocation-in-NBT-reading.patch index 8361608729..412e25f0fb 100644 --- a/patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch @@ -75,12 +75,12 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti this.setLeftHanded(nbt.getBoolean("LeftHanded")); if (nbt.contains("DeathLootTable", 8)) { -- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable")); -+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Paper - Validate ResourceLocation +- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("DeathLootTable"))); ++ this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("DeathLootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); } @@ -102,14 +102,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java @@ -0,0 +0,0 @@ public interface ContainerEntity extends Container, MenuProvider { - default void readChestVehicleSaveData(CompoundTag nbt) { + default void readChestVehicleSaveData(CompoundTag nbt, HolderLookup.Provider registriesLookup) { this.clearItemStacks(); if (nbt.contains("LootTable", 8)) { -- this.setLootTable(new ResourceLocation(nbt.getString("LootTable"))); -+ this.setLootTable(ResourceLocation.tryParse(nbt.getString("LootTable"))); // Paper - Validate ResourceLocation +- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("LootTable")))); ++ this.setLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation this.setLootTableSeed(nbt.getLong("LootTableSeed")); } - ContainerHelper.loadAllItems(nbt, this.getItemStacks()); // Paper - always load the items, table may still remain + ContainerHelper.loadAllItems(nbt, this.getItemStacks(), registriesLookup); // Paper - always save the items, table may still remain 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -136,8 +136,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private boolean tryLoadLootTable(CompoundTag nbt) { if (nbt.contains("LootTable", 8)) { -- this.lootTable = new ResourceLocation(nbt.getString("LootTable")); -+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Paper - Validate ResourceLocation +- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("LootTable"))); ++ this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation this.lootTableSeed = nbt.getLong("LootTableSeed"); return true; } else { diff --git a/patches/unapplied/server/add-more-scoreboard-API.patch b/patches/server/add-more-scoreboard-API.patch similarity index 100% rename from patches/unapplied/server/add-more-scoreboard-API.patch rename to patches/server/add-more-scoreboard-API.patch diff --git a/patches/unapplied/server/Add-PlayerShieldDisableEvent.patch b/patches/unapplied/server/Add-PlayerShieldDisableEvent.patch deleted file mode 100644 index 0e4d5cf3d5..0000000000 --- a/patches/unapplied/server/Add-PlayerShieldDisableEvent.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Cryptite <cryptite@gmail.com> -Date: Mon, 1 May 2023 16:22:43 -0500 -Subject: [PATCH] Add PlayerShieldDisableEvent - -Called whenever a players shield is disabled. This is mainly caused by -attacking players or monsters that carry axes. - -The event, while similar to the PlayerItemCooldownEvent, offers other -behaviour and can hence not be implemented as a childtype of said event. -Specifically, cancelling the event prevents the game events from being -sent to the player. - -Plugins listening to just the PlayerItemCooldownEvent may not want said -sideeffects, meaning the disable event cannot share a handlerlist with -the cooldown event - -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting { - float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F; - - if (this.random.nextFloat() < f) { -- player.getCooldowns().addCooldown(Items.SHIELD, 100); -+ // Paper start - Add PlayerShieldDisableEvent -+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitEntity(), 100); -+ if (!shieldDisableEvent.callEvent()) return; -+ player.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown()); -+ // Paper end - Add PlayerShieldDisableEvent - this.level().broadcastEntityEvent(player, (byte) 30); - } - } -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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - protected void blockUsingShield(LivingEntity attacker) { - super.blockUsingShield(attacker); - if (attacker.canDisableShield()) { -- this.disableShield(true); -+ this.disableShield(true, attacker); // Paper - Add PlayerShieldDisableEvent - } - - } -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - this.attack(target); - } - -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerShieldDisableEvent - public void disableShield(boolean sprinting) { -+ // Paper start - Add PlayerShieldDisableEvent -+ disableShield(sprinting, null); -+ } -+ -+ public void disableShield(boolean sprinting, @Nullable LivingEntity attacker) { -+ // Paper end - Add PlayerShieldDisableEvent - float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F; - - if (sprinting) { -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - } - - if (this.random.nextFloat() < f) { -- this.getCooldowns().addCooldown(Items.SHIELD, 100); -+ // Paper start - Add PlayerShieldDisableEvent -+ final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null; -+ if (finalAttacker != null) { -+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100); -+ if (!shieldDisableEvent.callEvent()) return; -+ this.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown()); -+ } else { -+ this.getCooldowns().addCooldown(Items.SHIELD, 100); -+ } -+ // Paper end - Add PlayerShieldDisableEvent - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte) 30); - }