mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-01 20:15:28 +02:00
More work on the repair rewrite, fleshing out more serializers
This commit is contained in:
@@ -3,6 +3,7 @@ package com.gmail.nossr50.util.nbt;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import net.minecraft.server.v1_13_R2.NBTBase;
|
||||
import net.minecraft.server.v1_13_R2.NBTList;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
|
||||
@@ -26,9 +27,16 @@ public class NBTManager {
|
||||
}
|
||||
}
|
||||
|
||||
public RawNBT<?> constructNBT(String nbtString) {
|
||||
public NBTTagCompound getNBT(ItemStack itemStack) {
|
||||
Bukkit.broadcastMessage("Checking NBT for "+itemStack.toString());
|
||||
net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound rootTag = nmsItemStack.getTag();
|
||||
return rootTag;
|
||||
}
|
||||
|
||||
public NBTBase constructNBT(String nbtString) {
|
||||
try {
|
||||
return new RawNBT<NBTBase>(nbtString, CraftNBTTagConfigSerializer.deserialize(nbtString));
|
||||
return CraftNBTTagConfigSerializer.deserialize(nbtString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mcMMO.p.getLogger().severe("mcMMO was unable parse the NBT string from your config! Double check that it is proper NBT!");
|
||||
@@ -37,15 +45,18 @@ public class NBTManager {
|
||||
}
|
||||
|
||||
public void printNBT(ItemStack itemStack) {
|
||||
Bukkit.broadcastMessage("Checking NBT for "+itemStack.toString());
|
||||
net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound rootTag = nmsItemStack.getTag();
|
||||
for(String key : rootTag.getKeys()) {
|
||||
for(String key : getNBT(itemStack).getKeys()) {
|
||||
Bukkit.broadcastMessage("NBT Key found: "+key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNBT(NBTTagCompound root, NBTTagCompound nbtData) {
|
||||
public boolean hasNBT(NBTBase nbt, NBTTagCompound otherNbt) {
|
||||
if(nbt instanceof NBTList<?>) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
//TODO: Implement this
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.nbt;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import net.minecraft.server.v1_13_R2.NBTBase;
|
||||
|
||||
/**
|
||||
* A simple class that acts as a container for raw NBT data
|
||||
@@ -14,12 +15,9 @@ import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
*/
|
||||
public class RawNBT {
|
||||
private String nbtContents;
|
||||
private NBTTagCompound nbtData; //Will be constructed using server internals to make matching NBT easier
|
||||
|
||||
|
||||
public RawNBT(String nbtContents, NBTTagCompound nbtData) {
|
||||
public RawNBT(String nbtContents) {
|
||||
this.nbtContents = nbtContents;
|
||||
this.nbtData = nbtData;
|
||||
}
|
||||
|
||||
public String getNbtContents() {
|
||||
@@ -30,7 +28,7 @@ public class RawNBT {
|
||||
this.nbtContents = nbtContents;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNbtData() {
|
||||
return nbtData;
|
||||
public NBTBase getNbtData() {
|
||||
return mcMMO.getNbtManager().constructNBT(nbtContents);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user