Skip to content

Commit

Permalink
[6.0.11][publish] Experimental > update ItemTag & fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Jun 13, 2023
1 parent 0a8d277 commit d726902
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public ItemTagData(ItemTagList data) {
this.data = data;
}

public ItemTagData(ItemTagType type, Object data) {
this.type = type;
this.data = data;
}

public String toJsonSimplified() {
return toJsonSimplified(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public NMSGenericImpl() {
);
packetPlayOutSignEditorConstructor = net.minecraft.server.v1_16_R1.PacketPlayOutOpenSignEditor.class.getDeclaredConstructor(
net.minecraft.server.v1_16_R1.BlockPosition.class,
Boolean.class
Boolean.TYPE
);
} else {
packetPlayOutLightUpdateConstructor = net.minecraft.server.v1_16_R1.PacketPlayOutLightUpdate.class.getDeclaredConstructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package taboolib.module.nms

fun ItemTagData.clone(): ItemTagData {
return when (type) {
ItemTagType.END -> ItemTagData(type, null)
ItemTagType.BYTE,
ItemTagType.SHORT,
ItemTagType.INT,
ItemTagType.LONG,
ItemTagType.FLOAT,
ItemTagType.DOUBLE,
ItemTagType.STRING -> ItemTagData(type, unsafeData())
ItemTagType.BYTE_ARRAY -> ItemTagData(type, asByteArray().copyOf())
ItemTagType.INT_ARRAY -> ItemTagData(type, asIntArray().copyOf())
ItemTagType.LIST -> {
val list = ItemTagList()
asList().forEach { list.add(it.clone()) }
list
}
ItemTagType.COMPOUND -> {
val compound = ItemTag()
asCompound().forEach { (k, v) -> compound[k] = v.clone() }
compound
}
else -> error("unsupported tag type")
}
}

0 comments on commit d726902

Please sign in to comment.