Brickfix Posted March 3, 2015 Share Posted March 3, 2015 I am trying to generate a custom tree instead of a normal tree during worldgeneration, using an eventhandler. I encountered the problem that very often the game crashes when generating my tree, throughing a RuntimeException "Already decorating!" I used a try{} catch{} block to evade the crash, and now I am getting a lot of missing chunks (basicall giant wholes in the ground), close to a tree that failed to generate. Here is my EventHandler: public class BrickfixEventHandler { @SubscribeEvent public void BiomeDecorate(Decorate event) { if (event.type == event.type.TREE) { Random rnd = event.rand; if (rnd.nextInt(5) == 0) { GenTreeTest tree = new GenTreeTest(); try { tree.growTree(event.world, event.rand, event.pos); } catch(RuntimeException e) { System.out.println("Failed to generate custom tree at " + event.pos.getX() + ":" + event.pos.getZ()); } event.setResult(Result.DENY); } } } } on thing I notice is that in the beginning, every custom tree successfully generates, while when starting to move around, the amount of Exceptions I catch in my code drastically increase. Not every tree failes, but a high amount. Thanks for any help in advance! Quote Link to comment Share on other sites More sharing options...
Brickfix Posted March 3, 2015 Author Share Posted March 3, 2015 First of all, thanks for the fast reply. So I'm not really sure if I got this correctly, but on the Decorate event I can filter out what is actually decorating. So I can say that I only want a custom tree to generate when the eventtype is TREE. And when looking through the code, the BiomeDecorator.class calls the decorate funtion in the TerrainGen.class, which posts the Decorate event. So the Pre and Post event of the DecorateBiomeEvent doesn't help me at all (besides, I get the exact same problems) and I would not able to to generate a tree exactly where the game normally would generate trees anyway. And when browsing through an older mod (1.7.10) that does basically the same, I found out that it used the Decorate event as well to start its own tree generation. I think the actual problem seems to be some kind of loop: the game starts to decorate a chunk, than it 'sees' my event and after doing something with my event, it calls (for some reason unknown to me) the decoration again, which throughs the exception. I neither understand why and have to say that this is really strange ... Quote Link to comment Share on other sites More sharing options...
Brickfix Posted March 3, 2015 Author Share Posted March 3, 2015 ok, I solved it has some minor flaws but I justed copied and modified some things and it worked. Thanks for the help anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.