From df8dbe1e610a6b48ea96f6499db4f1e0d6a59255 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Mon, 8 May 2023 22:32:40 +0200 Subject: [PATCH] Fix reflect wrappers due to changes in NMS about DamageSources --- .../lib/paper/reflect/PandalibPaperReflect.java | 2 ++ .../wrapper/minecraft/world/DamageSource.java | 5 ----- .../wrapper/minecraft/world/DamageSources.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java index ee54dfa..6dbcdf7 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java @@ -57,6 +57,7 @@ import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.AABB; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkPos; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSource; +import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSources; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level; @@ -169,6 +170,7 @@ public class PandalibPaperReflect { initWrapper(ChunkPos.class, ChunkPos.MAPPING.runtimeClass()); initWrapper(ChunkStorage.class, ChunkStorage.MAPPING.runtimeClass()); initWrapper(DamageSource.class, DamageSource.MAPPING.runtimeClass()); + initWrapper(DamageSources.class, DamageSources.MAPPING.runtimeClass()); initWrapper(Entity.class, Entity.MAPPING.runtimeClass()); initWrapper(ItemStack.class, ItemStack.MAPPING.runtimeClass()); initWrapper(Level.class, Level.MAPPING.runtimeClass()); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java index 12f0e77..e0fe945 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java @@ -9,11 +9,6 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class DamageSource extends ReflectWrapper { public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource")); - private static final ReflectField FIELD_OUT_OF_WORLD = wrapEx(() -> MAPPING.mojField("OUT_OF_WORLD")); - - public static DamageSource OUT_OF_WORLD() { - return wrap(wrapReflectEx(FIELD_OUT_OF_WORLD::getStaticValue), DamageSource.class); - } protected DamageSource(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java new file mode 100644 index 0000000..c039930 --- /dev/null +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java @@ -0,0 +1,16 @@ +package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; + +import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.ReflectField; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; + +import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; +import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; + +public class DamageSources extends ReflectWrapper { + public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSources")); + + protected DamageSources(Object obj) { + super(obj); + } +}