Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
1.04k
stars
257
forks
source link
Error Unable to find writeStack(class net.minecraft.world.item.ItemStack) in class net.minecraft.network.FriendlyByteBuf in a Inventory Sync Plugin #3297
[x] You're using the latest build for your server version
[x] This isn't an issue caused by another plugin
[x] You've checked for duplicate issues
[x] You didn't use /reload
Describe the question
So i am on Purpur 1.20.6 Java 23 and Protocollib 5.3.0, i have had an working Inventory Syncer and Enderchest Plugin but now i am getting an error when trying to seralize items, so how to fix that?
API method(s) used
i am uisng the StreamSerializer Class with the StreamSerializer#getDefault()#serializeItemStack()
Expected behavior
i expect it to serialize the items correctly so that i can save them and then deserailze them wehn needed
Code
Serialize: public String toBase64(ItemStack[] itemStacks) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < itemStacks.length; i++) {
if (i > 0) {
stringBuilder.append(";");
}
if ((itemStacks[i] != null) && (itemStacks[i].getType() != Material.AIR)) {
stringBuilder.append(StreamSerializer.getDefault().serializeItemStack(itemStacks[i]));
}
}
return stringBuilder.toString();
}
Deserialize:
public ItemStack[] fromBase64(String data) {
String[] strings = data.split(";");
ItemStack[] itemStacks = new ItemStack[strings.length];
for (int i = 0; i < strings.length; i++) {
if (!strings[i].isEmpty()) {
try {
itemStacks[i] = StreamSerializer.getDefault().deserializeItemStack(strings[i]);
} catch (Exception e) {
MegaEssentials.logger.warning("Error decoding item using ProtocolLib, Error: " + e.getMessage());
}
}
}
return itemStacks;
}
Additional context
Error: Unable to find writeStack(class net.minecraft.world.item.ItemStack) in class net.minecraft.network.FriendlyByteBuf
i had it working on 1.20.4 idk if its just my problem or somebody else does have it
Make sure you're doing the following
/reload
Describe the question So i am on Purpur 1.20.6 Java 23 and Protocollib 5.3.0, i have had an working Inventory Syncer and Enderchest Plugin but now i am getting an error when trying to seralize items, so how to fix that?
API method(s) used i am uisng the StreamSerializer Class with the StreamSerializer#getDefault()#serializeItemStack()
Expected behavior i expect it to serialize the items correctly so that i can save them and then deserailze them wehn needed
Code Serialize: public String toBase64(ItemStack[] itemStacks) throws IOException { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < itemStacks.length; i++) { if (i > 0) { stringBuilder.append(";"); } if ((itemStacks[i] != null) && (itemStacks[i].getType() != Material.AIR)) { stringBuilder.append(StreamSerializer.getDefault().serializeItemStack(itemStacks[i])); } } return stringBuilder.toString(); }
Deserialize: public ItemStack[] fromBase64(String data) { String[] strings = data.split(";"); ItemStack[] itemStacks = new ItemStack[strings.length]; for (int i = 0; i < strings.length; i++) { if (!strings[i].isEmpty()) { try { itemStacks[i] = StreamSerializer.getDefault().deserializeItemStack(strings[i]); } catch (Exception e) { MegaEssentials.logger.warning("Error decoding item using ProtocolLib, Error: " + e.getMessage()); } } } return itemStacks; }
Additional context Error: Unable to find writeStack(class net.minecraft.world.item.ItemStack) in class net.minecraft.network.FriendlyByteBuf i had it working on 1.20.4 idk if its just my problem or somebody else does have it