mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Progress?
This commit is contained in:
parent
433f6d085d
commit
6e0f8f99fa
@ -12,6 +12,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class NBTManager {
|
public class NBTManager {
|
||||||
|
|
||||||
private static final String CRAFT_META_ITEM_CLASS_PATH = "org.bukkit.craftbukkit.inventory.CraftMetaItem";
|
private static final String CRAFT_META_ITEM_CLASS_PATH = "org.bukkit.craftbukkit.inventory.CraftMetaItem";
|
||||||
@ -58,9 +61,19 @@ public class NBTManager {
|
|||||||
|
|
||||||
public static ItemStack saveNBT(ItemStack itemStack, NBTTagCompound nbtTagCompound) {
|
public static ItemStack saveNBT(ItemStack itemStack, NBTTagCompound nbtTagCompound) {
|
||||||
net.minecraft.server.v1_14_R1.ItemStack nmsItemStack = getNMSItemStack(itemStack);
|
net.minecraft.server.v1_14_R1.ItemStack nmsItemStack = getNMSItemStack(itemStack);
|
||||||
nmsItemStack.save(nbtTagCompound);
|
|
||||||
CraftItemStack craftItemStack = CraftItemStack.asCraftMirror(nmsItemStack);
|
try {
|
||||||
itemStack.setItemMeta(craftItemStack.getItemMeta());
|
Class clazz = Class.forName("net.minecraft.server.v1_14_R1.ItemStack");
|
||||||
|
Class[] methodParameters = new Class[]{ NBTTagCompound.class };
|
||||||
|
Method loadMethod = clazz.getDeclaredMethod("load", methodParameters);
|
||||||
|
loadMethod.setAccessible(true);
|
||||||
|
loadMethod.invoke(nmsItemStack, nbtTagCompound);
|
||||||
|
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// nmsItemStack.save(nbtTagCompound);
|
||||||
|
// itemStack.setItemMeta(nmsItemStack..getItemMeta());
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user