remove no longer needed patches and fix tests

This commit is contained in:
Jake Potrebic 2024-04-26 14:29:16 -07:00
parent 6bfa9ce2b1
commit 15221cd4ac
16 changed files with 159 additions and 315 deletions

View File

@ -143,6 +143,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ BEE_GROWTH(2011, Type.VISUAL, Integer.class),
+
+ /**
+ * {@link Integer} param is the number of particles
+ */
+ TURTLE_EGG_PLACEMENT(2012, Type.VISUAL, Integer.class),
+
+ /**
+ * {@link Integer} param is relative to the number of particles
+ */
+ SMASH_ATTACK(2013, Type.VISUAL, Integer.class),
+
+ PARTICLES_SCULK_CHARGE(3006, Type.VISUAL, Integer.class),
+
+ PARTICLES_SCULK_SHRIEK(3007, Type.SOUND),
@ -154,9 +164,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated(forRemoval = true, since = "1.20.5")
+ GUST_DUST(3010, Type.VISUAL),
+
+ TRIAL_SPAWNER_SPAWN(3011, Type.VISUAL),
+ /**
+ * {@link Boolean} param is true for "ominous" vaults
+ */
+ TRIAL_SPAWNER_SPAWN(3011, Type.VISUAL, Boolean.class),
+
+ TRIAL_SPAWNER_SPAWN_MOB_AT(3012, Type.VISUAL),
+ /**
+ * {@link Boolean} param is true for "ominous" vaults
+ */
+ TRIAL_SPAWNER_SPAWN_MOB_AT(3012, Type.VISUAL, Boolean.class),
+
+ /**
+ * {@link Integer} param is the number of players
@ -164,6 +180,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ TRIAL_SPAWNER_DETECT_PLAYER(3013, Type.VISUAL, Integer.class),
+
+ TRIAL_SPAWNER_EJECT_ITEM(3014, Type.VISUAL),
+
+ /**
+ * {@link Boolean} param is true for "ominous" vaults
+ */
+ VAULT_ACTIVATE(3015, Type.VISUAL, Boolean.class),
+
+ /**
+ * {@link Boolean} param is true for "ominous" vaults
+ */
+ VAULT_DEACTIVATE(3016, Type.VISUAL, Boolean.class),
+
+ VAULT_EJECT_ITEM(3017, Type.VISUAL),
+
+ SPAWN_COBWEB(3018, Type.VISUAL),
+
+ /**
+ * {@link Integer} param is the number of players
+ */
+ TRIAL_SPAWNER_DETECT_PLAYER_OMINOUS(3019, Type.VISUAL, Integer.class),
+
+ /**
+ * {@link Boolean} param is true for changing to "ominous"
+ */
+ TRIAL_SPAWNER_BECOME_OMINOUS(3020, Type.VISUAL, Boolean.class),
+
+ /**
+ * {@link Boolean} param is true for "ominous" vaults
+ */
+ TRIAL_SPAWNER_SPAWN_ITEM(3021, Type.VISUAL, Boolean.class)
;
+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
+ // Paper end
@ -205,17 +250,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public Class<?> getData() {
- return this.data;
+ return this.data == null ? null : this.data.get(0); // Paper
+ }
+
}
+ // Paper start - support deprecated data types
+ @org.jetbrains.annotations.ApiStatus.Internal
+ public boolean isApplicable(Object obj) {
+ return this.data != null && com.google.common.collect.Iterables.any(this.data, aClass -> aClass.isAssignableFrom(obj.getClass()));
}
+ }
+ // Paper end - support deprecated data types
+
/**
* Gets the Effect associated with the given ID.
*
@@ -0,0 +0,0 @@ public enum Effect {
static {

View File

@ -30,6 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>Shulker box contents</li>
+ * <li>Spawner descriptions</li>
+ * </ul>
+ * @deprecated use {@link #HIDE_ADDITIONAL_TOOLTIP}
+ */
+ @Deprecated
+ public static final ItemFlag HIDE_ITEM_SPECIFICS = HIDE_ADDITIONAL_TOOLTIP;

