Posted September 18, 201312 yr I noticed while debugging and testing that if you add methods to a block's class and then load a world where blocks have already been placed, it will crash: "error while ticking block" I'm not talking about changing block IDs or anything crazy like that, simply adding a few new methods (no, not removing methods). How does one go about updating their mod or adding new features after it's been released to the public without breaking the worlds people have built? I can't put my finger on it yet but sometimes I have to delete my test world or it simply crashes over and over after making changes. I assumed that as long as you weren't deleting methods then it would be fine.
September 18, 201312 yr Your probably doing something wrong when adding in the code, because it should not be crashing when you start up the world. if (You.likescoding == false){ You.goaway; }
September 18, 201312 yr That is very odd because as far as I know the save files don't store any object references. Could you show us the error log? Might give some clues. -TGG
September 18, 201312 yr The worlds only store Block ID's and metadata, unless there are TE's involved If you give us the crash logs and a more detailed description of what you are trying to do, then we should be better able to help you edit: Are you replacing the block entierly or are you manipulating it's class file by ASM? If you guys dont get it.. then well ya.. try harder...
September 18, 201312 yr Author I don't have a crash log at the moment but if I get another I'll definitely post it. I'm not using ASM but there are TileEntities involved. What I did was place a block to see if the TileEntity's fields were set properly, then I quit the game and added a couple new methods to the block's class file and I think one new method to the TileEntity. When I started the world again it crashed instantly with that "error ticking block". I had to delete the world and recreate it. I was under the impression that the TileEntity would still function because Minecraft doesn't save the actual TileEntity but rather it's fields. When you load your world it calls createNewTileEntity which returns a blank TileEntity that is then populated from readNBT(). This should allow you to add new features without breaking existing worlds.
September 18, 201312 yr Well, it is likely that you tried to use or load data that didn't exist the first time you placed the block and saved it. You would need to catch those cases and save some default value.
September 19, 201312 yr Author Well, it is likely that you tried to use or load data that didn't exist the first time you placed the block and saved it. You would need to catch those cases and save some default value. NBT returns zero on an attempt to retrieve a value for a key that has not been saved. None of the fields in my TileEntity would cause a crash with a value of zero. Worst case is the block would display the wrong texture or light value, or allow someone who is not the block's owner to interact with it.
September 19, 201312 yr I was thinking about List, Map, Arrays or other data structure rather than a simple int.
September 19, 201312 yr Author I was thinking about List, Map, Arrays or other data structure rather than a simple int. Oh, I don't store anything that complex. I only track the owner of the block (string) so not just anyone can fiddle with it as well as a few integers and floats. That's why I was surprised when it crashed after making a change. More than likely I did something I shouldn't but I'll have to wait until next time because once I remade the world it stopped crashing. I'm certain it had to do with my TileEntity though because the offending class is the only one that makes use of it.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.