Fix reflect wrappers due to changes in NMS about DamageSources

This commit is contained in:
Marc Baloup 2023-05-08 22:32:40 +02:00
parent d023bcb706
commit df8dbe1e61
3 changed files with 18 additions and 5 deletions

View File

@ -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());

View File

@ -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);

View File

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