View File

@ -4,19 +4,6 @@ Date: Wed, 2 Dec 2020 21:03:02 -0800
Subject: [PATCH] Add config for mobs immune to default effects
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (this.getMobType() == MobType.UNDEAD) {
MobEffect mobeffectlist = effect.getEffect();
- if (mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) {
+ if ((mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) && this.level().paperConfig().entities.mobEffects.undeadImmuneToCertainEffects) { // Paper - Add config for mobs immune to default effects
return false;
}
}
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@ -25,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
+ return effect.getEffect() == MobEffects.WITHER && this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.wither ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
- return effect.is(MobEffects.WITHER) ? false : super.canBeAffected(effect);
+ return effect.is(MobEffects.WITHER) && this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.wither ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
}
private class WitherDoNothingGoal extends Goal {
@ -38,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
+ return effect.getEffect() == MobEffects.POISON && this.level().paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
- return effect.is(MobEffects.POISON) ? false : super.canBeAffected(effect);
+ return effect.is(MobEffects.POISON) && this.level().paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
}
public boolean isClimbing() {
@ -51,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
+ return effect.getEffect() == MobEffects.WITHER && this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
- return effect.is(MobEffects.WITHER) ? false : super.canBeAffected(effect);
+ return effect.is(MobEffects.WITHER) && this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
}
}

View File

@ -16,9 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static <T> int getDataValue(Effect effect, T data) {
int datavalue;
switch (effect) {
+ case PARTICLES_SCULK_CHARGE: // Paper - add missing effects
+ case TRIAL_SPAWNER_DETECT_PLAYER: // Paper - add missing effects
+ case BEE_GROWTH: // Paper - add missing effects
+ // Paper start - add missing effects
+ case PARTICLES_SCULK_CHARGE:
+ case TRIAL_SPAWNER_DETECT_PLAYER:
+ case BEE_GROWTH:
+ case TURTLE_EGG_PLACEMENT:
+ case SMASH_ATTACK:
+ case TRIAL_SPAWNER_DETECT_PLAYER_OMINOUS:
+ // Paper end - add missing effects
case VILLAGER_PLANT_GROW:
datavalue = (Integer) data;
break;
@ -51,7 +56,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
break;
case COMPOSTER_FILL_ATTEMPT:
+ // Paper start - add missing effects
+ case TRIAL_SPAWNER_SPAWN:
+ case TRIAL_SPAWNER_SPAWN_MOB_AT:
+ case VAULT_ACTIVATE:
+ case VAULT_DEACTIVATE:
+ case TRIAL_SPAWNER_BECOME_OMINOUS:
+ case TRIAL_SPAWNER_SPAWN_ITEM:
+ // Paper end - add missing effects
datavalue = ((Boolean) data) ? 1 : 0;
break;
case BONE_MEAL_USE:
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java

View File

@ -120,6 +120,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.acceptsAll(Main.asList("nogui"), "Disables the graphical console");
this.acceptsAll(Main.asList("nojline"), "Disables jline and emulates the vanilla console");
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
@@ -0,0 +0,0 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
@Override
public int getMapId() {
+ Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
return this.mapId;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java

View File

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: SoSeDiK <mrsosedik@gmail.com>
Date: Thu, 26 May 2022 03:30:05 +0300
Subject: [PATCH] Deep clone unhandled nbt tags
Subject: [PATCH] Deep clone nbt tags in PDC
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@ -9,40 +9,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
private CompoundTag internalTag;
- final Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper
+ Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper - Deep clone unhandled nbt tags; remove final
private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY);
private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.destroyableKeys = new java.util.HashSet<>(meta.destroyableKeys);
}
// Paper end - Add API for CanPlaceOn and CanDestroy NBT values
- this.unhandledTags.putAll(meta.unhandledTags);
this.damage = meta.damage;
this.maxDamage = meta.maxDamage;
this.unhandledTags = meta.unhandledTags;
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
+ // Paper start - Deep clone unhandled nbt tags
+ meta.unhandledTags.forEach((key, tag) -> this.unhandledTags.put(key, tag.copy()));
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned());
+ // Paper end - Deep clone unhandled nbt tags
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); // Paper - deep clone NBT tags
this.customTag = meta.customTag;
this.internalTag = meta.internalTag;
if (this.internalTag != null) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.hasAttributeModifiers()) {
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
if (this.customTag != null) {
clone.customTag = this.customTag.copy();
}
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
+ // Paper start - Deep clone unhandled nbt tags
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY);
+ clone.unhandledTags = new TreeMap<>(this.unhandledTags);
+ clone.unhandledTags.replaceAll((key, tag) -> tag.copy());
+ // Paper end - Deep clone unhandled nbt tags
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY); // Paper - deep clone NBT tags
clone.hideFlag = this.hideFlag;
clone.hideTooltip = this.hideTooltip;
clone.unbreakable = this.unbreakable;
clone.damage = this.damage;
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java

