Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

  • Author

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

  • Author

ok, I solved it :)

 

has some minor flaws but I justed copied and modified some things and it worked.

Thanks for the help anyway :)

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.