Fix InitializerError during ReflectWrapper classes registration

This commit is contained in:
Marc Baloup 2022-07-11 00:50:00 +02:00
parent b6104a76c1
commit 3fd853f2a6
3 changed files with 12 additions and 4 deletions

View File

@ -14,7 +14,9 @@ public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Pa
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ResourceLocation.MAPPING.runtimeClass(), FriendlyByteBuf.MAPPING.runtimeClass())); private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ResourceLocation.MAPPING.runtimeClass(), FriendlyByteBuf.MAPPING.runtimeClass()));
private static final Reflect.ReflectField<?> FIELD_BRAND = wrapEx(() -> MAPPING.mojField("BRAND")); private static final Reflect.ReflectField<?> FIELD_BRAND = wrapEx(() -> MAPPING.mojField("BRAND"));
public static final ResourceLocation BRAND = wrap(wrapReflectEx(FIELD_BRAND::getStaticValue), ResourceLocation.class); public static ResourceLocation BRAND() {
return wrap(wrapReflectEx(FIELD_BRAND::getStaticValue), ResourceLocation.class);
}
protected ClientboundCustomPayloadPacket(Object obj) { protected ClientboundCustomPayloadPacket(Object obj) {
super(obj); super(obj);

View File

@ -13,8 +13,12 @@ public class ClientboundGameEventPacket extends ReflectWrapper implements Packet
private static final Reflect.ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE")); private static final Reflect.ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE"));
private static final Reflect.ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE")); private static final Reflect.ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE"));
public static final Type RAIN_LEVEL_CHANGE = wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class); public static Type RAIN_LEVEL_CHANGE() {
public static final Type THUNDER_LEVEL_CHANGE = wrap(wrapReflectEx(FIELD_THUNDER_LEVEL_CHANGE::getStaticValue), Type.class); return wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class);
}
public static Type THUNDER_LEVEL_CHANGE() {
return wrap(wrapReflectEx(FIELD_THUNDER_LEVEL_CHANGE::getStaticValue), Type.class);
}
public ClientboundGameEventPacket(Type type, float value) { public ClientboundGameEventPacket(Type type, float value) {
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(type), value))); this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(type), value)));

View File

@ -11,7 +11,9 @@ public class DamageSource extends ReflectWrapper {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource"));
private static final Reflect.ReflectField<?> FIELD_OUT_OF_WORLD = wrapEx(() -> MAPPING.mojField("OUT_OF_WORLD")); private static final Reflect.ReflectField<?> FIELD_OUT_OF_WORLD = wrapEx(() -> MAPPING.mojField("OUT_OF_WORLD"));
public static final DamageSource OUT_OF_WORLD = wrap(wrapReflectEx(FIELD_OUT_OF_WORLD::getStaticValue), DamageSource.class); public static DamageSource OUT_OF_WORLD() {
return wrap(wrapReflectEx(FIELD_OUT_OF_WORLD::getStaticValue), DamageSource.class);
}
protected DamageSource(Object obj) { protected DamageSource(Object obj) {
super(obj); super(obj);