How can i take acces for Java enviroment in nashorn?
lastuniverse opened this issue ยท 3 comments
Help me. How can i use/transplate this JAVA sample in scriptcraft?
CraftItemStack craft = (CraftItemStack) stack;
NBTTagCompound nbtin = new NBTTagCompound();
CraftItemStack.asNMSCopy(craft).save(nbtin);
String json = nbtin.toString();
NBTTagCompound nbtout = MojangsonParser.parse(json);
stack = CraftItemStack.asBukkitCopy(new net.minecraft.server.v1_12_R1.ItemStack(nbtout));
I will be infinitely grateful for your help.
I need a full serialization of ItemStack in JSON. And deserialization is back. In addition, the following classes should be optionally saved: BannerMeta, BookMeta, EnchantmentStorageMeta, LeatherArmorMeta, SkullMeta, FireworkMeta.
I found a few examples on JAVA solving this problem.
Https://github.com/Gnat008/PerWorldInventory/blob/master/src/main/java/me/gnat008/perworldinventory/data/serializers/ItemSerializer.java
Http://rubukkit.org/threads/serializacija-itemstask-v-json-i-deserializacija-obratno.138369/
But I can not reproduce them on scriptcraft. For some classes, I can not call constructors. In some cases I can not explicitly convert the types.
I suggest HowTo questions like this will get better visibility in the Google Forum. For this reason I'm closing this item which is not an "issue". Thanks.
The specific code initially provided here for Minecraft 1.12.1 won't work in the production version of ScriptCraft which supports up to 1.11. But I'm now testing a build for v1.12.1.