+ nbt update
This commit is contained in:
parent
b09dfbde60
commit
fd9817e5c5
@ -34,15 +34,15 @@ public abstract class NMSHandler {
|
|||||||
|
|
||||||
abstract public void sendActionBar(Player player, String text);
|
abstract public void sendActionBar(Player player, String text);
|
||||||
|
|
||||||
abstract public ItemStack saveNBT(ItemStack itemStack, NBTCompound compound);
|
|
||||||
|
|
||||||
abstract public Object _NBT(ItemStack itemStack);
|
abstract public Object _NBT(ItemStack itemStack);
|
||||||
|
|
||||||
|
abstract public ItemStack _NBT(ItemStack itemStack, Object compound);
|
||||||
|
|
||||||
public NBTCompound loadNBT(ItemStack itemStack) {
|
public NBTCompound loadNBT(ItemStack itemStack) {
|
||||||
return (NBTCompound) _NBT(itemStack);
|
return (NBTCompound) _NBT(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NMSHandler getHandler() {
|
public ItemStack saveNBT(ItemStack itemStack, NBTCompound compound) {
|
||||||
return handler;
|
return _NBT(itemStack, compound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,10 @@ public class NMSHandlerImpl extends NMSHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack saveNBT(ItemStack itemStack, NBTCompound compound) {
|
public ItemStack _NBT(ItemStack itemStack, Object compound) {
|
||||||
Object nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
Object nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
try {
|
try {
|
||||||
((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).setTag((net.minecraft.server.v1_8_R3.NBTTagCompound) toNBTBase(compound));
|
((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).setTag((net.minecraft.server.v1_8_R3.NBTTagCompound) toNBTBase((me.skymc.taboolib.common.nms.nbt.NBTBase) compound));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -197,30 +197,30 @@ public class NMSHandlerImpl extends NMSHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Object toNBTBase(me.skymc.taboolib.common.nms.nbt.NBTBase base) {
|
private Object toNBTBase(me.skymc.taboolib.common.nms.nbt.NBTBase base) {
|
||||||
switch (base.getType()) {
|
switch (base.getType().getId()) {
|
||||||
case INT:
|
case 1:
|
||||||
return new NBTTagInt(base.asInt());
|
|
||||||
case BYTE:
|
|
||||||
return new NBTTagByte(base.asByte());
|
return new NBTTagByte(base.asByte());
|
||||||
case LONG:
|
case 2:
|
||||||
return new NBTTagLong(base.asLong());
|
|
||||||
case FLOAT:
|
|
||||||
return new NBTTagFloat(base.asFloat());
|
|
||||||
case SHORT:
|
|
||||||
return new NBTTagShort(base.asShort());
|
return new NBTTagShort(base.asShort());
|
||||||
case DOUBLE:
|
case 3:
|
||||||
|
return new NBTTagInt(base.asInt());
|
||||||
|
case 4:
|
||||||
|
return new NBTTagLong(base.asLong());
|
||||||
|
case 5:
|
||||||
|
return new NBTTagFloat(base.asFloat());
|
||||||
|
case 6:
|
||||||
return new NBTTagDouble(base.asDouble());
|
return new NBTTagDouble(base.asDouble());
|
||||||
case STRING:
|
case 7:
|
||||||
return new NBTTagString(base.asString());
|
|
||||||
case INT_ARRAY:
|
|
||||||
return new NBTTagIntArray(base.asIntArray());
|
|
||||||
case BYTE_ARRAY:
|
|
||||||
return new NBTTagByteArray(base.asByteArray());
|
return new NBTTagByteArray(base.asByteArray());
|
||||||
case LIST:
|
case 11:
|
||||||
|
return new NBTTagIntArray(base.asIntArray());
|
||||||
|
case 8:
|
||||||
|
return new NBTTagString(base.asString());
|
||||||
|
case 9:
|
||||||
Object nmsList = new NBTTagList();
|
Object nmsList = new NBTTagList();
|
||||||
base.asList().forEach(value -> ((NBTTagList) nmsList).add((net.minecraft.server.v1_8_R3.NBTBase) toNBTBase(value)));
|
base.asList().forEach(value -> ((NBTTagList) nmsList).add((net.minecraft.server.v1_8_R3.NBTBase) toNBTBase(value)));
|
||||||
return nmsList;
|
return nmsList;
|
||||||
case COMPOUND:
|
case 10:
|
||||||
Object nmsTag = new net.minecraft.server.v1_8_R3.NBTTagCompound();
|
Object nmsTag = new net.minecraft.server.v1_8_R3.NBTTagCompound();
|
||||||
base.asCompound().forEach((k, v) -> ((net.minecraft.server.v1_8_R3.NBTTagCompound) nmsTag).set(k, (net.minecraft.server.v1_8_R3.NBTBase) toNBTBase(v)));
|
base.asCompound().forEach((k, v) -> ((net.minecraft.server.v1_8_R3.NBTTagCompound) nmsTag).set(k, (net.minecraft.server.v1_8_R3.NBTBase) toNBTBase(v)));
|
||||||
return nmsTag;
|
return nmsTag;
|
||||||
|
@ -21,6 +21,7 @@ public class NBTCompound extends NBTBase implements Map<String, NBTBase> {
|
|||||||
public NBTCompound() {
|
public NBTCompound() {
|
||||||
super(0);
|
super(0);
|
||||||
this.type = NBTType.COMPOUND;
|
this.type = NBTType.COMPOUND;
|
||||||
|
this.data = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,6 +19,7 @@ public class NBTList extends NBTBase implements List<NBTBase> {
|
|||||||
public NBTList() {
|
public NBTList() {
|
||||||
super(0);
|
super(0);
|
||||||
this.type = NBTType.LIST;
|
this.type = NBTType.LIST;
|
||||||
|
this.data = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user