Undo changes to DamageEffect for now

This commit is contained in:
Chaosdave34 2024-12-23 14:46:08 +01:00
parent d56b3b92fb
commit f37300044b
5 changed files with 11 additions and 54 deletions

View file

@ -125,7 +125,6 @@ public interface UnsafeValues {
@ApiStatus.Internal @ApiStatus.Internal
@Nullable @Nullable
@Deprecated
DamageEffect getDamageEffect(@NotNull String key); DamageEffect getDamageEffect(@NotNull String key);
/** /**
@ -252,15 +251,6 @@ public interface UnsafeValues {
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first) * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
*/ */
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
/**
* Get the {@link Sound} played for this {@link DamageEffect}
*
* @param damageEffect the damageEffect
* @return the sound
*/
@ApiStatus.Internal
Sound getSoundForDamageEffect(@NotNull DamageEffect damageEffect);
// Paper end // Paper end
// Paper start - namespaced key biome methods // Paper start - namespaced key biome methods

View file

@ -11,35 +11,34 @@ import org.jetbrains.annotations.NotNull;
* effects only determine the sound that plays. * effects only determine the sound that plays.
*/ */
@ApiStatus.Experimental @ApiStatus.Experimental
public enum DamageEffect { public interface DamageEffect {
/** /**
* The default damage effect. * The default damage effect.
*/ */
HURT, public static final DamageEffect HURT = getDamageEffect("hurt");
/** /**
* Thorns. * Thorns.
*/ */
THORNS, public static final DamageEffect THORNS = getDamageEffect("thorns");
/** /**
* Drowning. * Drowning.
*/ */
DROWNING, public static final DamageEffect DROWNING = getDamageEffect("drowning");
/** /**
* A single burn tick (fire, lava, etc.). * A single burn tick (fire, lava, etc.).
*/ */
BURNING, public static final DamageEffect BURNING = getDamageEffect("burning");
/** /**
* Poked by a berry bush. * Poked by a berry bush.
*/ */
POKING, public static final DamageEffect POKING = getDamageEffect("poking");
/** /**
* Freeze tick (powder snow). * Freeze tick (powder snow).
*/ */
FREEZING; public static final DamageEffect FREEZING = getDamageEffect("freezing");
@NotNull @NotNull
@Deprecated
private static DamageEffect getDamageEffect(@NotNull String key) { private static DamageEffect getDamageEffect(@NotNull String key) {
return Preconditions.checkNotNull(Bukkit.getUnsafe().getDamageEffect(key), "No DamageEffect found for %s. This is a bug.", key); return Preconditions.checkNotNull(Bukkit.getUnsafe().getDamageEffect(key), "No DamageEffect found for %s. This is a bug.", key);
} }
@ -50,7 +49,5 @@ public enum DamageEffect {
* @return the sound * @return the sound
*/ */
@NotNull @NotNull
public Sound getSound() { public Sound getSound();
return Bukkit.getUnsafe().getSoundForDamageEffect(this);
}
} }

View file

@ -5,8 +5,7 @@ import org.bukkit.Sound;
import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageEffect;
@Deprecated public class CraftDamageEffect implements DamageEffect {
public class CraftDamageEffect {
private final DamageEffects damageEffects; private final DamageEffects damageEffects;
@ -18,6 +17,7 @@ public class CraftDamageEffect {
return this.damageEffects; return this.damageEffects;
} }
@Override
public Sound getSound() { public Sound getSound() {
return CraftSound.minecraftToBukkit(this.getHandle().sound()); return CraftSound.minecraftToBukkit(this.getHandle().sound());
} }
@ -32,6 +32,6 @@ public class CraftDamageEffect {
} }
public static DamageEffect toBukkit(DamageEffects damageEffects) { public static DamageEffect toBukkit(DamageEffects damageEffects) {
return CraftDamageType.damageEffectToBukkit(damageEffects); return new CraftDamageEffect(damageEffects);
} }
} }

View file

@ -98,30 +98,6 @@ public class CraftDamageType implements DamageType, Handleable<net.minecraft.wor
}; };
} }
public static DamageEffect damageEffectToBukkit(net.minecraft.world.damagesource.DamageEffects damageEffect) {
return switch (damageEffect) {
case HURT -> DamageEffect.HURT;
case THORNS -> DamageEffect.THORNS;
case DROWNING -> DamageEffect.DROWNING;
case BURNING -> DamageEffect.BURNING;
case POKING -> DamageEffect.POKING;
case FREEZING -> DamageEffect.FREEZING;
default -> throw new IllegalArgumentException("NMS DamageEffect." + damageEffect + " cannot be converted to a Bukkit DamageEffect");
};
}
public static net.minecraft.world.damagesource.DamageEffects damageEffectToNMS(DamageEffect damageEffect) {
return switch (damageEffect) {
case DamageEffect.HURT -> net.minecraft.world.damagesource.DamageEffects.HURT;
case DamageEffect.THORNS -> net.minecraft.world.damagesource.DamageEffects.THORNS;
case DamageEffect.DROWNING -> net.minecraft.world.damagesource.DamageEffects.DROWNING;
case DamageEffect.BURNING -> net.minecraft.world.damagesource.DamageEffects.BURNING;
case DamageEffect.POKING -> net.minecraft.world.damagesource.DamageEffects.POKING;
case DamageEffect.FREEZING -> net.minecraft.world.damagesource.DamageEffects.FREEZING;
default -> throw new IllegalArgumentException("Bukkit DamageEffect." + damageEffect + " cannot be converted to a NMS DamageEffect");
};
}
public static DamageType minecraftHolderToBukkit(Holder<net.minecraft.world.damagesource.DamageType> minecraftHolder) { public static DamageType minecraftHolderToBukkit(Holder<net.minecraft.world.damagesource.DamageType> minecraftHolder) {
return CraftDamageType.minecraftToBukkit(minecraftHolder.value()); return CraftDamageType.minecraftToBukkit(minecraftHolder.value());
} }

View file

@ -674,12 +674,6 @@ public final class CraftMagicNumbers implements UnsafeValues {
player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag); player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag);
return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList(); return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList();
} }
@Override
public org.bukkit.Sound getSoundForDamageEffect(DamageEffect damageEffect) {
Preconditions.checkArgument(damageEffect != null, "key cannot be null");
return org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(org.bukkit.craftbukkit.damage.CraftDamageType.damageEffectToNMS(damageEffect).sound());
}
// Paper end // Paper end
// Paper start - spawn egg color visibility // Paper start - spawn egg color visibility