Jump to content

[1.8] Problem concerning custom Tree


Brickfix

Recommended Posts

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!

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.