mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
committed by
GitHub
parent
d43289ce14
commit
d12a88e1de
@@ -5,7 +5,7 @@ Subject: [PATCH] Potion NamespacedKey
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
|
||||
index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c0d27a862 100644
|
||||
index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..3aecf016ce182391e20c8d31b9399a9855ceb3e6 100644
|
||||
--- a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
|
||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.util.ExtraCodecs;
|
||||
@@ -24,23 +24,33 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
private MobEffectInstance hiddenEffect;
|
||||
private Optional<MobEffectInstance.FactorData> factorData;
|
||||
|
||||
@@ -48,12 +50,27 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -43,17 +45,36 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
this(type, duration, amplifier, ambient, visible, visible);
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean visible, @Nullable NamespacedKey key) {
|
||||
+ this(type, duration, amplifier, ambient, visible, visible, key);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon) {
|
||||
- this(type, duration, amplifier, ambient, showParticles, showIcon, (MobEffectInstance)null, type.createFactorData());
|
||||
+ // Purpur start
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showIcon, (MobEffectInstance)null, type.createFactorData(), (NamespacedKey)null);
|
||||
+ }
|
||||
+
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, @Nullable NamespacedKey key) {
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showIcon, (MobEffectInstance)null, type.createFactorData(), key);
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, @Nullable MobEffectInstance hiddenEffect, Optional<MobEffectInstance.FactorData> factorCalculationData) {
|
||||
+ // Purpur start
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showIcon, (NamespacedKey)null, hiddenEffect, factorCalculationData);
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showIcon, hiddenEffect, factorCalculationData, (NamespacedKey) null);
|
||||
+ }
|
||||
+
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, @Nullable NamespacedKey key, Optional<MobEffectInstance.FactorData> factorCalculationData) {
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showParticles, key, (MobEffectInstance)null, factorCalculationData);
|
||||
+ }
|
||||
+
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, @Nullable NamespacedKey key, Optional<MobEffectInstance.FactorData> factorCalculationData) {
|
||||
+ this(type, duration, amplifier, ambient, showParticles, showIcon, key, (MobEffectInstance)null, factorCalculationData);
|
||||
+ }
|
||||
+
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, @Nullable NamespacedKey key, @Nullable MobEffectInstance hiddenEffect, Optional<MobEffectInstance.FactorData> factorCalculationData) { // Purpur - add key
|
||||
+ public MobEffectInstance(MobEffect type, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, @Nullable MobEffectInstance hiddenEffect, Optional<MobEffectInstance.FactorData> factorCalculationData, @Nullable NamespacedKey key) {
|
||||
+ // Purpur end
|
||||
this.effect = type;
|
||||
this.duration = duration;
|
||||
@@ -52,7 +62,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
this.hiddenEffect = hiddenEffect;
|
||||
this.factorData = factorCalculationData;
|
||||
}
|
||||
@@ -74,6 +91,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -74,6 +95,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
this.ambient = that.ambient;
|
||||
this.visible = that.visible;
|
||||
this.showIcon = that.showIcon;
|
||||
@@ -60,7 +70,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
}
|
||||
|
||||
public boolean update(MobEffectInstance that) {
|
||||
@@ -126,6 +144,13 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -126,6 +148,13 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
bl = true;
|
||||
}
|
||||
|
||||
@@ -74,7 +84,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
return bl;
|
||||
}
|
||||
|
||||
@@ -153,6 +178,17 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -153,6 +182,17 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
return this.showIcon;
|
||||
}
|
||||
|
||||
@@ -92,7 +102,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
public boolean tick(LivingEntity entity, Runnable overwriteCallback) {
|
||||
if (this.duration > 0) {
|
||||
if (this.effect.isDurationEffectTick(this.duration, this.amplifier)) {
|
||||
@@ -209,6 +245,12 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -209,6 +249,12 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
string = string + ", Show Icon: false";
|
||||
}
|
||||
|
||||
@@ -105,7 +115,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -220,7 +262,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -220,7 +266,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
return false;
|
||||
} else {
|
||||
MobEffectInstance mobEffectInstance = (MobEffectInstance)object;
|
||||
@@ -114,7 +124,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,6 +286,11 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -244,6 +290,11 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
nbt.putBoolean("Ambient", this.isAmbient());
|
||||
nbt.putBoolean("ShowParticles", this.isVisible());
|
||||
nbt.putBoolean("ShowIcon", this.showIcon());
|
||||
@@ -126,7 +136,7 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
if (this.hiddenEffect != null) {
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
this.hiddenEffect.save(compoundTag);
|
||||
@@ -278,6 +325,13 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -278,6 +329,13 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
bl3 = nbt.getBoolean("ShowIcon");
|
||||
}
|
||||
|
||||
@@ -140,17 +150,17 @@ index f5c9be3fde2654bd5a6b3ee737afe96a9393e836..64571396652d4447ce3665cd8cef668c
|
||||
MobEffectInstance mobEffectInstance = null;
|
||||
if (nbt.contains("HiddenEffect", 10)) {
|
||||
mobEffectInstance = loadSpecifiedEffect(type, nbt.getCompound("HiddenEffect"));
|
||||
@@ -290,7 +344,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
@@ -290,7 +348,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
|
||||
optional = Optional.empty();
|
||||
}
|
||||
|
||||
- return new MobEffectInstance(type, j, Math.max(i, 0), bl, bl2, bl3, mobEffectInstance, optional);
|
||||
+ return new MobEffectInstance(type, j, Math.max(i, 0), bl, bl2, bl3, key, mobEffectInstance, optional); // Purpur - add key
|
||||
+ return new MobEffectInstance(type, j, Math.max(i, 0), bl, bl2, bl3, mobEffectInstance, optional, key); // Purpur - add key
|
||||
}
|
||||
|
||||
public void setNoCounter(boolean permanent) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index f2d17cb06fbcd7370ab8465c5c4830f8ba31169a..d726575f8df0176f2ee0b19d224d49d9ee3f248f 100644
|
||||
index f2d17cb06fbcd7370ab8465c5c4830f8ba31169a..3a3476000ee8c13e1c1a565b0ef38a5ac69bdfb3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -438,7 +438,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
@@ -158,7 +168,7 @@ index f2d17cb06fbcd7370ab8465c5c4830f8ba31169a..d726575f8df0176f2ee0b19d224d49d9
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
||||
- this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon
|
||||
+ this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon(), effect.getKey(), java.util.Optional.empty()), EntityPotionEffectEvent.Cause.PLUGIN); // Purpur - add key // Paper - Don't ignore icon
|
||||
+ this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon(), effect.getKey()), EntityPotionEffectEvent.Cause.PLUGIN); // Purpur - add key // Paper - Don't ignore icon
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -237,7 +247,7 @@ index 298326115f048bb79e3c949861c187134eb5efb8..9b060070ddbbade4c1b6830b9b861f46
|
||||
}
|
||||
this.customEffects.set(index, effect);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
|
||||
index acb69821a99aa69bce6d127e10976089c85be223..a44fc6122f6e653b149fff52e553d60a049e7432 100644
|
||||
index acb69821a99aa69bce6d127e10976089c85be223..c5abd73981c5f4b41605eba0d44e6573dfd2a77a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
|
||||
@@ -101,7 +101,7 @@ public class CraftPotionUtil {
|
||||
@@ -245,7 +255,7 @@ index acb69821a99aa69bce6d127e10976089c85be223..a44fc6122f6e653b149fff52e553d60a
|
||||
public static MobEffectInstance fromBukkit(PotionEffect effect) {
|
||||
MobEffect type = MobEffect.byId(effect.getType().getId());
|
||||
- return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
|
||||
+ return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.getKey(), java.util.Optional.empty()); // Purpur - add key
|
||||
+ return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.getKey()); // Purpur - add key
|
||||
}
|
||||
|
||||
public static PotionEffect toBukkit(MobEffectInstance effect) {
|
||||
|
||||
Reference in New Issue
Block a user