planetguy Posted March 13, 2013 Posted March 13, 2013 I considered using enchantments, but I think it would get very ugly if I tried to hide the enchantment from the client. I'm currently looking at adding my own NBT tag to items, but I'm worried it will cause massive breakage throughout Minecraft or with other mods, and I haven't figured out how to do it. Any thoughts/tips for me?
Lethosos Posted March 13, 2013 Posted March 13, 2013 This is what I'm facing later on down the road with my mod, too. Best way is to mess with metadata--if you know how to code in binary with integers, and retrieve binary data from a number, you can store quite a bit in there. But that's likely to be not the only method out there.
planetguy Posted March 14, 2013 Author Posted March 14, 2013 I got it working, although it probably will seriously screw up anything else that uses a similar method. (It removes items from its storage by writing null to the NBT tag.) If you want to see how I make it work, check my mod Gizmos v0.2+, source is included in the download.
Lethosos Posted March 14, 2013 Posted March 14, 2013 Mmm, I see you did it with the Spy Bench. Will be an interesting read within your code. Thanks.
planetguy Posted March 14, 2013 Author Posted March 14, 2013 Lethosos A word of warning, the Spy Bench stomps any other data stored in an item's additional NBT tags when you put in or remove a hidden item. It's a time bomb if any other mods use that data. I suspect several mods do, maybe IC2 for its seeds and MMMPowersuits for its upgrades. In short, I should probably fix that as soon as possible, maybe over the weekend.
gotyaoi Posted March 14, 2013 Posted March 14, 2013 As I haven't actually installed your mod, what exactly does the spy bench do, if you don't mind my asking?
Lethosos Posted March 14, 2013 Posted March 14, 2013 A word of warning, the Spy Bench stomps any other data stored in an item's additional NBT tags when you put in or remove a hidden item. It's a time bomb if any other mods use that data. So that means I can't effectively add the equivalent of a cup holder on my pickaxe so that I could carry my favorite beer brew in it? That sucks, but understandable. More research is needed to achieve greater heights in Beerology.
planetguy Posted March 14, 2013 Author Posted March 14, 2013 As I haven't actually installed your mod, what exactly does the spy bench do, if you don't mind my asking? The spy bench allows you to hide items inside other items, for example hiding a diamond block in your stone pickaxe to smuggle it around. So that means I can't effectively add the equivalent of a cup holder on my pickaxe so that I could carry my favorite beer brew in it? You will be able to as soon as I figure out how to get rid of the horrible hack I used, which erases all existing custom NBT tags when you put spy gear in. You can even include it now, it should work just fine with vanilla tools that don't have spy gear in them. (Spy gear will simply be erased by it, not likely the end of the world for anyone)
gotyaoi Posted March 14, 2013 Posted March 14, 2013 Just a thought, instead of writing to NBT, you could use a HashMap somewhere in your code to map the item to the item stored inside of it. Just need some unique property for the item to key off of.
planetguy Posted March 15, 2013 Author Posted March 15, 2013 Just a thought, instead of writing to NBT, you could use a HashMap somewhere in your code to map the item to the item stored inside of it. Just need some unique property for the item to key off of. Probably a better solution, but at the moment I'm doing my mod quick and dirty because I have lots of ideas and not enough time. I did figure out how to not overwrite other people's NBT tags (I hope, haven't tested...) by checking if the existing tag is null before adding my own tags. I have the whole block reading additional data in a try block, and if it errors attempting to read the item there must not be an item, and erasing the old data happens at the end, after it has successfully read an item. (The reading safety is in v0.2, write safety will probably be in v0.3. In the mean time, be careful what you try to hide stuff in.)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now