Posted August 5, 201411 yr Im not sure if retrogen it the rite word for it but basically i am replacing all of one block in the world (Existing chunks) with another. I have it working when the world loads it finds all of the blocks its looking for and replaces them and everything works fine. The weird part is when i then save and quit and then go back into the world... The code runs again even though it has already replaced all of the blocks it is looking for (i have it print a message to the console for each block it finds and replaces) This is my Forge event handler class that dose all of the work. https://github.com/brandon3055/Draconic-Evolution/blob/master/src/main/java/com/brandon3055/draconicevolution/common/core/handler/MinecraftForgeEventHandler.java (skip to ChunkEvent) The blocks i am finding and the blocks i am replacing them with are from my mod https://github.com/brandon3055/Draconic-Evolution/blob/master/src/main/java/com/brandon3055/draconicevolution/common/core/utills/Utills.java https://github.com/brandon3055/Draconic-Evolution/blob/master/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java The reason i want to do this is because i made a mistake when registering some of my blocks and used their unlocalized name so they were registered as tile.blockName instead of blockName. So i corrected that error and to prevent those blocks from being deleted from existing worlds i created a block that is registered as the old name (tile.blockName) that will be changed to the correct block (by this code) on world load. I am the author of Draconic Evolution
August 5, 201411 yr It is possible that the chunk needs to be explicitly saved again after you've replaced the blocks. There is a public field called isModified which maybe you should set to true. It seems to be checked by a method called needsSaving() which likely ensures it will be saved. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 5, 201411 yr Author Thanks jabelar that seems to have fixed it! You are searching an area of 16x16x16, when a chunk is 16x256x16 for (ExtendedBlockStorage storage : chunk.getBlockStorageArray()) diesieben07 posted this code in this post http://www.minecraftforge.net/forum/index.php?topic=21625.0 from what i can tell it breaks each chunk into 16x16x16 blocks. I am the author of Draconic Evolution
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.