BackpacksRemastered

BackpacksRemastered

1M Downloads

[BUG] After putting a custom weapon from Drehmul v2 Primordial into a backpack, it loses its texture.

giusmatt opened this issue ยท 4 comments

commented

I'm playing on a 1.15.2 Spigot Server with the Drehmal v2 Primordial map loaded on. The mapmakers exploited optifine + a custom resource pack to assign a different texture to some special weapons which are based off an iron sword (and I guess custon NBT tags).

The bug consists of the item losing the texture after putting it in a backpack. (so I think the NBT tags are stored in such a way that they are somewhat changed after picking up the item again)

Steps to reproduce the behavior:

  1. Set up the Spigot Server, the custom map, and client side optifine + the resource given by the creators.
  2. Give yourself a custom weapon (ex. Peace Treaty, found in the creative inventory) and a backpack from this plugin.
  3. Put the sword in the backpack, close the backpack, reopen it and see that the sword has the standard iron sword texture.
  4. There is no way I've found to let the sword have the custom texture again.

image
image
image
image

I also analyzed the tags. There was one difference in the "display" tag:
image
image

Version info
image

commented

So its been forever and idk if you still care, but I did test it 1.16.4 / OptiFine HD U G7 / Forge 35.1.37 / BP2022.1.6 and the "Peace Treaty" keeps its texture. So, I am going to close this. I'm guessing this is the hotfix you and your friends figured out.

Really nice resource pack and map. Bests to ya!

commented

I haven't verified this yet, but from the photos, it appears the lore of the item is using the newer JSON based color codes which aren't parsed in this context. However, these are converted to normal char color codes when saved in the backpack (which are parsed in every context).

That's why the color appears in the chat message for the broken item's display tag. This is also what is probably breaking the item.

What's interesting is that I use "org.bukkit.util.io.BukkitObjectOutputStream" for serializing items. So, this conversion is being done by craftbukkit's API (likely as an optimization to save space). A theoretical fix would be to hijack the item serialization methods of chests which shouldn't suffer from this issue.

I will try to get on this when I can, but it may be a while. This info is here if you can't wait and wanted to try implementing a fix yourself.

commented

Thank you! In the meantime I've been investigating on this with my friends (we know just a bit about programming in general - but no java at all) and we actually found a hotfix (in the resource pack) that will work out for now. We changed the nbt name request in the resource pack with a wild card (*) so that optifine still recognize the item even if there is formatting code in the tag. This will also mean that an anvil can change a standard weapon giving it a special texture, but this is fine for us since we will not be doing it on purpose. We won't try to touch your code for now because of total lack in java knowledge.

Thank you very much for your time and for the plugin, which is great!

(sidenote: we're trying to create an optifine resource pack for the backpacks - so that they don't appear as armor - and key. If the result is pleasant we may post as a suggestion topic later)

commented

Sounds good. As for the resource pack, assuming you follow the code of conduct, I will accept about anything into the repo. If it gets to a state that you like, make a pull request, and we can work on getting the changes in.