Fix reflection for 1.21.7/8 (round 3)
This commit is contained in:
@@ -22,6 +22,11 @@
|
||||
<id>fabricmc</id>
|
||||
<url>https://maven.fabricmc.net/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minecraft-libraries</id>
|
||||
<name>Minecraft Libraries</name>
|
||||
<url>https://libraries.minecraft.net</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -84,6 +89,12 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>datafixerupper</artifactId>
|
||||
<version>${datafixerupper.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Paper -->
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
|
@@ -3,9 +3,14 @@ package fr.pandacube.lib.paper.players;
|
||||
import fr.pandacube.lib.paper.inventory.DummyPlayerInventory;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftItemStack;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.ListTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProblemReporter;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStackWithSlot;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.TagValueInput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.TagValueOutput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueInput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueOutputTypedOutputList;
|
||||
import fr.pandacube.lib.paper.util.ExperienceUtil;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -14,6 +19,7 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@@ -118,17 +124,17 @@ public record PlayerDataWrapper(CompoundTag data) {
|
||||
}
|
||||
|
||||
private Map<Integer, ItemStack> getRawInventoryContent(String key) {
|
||||
if (!data.contains(key, Tag.TAG_LIST()))
|
||||
return Map.of();
|
||||
ListTag list = data.getList(key, Tag.TAG_COMPOUND());
|
||||
if (list == null)
|
||||
return Map.of();
|
||||
|
||||
ValueInput vi = TagValueInput.createGlobal(ProblemReporter.DISCARDING(), data);
|
||||
Iterable<?> listNMSItemStackWithSlot = ReflectWrapper.unwrap(vi.listOrEmpty(key, ItemStackWithSlot.CODEC()));
|
||||
|
||||
Map<Integer, ItemStack> stacks = new TreeMap<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CompoundTag itemTag = list.getCompound(i);
|
||||
int nbtSlot = itemTag.getByte("Slot") & 255;
|
||||
fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack.parse(itemTag)
|
||||
|
||||
for (Object nmsISWS : listNMSItemStackWithSlot) {
|
||||
ItemStackWithSlot isws = ReflectWrapper.wrap(nmsISWS, ItemStackWithSlot.class);
|
||||
|
||||
int nbtSlot = isws.slot() & 255;
|
||||
Optional.of(isws.stack())
|
||||
.map(nms -> filterStack(CraftItemStack.asCraftMirror(nms)))
|
||||
.ifPresent(is -> stacks.put(nbtSlot, is));
|
||||
}
|
||||
@@ -153,21 +159,22 @@ public record PlayerDataWrapper(CompoundTag data) {
|
||||
}
|
||||
|
||||
private void setRawInventoryContent(String key, Map<Integer, ItemStack> stacks) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
TagValueOutput vo = TagValueOutput.createWrappingGlobal(ProblemReporter.DISCARDING(), data);
|
||||
ValueOutputTypedOutputList listNMSItemStackWithSlot = vo.list(key, ItemStackWithSlot.CODEC());
|
||||
|
||||
for (Entry<Integer, ItemStack> is : stacks.entrySet()) {
|
||||
ItemStack stack = filterStack(is.getValue());
|
||||
if (stack == null)
|
||||
continue;
|
||||
CompoundTag itemTag = new CompoundTag();
|
||||
itemTag.putByte("Slot", is.getKey().byteValue());
|
||||
list.add(list.size(), CraftItemStack.asNMSCopy(is.getValue()).save(itemTag));
|
||||
|
||||
listNMSItemStackWithSlot.add(ReflectWrapper.unwrap(new ItemStackWithSlot(is.getKey(), CraftItemStack.asNMSCopy(is.getValue()))));
|
||||
}
|
||||
data.put(key, list);
|
||||
}
|
||||
|
||||
|
||||
private ItemStack filterStack(ItemStack is) {
|
||||
return is == null || is.getType().isEmpty() || is.getAmount() == 0 ? null : is;
|
||||
return is == null || is.isEmpty() || is.getAmount() <= 0 ? null : is;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -59,11 +59,18 @@ 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.Entity;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStackWithSlot;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.PlayerDataStorage;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.RegionFileStorage;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.SavedData;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.TagValueInput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.TagValueOutput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueInput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueInputTypedInputList;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueOutput;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ValueOutputTypedOutputList;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block.BambooStalkBlock;
|
||||
@@ -189,11 +196,18 @@ public class PandalibPaperReflect {
|
||||
thAcc.catchThrowable(() -> initWrapper(ChunkStorage.class, ChunkStorage.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(Entity.class, Entity.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ItemStack.class, ItemStack.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ItemStackWithSlot.class, ItemStackWithSlot.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(Level.class, Level.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(MapItemSavedData.class, MapItemSavedData.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(PlayerDataStorage.class, PlayerDataStorage.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(RegionFileStorage.class, RegionFileStorage.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(SavedData.class, SavedData.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(TagValueInput.class, TagValueInput.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(TagValueOutput.class, TagValueOutput.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ValueInput.class, ValueInput.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ValueInputTypedInputList.class, ValueInputTypedInputList.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ValueOutput.class, ValueOutput.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(ValueOutputTypedOutputList.class, ValueOutputTypedOutputList.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(Vec3.class, Vec3.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(VoxelShape.class, VoxelShape.REFLECT.get()));
|
||||
// minecraft
|
||||
|
@@ -6,7 +6,6 @@ import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -20,17 +19,14 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
private static final ReflectMethod<?> putBoolean = wrapEx(() -> REFLECT.method("putBoolean", String.class, boolean.class));
|
||||
private static final ReflectMethod<?> putByte = wrapEx(() -> REFLECT.method("putByte", String.class, byte.class));
|
||||
private static final ReflectMethod<?> putByteArray = wrapEx(() -> REFLECT.method("putByteArray", String.class, byte[].class));
|
||||
private static final ReflectMethod<?> putByteArray_List = wrapEx(() -> REFLECT.method("putByteArray", String.class, List.class));
|
||||
private static final ReflectMethod<?> putDouble = wrapEx(() -> REFLECT.method("putDouble", String.class, double.class));
|
||||
private static final ReflectMethod<?> putFloat = wrapEx(() -> REFLECT.method("putFloat", String.class, float.class));
|
||||
private static final ReflectMethod<?> putInt = wrapEx(() -> REFLECT.method("putInt", String.class, int.class));
|
||||
private static final ReflectMethod<?> putIntArray = wrapEx(() -> REFLECT.method("putIntArray", String.class, int[].class));
|
||||
private static final ReflectMethod<?> putIntArray_List = wrapEx(() -> REFLECT.method("putIntArray", String.class, List.class));
|
||||
private static final ReflectMethod<?> putString = wrapEx(() -> REFLECT.method("putString", String.class, String.class));
|
||||
private static final ReflectMethod<?> putUUID = wrapEx(() -> REFLECT.method("putUUID", String.class, UUID.class));
|
||||
private static final ReflectMethod<?> putLong = wrapEx(() -> REFLECT.method("putLong", String.class, long.class));
|
||||
private static final ReflectMethod<?> putLongArray = wrapEx(() -> REFLECT.method("putLongArray", String.class, long[].class));
|
||||
private static final ReflectMethod<?> putLongArray_List = wrapEx(() -> REFLECT.method("putLongArray", String.class, List.class));
|
||||
private static final ReflectMethod<?> putShort = wrapEx(() -> REFLECT.method("putShort", String.class, short.class));
|
||||
private static final ReflectMethod<?> put = wrapEx(() -> REFLECT.method("put", String.class, Tag.REFLECT.get()));
|
||||
|
||||
@@ -73,9 +69,6 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
public void putByteArray(String key, byte[] value) {
|
||||
wrapReflectEx(() -> putByteArray.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putByteArray(String key, List<Byte> value) {
|
||||
wrapReflectEx(() -> putByteArray_List.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putDouble(String key, double value) {
|
||||
wrapReflectEx(() -> putDouble.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
@@ -88,9 +81,6 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
public void putIntArray(String key, int[] value) {
|
||||
wrapReflectEx(() -> putIntArray.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putIntArray(String key, List<Integer> value) {
|
||||
wrapReflectEx(() -> putIntArray_List.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putString(String key, String value) {
|
||||
wrapReflectEx(() -> putString.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
@@ -103,9 +93,6 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
public void putLongArray(String key, long[] value) {
|
||||
wrapReflectEx(() -> putLongArray.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putLongArray(String key, List<Long> value) {
|
||||
wrapReflectEx(() -> putLongArray_List.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
public void putShort(String key, short value) {
|
||||
wrapReflectEx(() -> putShort.invoke(__getRuntimeInstance(), key, value));
|
||||
}
|
||||
|
@@ -1,63 +1,15 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.HolderLookupProvider;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.RegistryAccess;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public class ItemStack extends ReflectWrapper {
|
||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.item.ItemStack"));
|
||||
private static final ReflectMethod<?> parse = wrapEx(() -> REFLECT.method("parse", HolderLookupProvider.REFLECT.get(), Tag.REFLECT.get()));
|
||||
private static final ReflectMethod<?> saveWithPrefix = wrapEx(() -> REFLECT.method("save", HolderLookupProvider.REFLECT.get(), Tag.REFLECT.get()));
|
||||
private static final ReflectMethod<?> save = wrapEx(() -> REFLECT.method("save", HolderLookupProvider.REFLECT.get()));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Optional<ItemStack> parse(HolderLookupProvider registries, Tag nbt) {
|
||||
return ((Optional<Object>) wrapReflectEx(() -> parse.invokeStatic(unwrap(registries), unwrap(nbt))))
|
||||
.map(o -> wrap(o, ItemStack.class));
|
||||
}
|
||||
|
||||
|
||||
public static Optional<ItemStack> parse(Tag nbt) {
|
||||
return parse(getRegistries(), nbt);
|
||||
}
|
||||
|
||||
|
||||
protected ItemStack(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
|
||||
public Tag save(HolderLookupProvider registries, Tag prefix) {
|
||||
return wrap(wrapReflectEx(() -> saveWithPrefix.invoke(__getRuntimeInstance(), unwrap(registries), unwrap(prefix))), Tag.class);
|
||||
}
|
||||
|
||||
|
||||
public Tag save(HolderLookupProvider registries) {
|
||||
return wrap(wrapReflectEx(() -> save.invoke(__getRuntimeInstance(), unwrap(registries))), Tag.class);
|
||||
}
|
||||
|
||||
|
||||
public Tag save(Tag prefix) {
|
||||
return save(getRegistries(), prefix);
|
||||
}
|
||||
|
||||
|
||||
public Tag save() {
|
||||
return save(getRegistries());
|
||||
}
|
||||
|
||||
private static RegistryAccess getRegistries() {
|
||||
return wrap(Bukkit.getServer(), CraftServer.class).getServer().registryAccess();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||
import fr.pandacube.lib.reflect.ReflectField;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
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 ItemStackWithSlot extends ReflectWrapper {
|
||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.ItemStackWithSlot"));
|
||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(int.class, ItemStack.REFLECT.get()));
|
||||
private static final ReflectField<?> CODEC = wrapEx(() -> REFLECT.field("CODEC"));
|
||||
private static final ReflectMethod<?> slot = wrapEx(() -> REFLECT.method("slot"));
|
||||
private static final ReflectMethod<?> stack = wrapEx(() -> REFLECT.method("stack"));
|
||||
|
||||
public static Codec<?> CODEC() {
|
||||
return (Codec<?>) wrapReflectEx(CODEC::getStaticValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ItemStackWithSlot(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
public ItemStackWithSlot(int slot, ItemStack stack) {
|
||||
super(wrapReflectEx(() -> CONSTRUCTOR.instantiate(slot, unwrap(stack))));
|
||||
}
|
||||
|
||||
|
||||
public int slot() {
|
||||
return (int) wrapReflectEx(() -> slot.invoke(__getRuntimeInstance()));
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return wrap(wrapReflectEx(() -> stack.invoke(__getRuntimeInstance())), ItemStack.class);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProblemReporter;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
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 TagValueInput extends ReflectWrapper implements ValueInput {
|
||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.TagValueInput"));
|
||||
private static final ReflectMethod<?> createGlobal = wrapEx(() -> REFLECT.method("createGlobal", ProblemReporter.REFLECT.get(), CompoundTag.REFLECT.get()));
|
||||
|
||||
public static ValueInput createGlobal(ProblemReporter problemReporter, CompoundTag nbt) {
|
||||
return wrap(wrapReflectEx(() -> createGlobal.invokeStatic(unwrap(problemReporter), unwrap(nbt))), ValueInput.class);
|
||||
}
|
||||
|
||||
protected TagValueInput(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProblemReporter;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
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 TagValueOutput extends ReflectWrapper implements ValueOutput {
|
||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.TagValueOutput"));
|
||||
private static final ReflectMethod<?> createWrappingGlobal = wrapEx(() -> REFLECT.method("createWrappingGlobal", ProblemReporter.REFLECT.get(), CompoundTag.REFLECT.get()));
|
||||
|
||||
public static TagValueOutput createWrappingGlobal(ProblemReporter problemReporter, CompoundTag nbt) {
|
||||
return wrap(wrapReflectEx(() -> createWrappingGlobal.invokeStatic(unwrap(problemReporter), unwrap(nbt))), TagValueOutput.class);
|
||||
}
|
||||
|
||||
protected TagValueOutput(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||
|
||||
import static fr.pandacube.lib.reflect.wrapper.ReflectWrapper.wrap;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public interface ValueInput extends ReflectWrapperI {
|
||||
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.ValueInput"));
|
||||
ReflectMethod<?> listOrEmpty = wrapEx(() -> REFLECT.method("listOrEmpty", String.class, Codec.class));
|
||||
|
||||
|
||||
|
||||
default ValueInputTypedInputList listOrEmpty(String key, Codec<?> elementCodec) {
|
||||
return wrap(wrapReflectEx(() -> listOrEmpty.invoke(__getRuntimeInstance(), key, elementCodec)), ValueInputTypedInputList.class);
|
||||
}
|
||||
|
||||
class __concrete extends ReflectWrapper implements ValueInput {
|
||||
private __concrete(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTypedI;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
|
||||
public interface ValueInputTypedInputList extends ReflectWrapperTypedI<Iterable<?>> {
|
||||
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.ValueInput$TypedInputList"));
|
||||
|
||||
|
||||
class __concrete extends ReflectWrapperTyped<Iterable<?>> implements ValueInputTypedInputList {
|
||||
private __concrete(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||
|
||||
import static fr.pandacube.lib.reflect.wrapper.ReflectWrapper.wrap;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public interface ValueOutput extends ReflectWrapperI {
|
||||
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.ValueOutput"));
|
||||
ReflectMethod<?> list = wrapEx(() -> REFLECT.method("list", String.class, Codec.class));
|
||||
|
||||
|
||||
|
||||
default ValueOutputTypedOutputList list(String key, Codec<?> elementCodec) {
|
||||
return wrap(wrapReflectEx(() -> list.invoke(__getRuntimeInstance(), key, elementCodec)), ValueOutputTypedOutputList.class);
|
||||
}
|
||||
|
||||
class __concrete extends ReflectWrapper implements ValueOutput {
|
||||
private __concrete(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public interface ValueOutputTypedOutputList extends ReflectWrapperI {
|
||||
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.ValueOutput$TypedOutputList"));
|
||||
ReflectMethod<?> add = wrapEx(() -> REFLECT.method("add", Object.class));
|
||||
|
||||
default void add(Object rawElement) {
|
||||
wrapReflectEx(() -> add.invoke(__getRuntimeInstance(), rawElement));
|
||||
}
|
||||
|
||||
|
||||
class __concrete extends ReflectWrapper implements ValueOutputTypedOutputList {
|
||||
private __concrete(Object obj) {
|
||||
super(obj);
|
||||
}
|
||||
}
|
||||
}
|
1
pom.xml
1
pom.xml
@@ -60,6 +60,7 @@
|
||||
<mc.version>1.21.8</mc.version>
|
||||
|
||||
<guava.version>33.3.1-jre</guava.version> <!-- Match the version imported by Paper API/BungeeCord API if possible -->
|
||||
<datafixerupper.version>8.0.16</datafixerupper.version> <!-- Match the version used internally in Paper Server -->
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
Reference in New Issue
Block a user