Apply and move up non-optimization patches

This commit is contained in:
Nassim Jahnke 2024-04-25 12:27:57 +02:00
parent 02eec3bcd0
commit 4047edb114
16 changed files with 73 additions and 155 deletions

9
a.sh
View File

@ -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

View File

@ -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

View File

@ -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<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> 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) {

View File

@ -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<Attribute, AttributeModifier> defaultModifiers;
protected final Holder<ArmorMaterial> material;
private final Supplier<ItemAttributeModifiers> defaultModifiers;
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper
public static boolean dispenseArmor(BlockSource pointer, ItemStack armor) {

View File

@ -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<CompoundTag> 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<ServerGamePack
public ServerboundCommandSuggestionPacket(FriendlyByteBuf buf) {
private ServerboundCommandSuggestionPacket(FriendlyByteBuf buf) {
this.id = buf.readVarInt();
- this.command = buf.readUtf(32500);
+ this.command = buf.readUtf(2048); // Paper
}
@Override
private void write(FriendlyByteBuf buf) {
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java

View File

@ -14,36 +14,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.access.execute((world, blockposition) -> {
- ItemStack itemstack2 = itemstack;
+ ItemStack itemstack2 = itemstack; // Paper - diff on change
List<EnchantmentInstance> list = this.getEnchantmentList(itemstack, id, this.costs[id]);
List<EnchantmentInstance> 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<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {

View File

@ -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<ArmorStand> 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

View File

@ -15795,8 +15795,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
try {
if (!this.initServer()) {
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
long currentTime;
// Paper end - further improve server tick loop
// 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

View File

@ -34,51 +34,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public boolean addEffectToNextStew(io.papermc.paper.potion.SuspiciousEffectEntry suspiciousEffectEntry, boolean overwrite) {
+ Preconditions.checkArgument(suspiciousEffectEntry != null, "SuspiciousEffectEntry cannot be null");
+ MobEffect minecraftPotionEffect = CraftPotionEffectType.bukkitToMinecraft(suspiciousEffectEntry.effect());
+ // Paper end - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta
+ if (!overwrite && this.hasEffectForNextStew(suspiciousEffectEntry.effect())) {
return false;
}
+ SuspiciousEffectHolder.EffectEntry recordSuspiciousEffect = new SuspiciousEffectHolder.EffectEntry(minecraftPotionEffect, suspiciousEffectEntry.duration());
+ this.removeEffectFromNextStew(suspiciousEffectEntry.effect()); // Avoid duplicates of effects
+ // Paper start - fix modification of immutable stew effects list
if (this.getHandle().stewEffects == null) {
- this.getHandle().stewEffects = new ArrayList<>();
+ 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<SuspiciousStewEffects> EFFECTS = new ItemMetaKeyType<>(DataComponents.SUSPICIOUS_STEW_EFFECTS, "effects");
- private List<PotionEffect> customEffects;
+ private List<io.papermc.paper.potion.SuspiciousEffectEntry> 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<SuspiciousStewEffects.Entry> 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<PotionEffect> getCustomEffects() {

View File

@ -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