From 4047edb1149620241f0c8ea2e2901aebe3b52f31 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 25 Apr 2024 12:27:57 +0200 Subject: [PATCH] Apply and move up non-optimization patches --- a.sh | 9 --- ...ing-message-for-initial-server-start.patch | 4 +- .../Configurable-max-block-fluid-ticks.patch | 0 .../Disable-memory-reserve-allocating.patch | 0 ...eByEntityEvent-for-unowned-wither-sk.patch | 0 .../server/Fix-DamageSource-API.patch | 38 ++++++---- ...invalid-block-entity-during-world-ge.patch | 0 ...tackOverflowError-for-some-dispenses.patch | 5 +- .../server/Improve-tag-parser-handling.patch | 6 +- .../server/Item-Mutation-Fixes.patch | 29 +++----- .../Per-world-ticks-per-spawn-settings.patch | 0 ...he-changed-item-from-dispense-events.patch | 55 ++++++-------- patches/server/Rewrite-chunk-system.patch | 4 +- .../server/Suspicious-Effect-Entry-API.patch | 74 +++---------------- ...heck-if-itemstack-is-stackable-first.patch | 4 +- .../disable-forced-empty-world-ticks.patch | 0 16 files changed, 73 insertions(+), 155 deletions(-) delete mode 100644 a.sh rename patches/{unapplied => }/server/Add-onboarding-message-for-initial-server-start.patch (97%) rename patches/{unapplied => }/server/Configurable-max-block-fluid-ticks.patch (100%) rename patches/{unapplied => }/server/Disable-memory-reserve-allocating.patch (100%) rename patches/{unapplied => }/server/Fire-EntityDamageByEntityEvent-for-unowned-wither-sk.patch (100%) rename patches/{unapplied => }/server/Fix-DamageSource-API.patch (84%) rename patches/{unapplied => }/server/Fix-creation-of-invalid-block-entity-during-world-ge.patch (100%) rename patches/{unapplied => }/server/Fix-possible-StackOverflowError-for-some-dispenses.patch (97%) rename patches/{unapplied => }/server/Improve-tag-parser-handling.patch (97%) rename patches/{unapplied => }/server/Item-Mutation-Fixes.patch (55%) rename patches/{unapplied => }/server/Per-world-ticks-per-spawn-settings.patch (100%) rename patches/{unapplied => }/server/Properly-track-the-changed-item-from-dispense-events.patch (72%) rename patches/{unapplied => }/server/Suspicious-Effect-Entry-API.patch (69%) rename patches/{unapplied => }/server/check-if-itemstack-is-stackable-first.patch (69%) rename patches/{unapplied => }/server/disable-forced-empty-world-ticks.patch (100%) diff --git a/a.sh b/a.sh deleted file mode 100644 index 5e98c3969f..0000000000 --- a/a.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -cd patches/server - - -for file in [0-9][0-9][0-9][0-9]-*.patch; do - suffix=$(echo $file | cut -d'-' -f2-) - mv "$file" "$suffix" -done diff --git a/patches/unapplied/server/Add-onboarding-message-for-initial-server-start.patch b/patches/server/Add-onboarding-message-for-initial-server-start.patch similarity index 97% rename from patches/unapplied/server/Add-onboarding-message-for-initial-server-start.patch rename to patches/server/Add-onboarding-message-for-initial-server-start.patch index 4d15ac80ed..fac8048373 100644 --- a/patches/unapplied/server/Add-onboarding-message-for-initial-server-start.patch +++ b/patches/server/Add-onboarding-message-for-initial-server-start.patch @@ -47,8 +47,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - Add onboarding message for initial server start + while (this.running) { - // Paper start - rewrite chunk system - // guarantee that nothing can stop the server from halting if it can at least still tick + long i; + diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java diff --git a/patches/unapplied/server/Configurable-max-block-fluid-ticks.patch b/patches/server/Configurable-max-block-fluid-ticks.patch similarity index 100% rename from patches/unapplied/server/Configurable-max-block-fluid-ticks.patch rename to patches/server/Configurable-max-block-fluid-ticks.patch diff --git a/patches/unapplied/server/Disable-memory-reserve-allocating.patch b/patches/server/Disable-memory-reserve-allocating.patch similarity index 100% rename from patches/unapplied/server/Disable-memory-reserve-allocating.patch rename to patches/server/Disable-memory-reserve-allocating.patch diff --git a/patches/unapplied/server/Fire-EntityDamageByEntityEvent-for-unowned-wither-sk.patch b/patches/server/Fire-EntityDamageByEntityEvent-for-unowned-wither-sk.patch similarity index 100% rename from patches/unapplied/server/Fire-EntityDamageByEntityEvent-for-unowned-wither-sk.patch rename to patches/server/Fire-EntityDamageByEntityEvent-for-unowned-wither-sk.patch diff --git a/patches/unapplied/server/Fix-DamageSource-API.patch b/patches/server/Fix-DamageSource-API.patch similarity index 84% rename from patches/unapplied/server/Fix-DamageSource-API.patch rename to patches/server/Fix-DamageSource-API.patch index 7034901e28..e9040be07a 100644 --- a/patches/unapplied/server/Fix-DamageSource-API.patch +++ b/patches/server/Fix-DamageSource-API.patch @@ -32,10 +32,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - public DamageSource customCausingEntity(Entity entity) { +- // This method is not intended for change the causing entity if is already set +- // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity +- if (this.customCausingEntity != null || this.directEntity == entity || this.causingEntity == entity) { +- return this; + public DamageSource customEventDamager(Entity entity) { + if (this.directEntity != null) { -+ throw new IllegalStateException("Cannot set a custom event damager entity when a direct entity is already set (report as a bug to Paper)"); -+ } ++ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)"); + } DamageSource damageSource = this.cloneInstance(); - damageSource.customCausingEntity = entity; + damageSource.customEventDamager = entity; @@ -47,7 +51,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 return; } @@ -82,6 +86,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 HangingBreakEvent event; if (damager != null) { event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), source.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); +diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java ++++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java +@@ -0,0 +0,0 @@ public class Creeper extends Monster implements PowerableMob { + if (!event.isCancelled()) { + // CraftBukkit end + this.dead = true; +- this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntity(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit ++ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customEventDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit + this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + this.spawnLingeringCloud(); + // CraftBukkit start diff --git a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java @@ -180,19 +197,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map modifiers, Map> modifierFunctions, boolean cancelled) { CraftDamageSource bukkitDamageSource = new CraftDamageSource(source); -- Entity damager = source.getCausingEntity(); -+ final Entity damager = source.getCustomEventDamager(); // Paper - fix DamageSource API +- Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCausingEntity(); ++ Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCustomEventDamager(); // Paper - fix DamageSource API if (source.is(DamageTypeTags.IS_EXPLOSION)) { if (damager == null) { return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.explodedBlockState); // Paper - Include BlockState for damage -@@ -0,0 +0,0 @@ public class CraftEventFactory { - } else if (damager != null || source.getDirectEntity() != null) { - DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK; - -- if (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) { -- damager = source.getDirectEntity(); -- } -+ // Paper - fix DamageSource API - - if (damager instanceof net.minecraft.world.entity.projectile.Projectile) { - if (damager.getBukkitEntity() instanceof ThrownPotion) { diff --git a/patches/unapplied/server/Fix-creation-of-invalid-block-entity-during-world-ge.patch b/patches/server/Fix-creation-of-invalid-block-entity-during-world-ge.patch similarity index 100% rename from patches/unapplied/server/Fix-creation-of-invalid-block-entity-during-world-ge.patch rename to patches/server/Fix-creation-of-invalid-block-entity-during-world-ge.patch diff --git a/patches/unapplied/server/Fix-possible-StackOverflowError-for-some-dispenses.patch b/patches/server/Fix-possible-StackOverflowError-for-some-dispenses.patch similarity index 97% rename from patches/unapplied/server/Fix-possible-StackOverflowError-for-some-dispenses.patch rename to patches/server/Fix-possible-StackOverflowError-for-some-dispenses.patch index 9125318441..970b709704 100644 --- a/patches/unapplied/server/Fix-possible-StackOverflowError-for-some-dispenses.patch +++ b/patches/server/Fix-possible-StackOverflowError-for-some-dispenses.patch @@ -84,9 +84,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } }; protected final ArmorItem.Type type; -@@ -0,0 +0,0 @@ public class ArmorItem extends Item implements Equipable { - protected final ArmorMaterial material; - private final Multimap defaultModifiers; + protected final Holder material; + private final Supplier defaultModifiers; + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper public static boolean dispenseArmor(BlockSource pointer, ItemStack armor) { diff --git a/patches/unapplied/server/Improve-tag-parser-handling.patch b/patches/server/Improve-tag-parser-handling.patch similarity index 97% rename from patches/unapplied/server/Improve-tag-parser-handling.patch rename to patches/server/Improve-tag-parser-handling.patch index e26914afab..980c3818a2 100644 --- a/patches/unapplied/server/Improve-tag-parser-handling.patch +++ b/patches/server/Improve-tag-parser-handling.patch @@ -58,8 +58,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/nbt/TagParser.java +++ b/src/main/java/net/minecraft/nbt/TagParser.java @@ -0,0 +0,0 @@ public class TagParser { - } }, CompoundTag::toString); + public static final Codec LENIENT_CODEC = Codec.withAlternative(AS_CODEC, CompoundTag.CODEC); private final StringReader reader; + private int depth; // Paper @@ -161,13 +161,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java @@ -0,0 +0,0 @@ public class ServerboundCommandSuggestionPacket implements Packet { - ItemStack itemstack2 = itemstack; + ItemStack itemstack2 = itemstack; // Paper - diff on change - List list = this.getEnchantmentList(itemstack, id, this.costs[id]); + List list = this.getEnchantmentList(world.enabledFeatures(), itemstack, id, this.costs[id]); // CraftBukkit start @@ -0,0 +0,0 @@ public class EnchantmentMenu extends AbstractContainerMenu { return; } // CraftBukkit end -- boolean flag = itemstack.is(Items.BOOK); +- if (itemstack.is(Items.BOOK)) { +- itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK, 1); + // Paper start + itemstack2 = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(item, event.getItem()); + if (itemstack2 != itemstack) { + this.enchantSlots.setItem(0, itemstack2); + } ++ if (itemstack2.is(Items.BOOK)) { ++ itemstack2 = itemstack2.transmuteCopy(Items.ENCHANTED_BOOK, 1); + this.enchantSlots.setItem(0, itemstack2); + } -+ boolean flag = itemstack2.is(Items.BOOK); + // Paper end - if (flag) { -+ CompoundTag nbttagcompound = itemstack2.getTag(); // Paper - move up - itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); -- CompoundTag nbttagcompound = itemstack.getTag(); -+ // Paper - move up - - if (nbttagcompound != null) { - itemstack2.setTag(nbttagcompound.copy()); -@@ -0,0 +0,0 @@ public class EnchantmentMenu extends AbstractContainerMenu { - EnchantmentInstance weightedrandomenchant = new EnchantmentInstance(nms, entry.getValue()); - EnchantedBookItem.addEnchantment(itemstack2, weightedrandomenchant); - } else { -- item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); -+ CraftItemStack.asCraftMirror(itemstack2).addUnsafeEnchantment(entry.getKey(), entry.getValue()); // Paper - } - } catch (IllegalArgumentException e) { - /* Just swallow invalid enchantments */ + // CraftBukkit start + for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { diff --git a/patches/unapplied/server/Per-world-ticks-per-spawn-settings.patch b/patches/server/Per-world-ticks-per-spawn-settings.patch similarity index 100% rename from patches/unapplied/server/Per-world-ticks-per-spawn-settings.patch rename to patches/server/Per-world-ticks-per-spawn-settings.patch diff --git a/patches/unapplied/server/Properly-track-the-changed-item-from-dispense-events.patch b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch similarity index 72% rename from patches/unapplied/server/Properly-track-the-changed-item-from-dispense-events.patch rename to patches/server/Properly-track-the-changed-item-from-dispense-events.patch index 3a9a54d3d3..0b58597ca9 100644 --- a/patches/unapplied/server/Properly-track-the-changed-item-from-dispense-events.patch +++ b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch @@ -4,27 +4,6 @@ Date: Mon, 12 Dec 2022 12:14:03 -0800 Subject: [PATCH] Properly track the changed item from dispense events -diff --git a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -+++ b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -@@ -0,0 +0,0 @@ public abstract class AbstractProjectileDispenseBehavior extends DefaultDispense - ServerLevel worldserver = pointer.level(); - Position iposition = DispenserBlock.getDispensePosition(pointer); - Direction enumdirection = (Direction) pointer.state().getValue(DispenserBlock.FACING); -- Projectile iprojectile = this.getProjectile(worldserver, iposition, stack); -+ // Paper - move down - - // CraftBukkit start - // iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty()); -@@ -0,0 +0,0 @@ public abstract class AbstractProjectileDispenseBehavior extends DefaultDispense - return stack; - } - } -+ Projectile iprojectile = this.getProjectile(worldserver, iposition, CraftItemStack.asNMSCopy(event.getItem())); // Paper - move from above and track changed items in the dispense event - - iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.getUncertainty()); - ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -53,21 +32,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Consumer consumer = EntityType.appendDefaultStackConfig((entityarmorstand) -> { entityarmorstand.setYRot(enumdirection.toYRot()); - }, worldserver, stack, (Player) null); -- ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.spawn(worldserver, stack.getTag(), consumer, blockposition, MobSpawnType.DISPENSER, false, false); + }, worldserver, newStack, (Player) null); // Paper - track changed items in the dispense event -+ ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.spawn(worldserver, newStack.getTag(), consumer, blockposition, MobSpawnType.DISPENSER, false, false); // Paper - track changed items in the dispense event + ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.spawn(worldserver, consumer, blockposition, MobSpawnType.DISPENSER, false, false); if (entityarmorstand != null) { - if (shrink) stack.shrink(1); // Paper - actually handle here -@@ -0,0 +0,0 @@ public interface DispenseItemBehavior { - } - - SmallFireball entitysmallfireball = new SmallFireball(worldserver, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); -- entitysmallfireball.setItem(itemstack1); -+ entitysmallfireball.setItem(CraftItemStack.unwrap(event.getItem())); // Paper - track changed items in the dispense event (unwrap is save cause setItem already copies) - entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); - - worldserver.addFreshEntity(entitysmallfireball); @@ -0,0 +0,0 @@ public interface DispenseItemBehavior { int y = blockposition.getY(); int z = blockposition.getZ(); @@ -94,6 +62,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - Handle stacked buckets Item item = Items.BUCKET; stack.shrink(1); +diff --git a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java ++++ b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +@@ -0,0 +0,0 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { + ServerLevel worldserver = pointer.level(); + Direction enumdirection = (Direction) pointer.state().getValue(DispenserBlock.FACING); + Position iposition = this.dispenseConfig.positionFunction().getDispensePosition(pointer, enumdirection); +- Projectile iprojectile = this.projectileItem.asProjectile(worldserver, iposition, stack, enumdirection); ++ // Paper - move down + + // CraftBukkit start + // this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); +@@ -0,0 +0,0 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { + } + } + ++ Projectile iprojectile = this.projectileItem.asProjectile(worldserver, iposition, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); // Paper - move from above and track changed items in the dispense event + this.projectileItem.shoot(iprojectile, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); + ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); + // CraftBukkit end diff --git a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index bbc4fe42a7..4f36ccf158 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -15795,8 +15795,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { if (!this.initServer()) { @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(); -+ this.getHandle().stewEffects = List.of(recordSuspiciousEffect); -+ } else { -+ this.getHandle().stewEffects = io.papermc.paper.util.MCUtil.copyListAndAdd(this.getHandle().stewEffects, recordSuspiciousEffect); - } -- SuspiciousEffectHolder.EffectEntry recordSuspiciousEffect = new SuspiciousEffectHolder.EffectEntry(minecraftPotionEffect.getEffect(), minecraftPotionEffect.getDuration()); -- this.removeEffectFromNextStew(potionEffect.getType()); // Avoid duplicates of effects -- return this.getHandle().stewEffects.add(recordSuspiciousEffect); -+ // Paper end - fix modification of immutable stew effects list -+ return true; - } -+ // Paper end - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta - - @Override - public boolean removeEffectFromNextStew(PotionEffectType potionEffectType) { -@@ -0,0 +0,0 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm - return false; - } - MobEffect minecraftPotionEffectType = CraftPotionEffectType.bukkitToMinecraft(potionEffectType); -- return this.getHandle().stewEffects.removeIf(recordSuspiciousEffect -> recordSuspiciousEffect.effect().equals(minecraftPotionEffectType)); -+ // Paper start - fix modification of immutable stew effects list -+ if (this.getHandle().stewEffects == null) return false; -+ -+ final int oldSize = this.getHandle().stewEffects.size(); -+ this.getHandle().stewEffects = io.papermc.paper.util.MCUtil.copyListAndRemoveIf( -+ this.getHandle().stewEffects, s -> java.util.Objects.equals(s.effect(), minecraftPotionEffectType) -+ ); -+ -+ final int newSize = this.getHandle().stewEffects.size(); -+ if (newSize == 0) { -+ this.getHandle().stewEffects = null; // Null the empty list, mojang expect this -+ } -+ -+ return oldSize != newSize; // Yield back if the size changed, implying an object was removed. -+ // Paper end - fix modification of immutable stew effects list - } - - @Override + SuspiciousStewEffects stewEffects = this.getHandle().stewEffects; @@ -0,0 +0,0 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm this.getHandle().setVariant(net.minecraft.world.entity.animal.MushroomCow.MushroomType.values()[variant.ordinal()]); } @@ -128,8 +88,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java @@ -0,0 +0,0 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious - static final ItemMetaKey EFFECTS = new ItemMetaKey("effects", "effects"); - static final ItemMetaKey ID = new ItemMetaKey("id", "id"); + + static final ItemMetaKeyType EFFECTS = new ItemMetaKeyType<>(DataComponents.SUSPICIOUS_STEW_EFFECTS, "effects"); - private List customEffects; + private List customEffects; // Paper - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta @@ -137,32 +97,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftMetaSuspiciousStew(CraftMetaItem meta) { super(meta); @@ -0,0 +0,0 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious - duration = net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION; - } - // Paper end start - default duration is 160 -- this.customEffects.add(new PotionEffect(type, duration, 0)); -+ this.customEffects.add(io.papermc.paper.potion.SuspiciousEffectEntry.create(type, duration)); // Paper - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta - } - } - } -@@ -0,0 +0,0 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious - ListTag effectList = new ListTag(); - tag.put(CraftMetaSuspiciousStew.EFFECTS.NBT, effectList); + if (this.customEffects != null) { + List effectList = new ArrayList<>(); - for (PotionEffect effect : this.customEffects) { -+ // Paper start - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta +- effectList.add(new net.minecraft.world.item.component.SuspiciousStewEffects.Entry(CraftPotionEffectType.bukkitToMinecraftHolder(effect.getType()), effect.getDuration())); + for (io.papermc.paper.potion.SuspiciousEffectEntry effect : this.customEffects) { - CompoundTag effectData = new CompoundTag(); -- effectData.putString(CraftMetaSuspiciousStew.ID.NBT, effect.getType().getKey().toString()); -- if (effect.getDuration() != net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION) effectData.putInt(CraftMetaSuspiciousStew.DURATION.NBT, effect.getDuration()); // Paper - don't save duration if it's the default value -+ effectData.putString(CraftMetaSuspiciousStew.ID.NBT, effect.effect().getKey().toString()); -+ if (effect.duration() != net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION) effectData.putInt(CraftMetaSuspiciousStew.DURATION.NBT, effect.duration()); // Paper - don't save duration if it's the default value - effectList.add(effectData); ++ effectList.add(new net.minecraft.world.item.component.SuspiciousStewEffects.Entry(CraftPotionEffectType.bukkitToMinecraftHolder(effect.effect()), effect.duration())); // Paper - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta } -+ // Paper end - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta + tag.put(CraftMetaSuspiciousStew.EFFECTS, new SuspiciousStewEffects(effectList)); } - } - @@ -0,0 +0,0 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious @Override public List getCustomEffects() { diff --git a/patches/unapplied/server/check-if-itemstack-is-stackable-first.patch b/patches/server/check-if-itemstack-is-stackable-first.patch similarity index 69% rename from patches/unapplied/server/check-if-itemstack-is-stackable-first.patch rename to patches/server/check-if-itemstack-is-stackable-first.patch index af78578433..32aae919e5 100644 --- a/patches/unapplied/server/check-if-itemstack-is-stackable-first.patch +++ b/patches/server/check-if-itemstack-is-stackable-first.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } private boolean hasRemainingSpaceForItem(ItemStack existingStack, ItemStack stack) { -- return !existingStack.isEmpty() && ItemStack.isSameItemSameTags(existingStack, stack) && existingStack.isStackable() && existingStack.getCount() < existingStack.getMaxStackSize() && existingStack.getCount() < this.getMaxStackSize(); -+ return !existingStack.isEmpty() && existingStack.isStackable() && existingStack.getCount() < existingStack.getMaxStackSize() && existingStack.getCount() < this.getMaxStackSize() && ItemStack.isSameItemSameTags(existingStack, stack); // Paper - check if itemstack is stackable first +- return !existingStack.isEmpty() && ItemStack.isSameItemSameComponents(existingStack, stack) && existingStack.isStackable() && existingStack.getCount() < this.getMaxStackSize(existingStack); ++ return !existingStack.isEmpty() && existingStack.isStackable() && existingStack.getCount() < this.getMaxStackSize(existingStack) && ItemStack.isSameItemSameComponents(existingStack, stack); // Paper - check if itemstack is stackable first } // CraftBukkit start - Watch method above! :D diff --git a/patches/unapplied/server/disable-forced-empty-world-ticks.patch b/patches/server/disable-forced-empty-world-ticks.patch similarity index 100% rename from patches/unapplied/server/disable-forced-empty-world-ticks.patch rename to patches/server/disable-forced-empty-world-ticks.patch