View File

@ -646,8 +646,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public boolean performUsernameValidation = true;
+ @Comment("This setting controls if players should be able to create headless pistons.")
+ public boolean allowHeadlessPistons = false;
+ @Comment("This setting controls if grindstones should be able to output overstacked items (such as cursed books).")
+ public boolean allowGrindstoneOverstacking = false;
+ @Comment("This setting controls what compression format is used for region files.")
+ public CompressionFormat compressionFormat = CompressionFormat.ZLIB;
+
@ -1367,7 +1365,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ path("tnt-explosion-volume"),
+ path("entities", "spawning", "despawn-ranges", "soft"),
+ path("entities", "spawning", "despawn-ranges", "hard"),
+ path("fixes", "fix-curing-zombie-villager-discount-exploit")
+ path("fixes", "fix-curing-zombie-villager-discount-exploit"),
+ path("entities", "mob-effects", "undead-immune-to-certain-effects")
+ };
+
+ NodePath[] REMOVED_GLOBAL_PATHS = {
@ -1388,7 +1387,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ path("baby-zombie-movement-speed"),
+ path("limit-player-interactions"),
+ path("warnWhenSettingExcessiveVelocity"),
+ path("logging", "use-rgb-for-named-text-colors")
+ path("logging", "use-rgb-for-named-text-colors"),
+ path("unsupported-settings", "allow-grindstone-overstacking")
+ };
+
+}
@ -1539,7 +1539,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public MobEffects mobEffects;
+
+ public class MobEffects extends ConfigurationPart {
+ public boolean undeadImmuneToCertainEffects = true;
+ public boolean spidersImmuneToPoisonEffect = true;
+ public ImmuneToWitherEffect immuneToWitherEffect;
+

View File

@ -141,46 +141,55 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- int index = this.indexOfEffect(effect.getType());
- if (index != -1) {
- if (overwrite) {
- PotionEffect old = this.customEffects.get(index);
- if (old.getDuration() == effect.getDuration()) {
+ // Paper start - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta
+ @Override
+ public boolean addCustomEffect(final io.papermc.paper.potion.SuspiciousEffectEntry suspiciousEffectEntry, final boolean overwrite) {
+ Preconditions.checkArgument(suspiciousEffectEntry != null, "Suspicious effect entry cannot be null");
+ final List<io.papermc.paper.potion.SuspiciousEffectEntry> matchingEffects = this.customEffects.stream().filter(
+ entry -> entry.effect() == suspiciousEffectEntry.effect()
+ ).toList();
+ if (!matchingEffects.isEmpty()) {
if (overwrite) {
- PotionEffect old = this.customEffects.get(index);
- if (old.getDuration() == effect.getDuration()) {
+ boolean foundMatchingDuration = false;
+ boolean mutated = false;
+ for (final io.papermc.paper.potion.SuspiciousEffectEntry matchingEffect : matchingEffects) {
+ if (matchingEffect.duration() != suspiciousEffectEntry.duration()) {
+ this.customEffects.remove(suspiciousEffectEntry);
+ mutated = true;
+ } else {
+ foundMatchingDuration = true;
+ if (this.hasCustomEffects()) {
+ final List<io.papermc.paper.potion.SuspiciousEffectEntry> matchingEffects = this.customEffects.stream().filter(
+ entry -> entry.effect() == suspiciousEffectEntry.effect()
+ ).toList();
+ if (!matchingEffects.isEmpty()) {
+ if (overwrite) {
+ boolean foundMatchingDuration = false;
+ boolean mutated = false;
+ for (final io.papermc.paper.potion.SuspiciousEffectEntry matchingEffect : matchingEffects) {
+ if (matchingEffect.duration() != suspiciousEffectEntry.duration()) {
+ this.customEffects.remove(suspiciousEffectEntry);
+ mutated = true;
+ } else {
+ foundMatchingDuration = true;
+ }
+ }
+ }
+ if (foundMatchingDuration && !mutated) {
+ if (foundMatchingDuration && !mutated) {
+ return false;
+ } else if (!foundMatchingDuration) {
+ this.customEffects.add(suspiciousEffectEntry);
+ }
+ return true;
+ } else {
return false;
+ } else if (!foundMatchingDuration) {
+ this.customEffects.add(suspiciousEffectEntry);
}
- this.customEffects.set(index, effect);
return true;
- return true;
- } else {
+ } else {
return false;
}
} else {
if (this.customEffects == null) {
this.customEffects = new ArrayList<>();
- return false;
}
- } else {
- if (this.customEffects == null) {
- this.customEffects = new ArrayList<>();
- }
- this.customEffects.add(effect);
+ this.customEffects.add(suspiciousEffectEntry);
return true;
- return true;
}
+ if (this.customEffects == null) {
+ this.customEffects = new ArrayList<>();
+ }
+ this.customEffects.add(suspiciousEffectEntry);
+ return true;
}
+ // Paper end - add overloads to use suspicious effect entry to mushroom cow and suspicious stew meta

View File

@ -8,6 +8,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
for (Object hideFlagObject : hideFlags) {
String hideFlagString = (String) hideFlagObject;
try {
- ItemFlag hideFlatEnum = ItemFlag.valueOf(hideFlagString);
+ ItemFlag hideFlatEnum = ItemFlag.valueOf(org.bukkit.craftbukkit.legacy.FieldRename.convertItemFlagName(org.bukkit.craftbukkit.util.ApiVersion.CURRENT, hideFlagString)); // Paper - handle old field names
this.addItemFlags(hideFlatEnum);
} catch (IllegalArgumentException ex) {
// Ignore when we got a old String which does not map to a Enum value anymore
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
enchantKey = "SWEEPING_EDGE";
}
@ -17,16 +26,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if ((enchantment != null) && (entry.getValue() instanceof Integer)) {
enchantments.put(enchantment, (Integer) entry.getValue());
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java
@@ -0,0 +0,0 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
String entityType = SerializableMeta.getString(map, CraftMetaSpawnEgg.ENTITY_ID.BUKKIT, true);
if (entityType != null) {
- this.spawnedType = EntityType.fromName(entityType);
+ this.spawnedType = EntityType.fromName(org.bukkit.craftbukkit.legacy.FieldRename.convertEntityTypeName(org.bukkit.craftbukkit.util.ApiVersion.CURRENT, entityType)); // Paper - handle old entity type field names
}
}
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
continue;
}
AttributeModifier modifier = (AttributeModifier) o;
- Attribute attribute = EnumUtils.getEnum(Attribute.class, attributeName.toUpperCase(Locale.ROOT));
+ Attribute attribute = EnumUtils.getEnum(Attribute.class, org.bukkit.craftbukkit.legacy.FieldRename.convertAttributeName(org.bukkit.craftbukkit.util.ApiVersion.CURRENT, attributeName.toUpperCase(Locale.ROOT))); // Paper - handle old field names
if (attribute == null) {
continue;
}

View File

@ -1,26 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Tue, 16 Feb 2021 21:37:51 -0600
Subject: [PATCH] Prevent grindstones from overstacking items
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
@@ -0,0 +0,0 @@ public class GrindstoneMenu extends AbstractContainerMenu {
i = Math.max(item.getMaxDamage() - l, 0);
itemstack2 = this.mergeEnchants(itemstack, itemstack1);
if (!itemstack2.isDamageableItem()) {
- if (!ItemStack.matches(itemstack, itemstack1)) {
+ if (!ItemStack.matches(itemstack, itemstack1) || (itemstack2.getMaxStackSize() == 1 && !io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking)) { // Paper - add max stack size check & config value
org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareGrindstoneEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
this.broadcastChanges();
return;
}
- b0 = 2;
+ b0 = 2; // Paper - add max stack size check & config value; the problem line for above change, causing over-stacking
}
} else {
boolean flag3 = !itemstack.isEmpty();

View File

@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 1 Aug 2021 09:49:06 +0100
Subject: [PATCH] Fix incosistency issue with empty map items in CB
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/MapItem.java
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
@@ -0,0 +0,0 @@ public class MapItem extends ComplexItem {
public static Integer getMapId(ItemStack stack) {
CompoundTag nbttagcompound = stack.getTag();
- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
+ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; // CraftBukkit - make new maps for no tag // Paper - don't return invalid ID
}
public static int createNewSavedData(Level world, int x, int z, int scale, boolean showIcons, boolean unlimitedTracking, ResourceKey<Level> dimension) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
@@ -0,0 +0,0 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
@Override
public int getMapId() {
+ Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
return this.mapId;
}

View File

@ -1,35 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Mon, 18 Dec 2023 20:05:50 -0800
Subject: [PATCH] properly read and store sus effect duration
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- 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
if (type == null) {
continue;
}
- int duration = effect.getInt(CraftMetaSuspiciousStew.DURATION.NBT);
+ // Paper start - default duration is 160
+ final int duration;
+ if (effect.contains(CraftMetaSuspiciousStew.DURATION.NBT)) {
+ duration = effect.getInt(CraftMetaSuspiciousStew.DURATION.NBT);
+ } else {
+ duration = net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION;
+ }
+ // Paper end start - default duration is 160
this.customEffects.add(new PotionEffect(type, duration, 0));
}
}
@@ -0,0 +0,0 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious
for (PotionEffect effect : this.customEffects) {
CompoundTag effectData = new CompoundTag();
effectData.putString(CraftMetaSuspiciousStew.ID.NBT, effect.getType().getKey().toString());
- effectData.putInt(CraftMetaSuspiciousStew.DURATION.NBT, effect.getDuration());
+ 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
effectList.add(effectData);
}
}

View File

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 23 Jun 2022 19:25:51 -0700
Subject: [PATCH] Track projectile source for fireworks from dispensers
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
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
Vec3 vec3d = DispenseItemBehavior.getEntityPokingOutOfBlockPos(pointer, EntityType.FIREWORK_ROCKET, enumdirection);
FireworkRocketEntity entityfireworks = new FireworkRocketEntity(pointer.level(), itemstack1, vec3d.x(), vec3d.y(), vec3d.z(), true); // Paper - GH-2871 - fix last firework in stack having no effects when dispensed
+ entityfireworks.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity()); // Paper - Track projectile source for fireworks from dispensers
entityfireworks.shoot((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), 0.5F, 1.0F);
pointer.level().addFreshEntity(entityfireworks);

View File

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 15 May 2023 00:20:59 -0700
Subject: [PATCH] Fix concurrenct access to lookups field in RegistryOps
The concurrent access occurs on the Netty IO threads when
serializing packets. Thus, it seems it was an oversight of
the implementator of this function as there are typically
more than one Netty IO thread.
Fixes https://github.com/PaperMC/Folia/issues/11
diff --git a/src/main/java/net/minecraft/resources/RegistryOps.java b/src/main/java/net/minecraft/resources/RegistryOps.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/resources/RegistryOps.java
+++ b/src/main/java/net/minecraft/resources/RegistryOps.java
@@ -0,0 +0,0 @@ public class RegistryOps<T> extends DelegatingOps<T> {
private static RegistryOps.RegistryInfoLookup memoizeLookup(RegistryOps.RegistryInfoLookup registryInfoGetter) {
return new RegistryOps.RegistryInfoLookup() {
- private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new HashMap<>();
+ // The concurrent access occurs on the Netty IO threads when serializing packets.
+ // Thus, it seems it was an oversight of the implementator of this function as there
+ // are typically more than one Netty IO thread.
+ private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - fix concurrent access to lookups field
@Override
public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) {

View File

@ -1,56 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jellysquid3 <jellysquid3@users.noreply.github.com>
Date: Sat, 8 Jul 2023 21:38:05 +0200
Subject: [PATCH] Array backed synched entity data
Original code by jellysquid3 in Lithium, licensed under the GNU Lesser General Public License v3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
@@ -0,0 +0,0 @@ public class SynchedEntityData {
private final Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = new Int2ObjectOpenHashMap();
// private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required
private boolean isDirty;
+ // Paper start - Perf: array backed synched entity data
+ private static final int DEFAULT_ENTRY_COUNT = 10;
+ private static final int GROW_FACTOR = 8;
+ private SynchedEntityData.DataItem<?>[] itemsArray = new SynchedEntityData.DataItem<?>[DEFAULT_ENTRY_COUNT];
+ // Paper end - Perf: array backed synched entity data
public SynchedEntityData(Entity trackedEntity) {
this.entity = trackedEntity;
@@ -0,0 +0,0 @@ public class SynchedEntityData {
// this.lock.writeLock().lock(); // Spigot - not required
this.itemsById.put(key.getId(), datawatcher_item);
// this.lock.writeLock().unlock(); // Spigot - not required
+ // Paper start - Perf: array backed synched entity data
+ if (this.itemsArray.length <= key.getId()) {
+ final int newSize = Math.min(key.getId() + GROW_FACTOR, MAX_ID_VALUE);
+
+ this.itemsArray = java.util.Arrays.copyOf(this.itemsArray, newSize);
+ }
+
+ this.itemsArray[key.getId()] = datawatcher_item;
+ // Paper end - Perf: array backed synched entity data
}
public <T> boolean hasItem(EntityDataAccessor<T> key) {
@@ -0,0 +0,0 @@ public class SynchedEntityData {
return datawatcher_item;
*/
- return (SynchedEntityData.DataItem) this.itemsById.get(key.getId());
+ // Paper start - Perf: array backed synched entity data
+ final int id = key.getId();
+
+ if (id < 0 || id >= this.itemsArray.length) {
+ return null;
+ }
+
+ return (DataItem<T>) this.itemsArray[id];
+ // Paper end - Perf: array backed synched entity data
// Spigot end
}

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 10 Oct 2023 10:17:43 -0700
Subject: [PATCH] Use correct variable for initializing CraftLootTable
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
@@ -0,0 +0,0 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv
});
// CraftBukkit start
map1.forEach((key, lootTable) -> {
- if (object instanceof LootTable table) {
+ if (lootTable instanceof LootTable table) { // Paper - Use correct variable for initializing CraftLootTable
table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table);
}
});