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

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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/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
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- 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 {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- 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 {
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- 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() {
diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
@@ -0,0 +0,0 @@ public class WitherSkeleton extends AbstractSkeleton {
@Override
public boolean canBeAffected(MobEffectInstance effect) {
- 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

@@ -0,0 +1,45 @@
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 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
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 {
this.damage = meta.damage;
this.maxDamage = meta.maxDamage;
this.unhandledTags = meta.unhandledTags;
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); // Paper - deep clone NBT tags
this.customTag = meta.customTag;
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.customTag != null) {
clone.customTag = this.customTag.copy();
}
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
+ 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;
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
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
@@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
}
}
// Paper end - byte array serialization
+
+ // Paper start - deep clone tags
+ public Map<String, Tag> getTagsCloned() {
+ final Map<String, Tag> tags = new HashMap<>();
+ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
+ return tags;
+ }
+ // Paper end - deep clone tags
}

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;
}