-
Save inventory to player [1.12]
I didn't just copy the reference. I am a CS major, I have an idea of what I'm doing. I constructed a new InventoryPlayer, but for some reason that one was still affected when I cleared the original. It seems like a problem with copying a reference, yet I did not copy the reference- thus why I am confused.
-
Save inventory to player [1.12]
Okay, there were several more issues, but I seem to have it working perfectly now! For some reason, despite the InventoryPlayer being passed being just a copy of the original, it was still being cleared when the original was cleared. Don't know why, don't care anymore- I changed it so that the capability simply stores the items in 3 ItemStack[]'s (returning them in an ItemStack[][]). Best part? When dying, then returning to Title Screen before respawning, then rejoining and respawning, THE INVENTORY STILL LOADS SUCCESSFULLY! Thank you so much for your help!
-
Save inventory to player [1.12]
Is there a way to get the reference to the entity the capability is attached to?
-
Save inventory to player [1.12]
Right, okay. (Followed tutorial to a T, didn't realize that was a thing I had specified). Now when I die with the keeping medallion in my inventory, the entire inventory is just deleted. (I'm going to go through and set up some debug logging to see exactly where it is failing)
-
Save inventory to player [1.12]
Okay, that's fixed, but now there's a new crash. This one I know exactly the problem at least, but no clue how to fix it. Provider#serializeNBT returns NBTTagCompound, but the inventory is saved as an NBTTagList. How would I go about converting/changing this?
-
Save inventory to player [1.12]
I don't know what to tell you, I opened the crash report and copy/pasted. Here's a version with fixed spacing/newlines
-
Save inventory to player [1.12]
That's what the game gave me, exactly. Give me a minute, I'll try to make it more readable
-
Save inventory to player [1.12]
Well something is dreadfully wrong now... it crashed the instant I loaded a save. ...So from what I gather, it gets a NullPo when it checks if I am riding something? What is causing THAT? (I haven't updated the repo, but literally the only change made was changing the @SubscribeEvent to being static) Also, the error line is line 21 of the Storage class... that is the first line of a for loop... the only method called is inv.mainInventory.size(), which shouldn't be able to cause THIS.
-
Save inventory to player [1.12]
Oh... I forgot about the static thing AGAIN. Testing that now... The InventoryPlayer that is being passed is already a copy of the original, so it should work fine. (EventHandler.java , InventoryPlayer newInv = new InventoryPlayer(player))
-
Save inventory to player [1.12]
I've now spent an hour looking over capabilities and getting it to work, but I still have an issue. Code: https://github.com/venrob/RobsStuff-mcmod/tree/add-capabilities/main/java/com/venrob/robsstuff The relevant code is at /capabilities, as well as /utils/handlers/CapabilityHandler.java and /utils/handlers/EventHandler.java When the player dies, it should store the inventory in the capability, but the call to CapabilityHandler.getCapabilityInv(Entity entity) returns false. Should the entityPlayer not have the capability from the @SubscribeEvent method attachCapabilityEntity(AttachCapabilitiesEvent<Entity> event) ? What am I missing here?
-
Save inventory to player [1.12]
Okay, so I'm having some trouble here. I want to, under a certain condition, have the player's inventory (either the entire thing, or only certain items, depending on the condition) to be kept after death. Currently, I am just saving an InventoryPlayer variable which I store items in on LivingDeathEvent, and restore on PlayerEvent.Clone. There is an issue I have found, however- if the player disconnects from the server before clicking "Respawn", the inventory is completely lost- not just not kept through death, but does not drop either. What I have figured out is that I need to save the backup of the inventory to the player. Everything I can find online through searching tells me I should be using "IExtendedEntityProperties", though in 1.12 that doesn't appear to exist? How would I go about this in 1.12? (forge version is 14.23.4.2709 btw)
- Server Crash
-
Server Crash
Log: Line of my code: https://github.com/venrob/RobsStuff-mcmod/blob/master/main/java/com/venrob/robsstuff/init/ModEnchantsjava#L16 This was a server crash which happened seemingly out of nowhere, we had had 10+ hours of time on the server without any changes to my mod and without problems. I can't quite figure out what is causing this...
-
Potion Effects on Armor
No problem! Like I said, I literally had just coded this exact thing!
-
[Solved] java.lang.ExceptionInInitializerError
Thank you! I'm still confused why the error would point toward my block registry, but that was indeed the actual issue!
IPS spam blocked by CleanTalk.