Jump to content

Recommended Posts

Posted

Greetings! I've been trying to figure out why my bonemeal event for custom trees isn't working. I've got it to generate a tree but not in the manner I intended. Have a look.

 

This is what happens when I initially bonemeal the sapling.

GzVRbSR.png

 

When I re-log or right click on the top leaf blocks they disappear.

M08YaJ7.png

 

The second image is what I want the outcome to be. I really don't understand why this isn't working could anyone help me out? It would be extremely appreciated as I have been trying to figure this out for quite some time and I'm getting frustrated. I assume what's happening is that when I bonemeal the sapling it tries to create a tree twice but only creates one but the blocks are still there until they're updated. I have no idea how to fix this. Again any help is really appreciated! Thank you!

 

Custom Tree World Gen Class - http://pastebin.com/HgK6KFEe

 

Custom Tree Sapling Class - http://pastebin.com/G59Btuga

 

Bonemeal Event Class - http://pastebin.com/3kMRMKC2

Posted

The code for your bonemeal event seems pretty complicated.  Not sure why you need such complicated code to simply grow your tree, but anyway I suggest you just add System.out.println() type console statements at each point in your code to output information that shows what's happening in the code logic.  In other words, if you think a certain if statement should test true then you print out the value of the field before you test it to confirm that your assumptions are correct, and so forth.

 

Usually if you trace the logic of your code step-by-step with console messages you'll quickly find out the exact problem with the code logic.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Thank you for the reply, I've figured out part of it. For some reason it's going through the event code twice. When I print something out in the console where all the other code is, it comes up twice. I have no idea why this is and it's incredibly frustrating. Have any ideas? And of course, any help is greatly appreciated.

Posted

Most likely client & server. Check for world.isRemote == false.

this. It also explains why you get a "ghost" version - your client thinks it is there but it's not, so when you try to interact the server says "nuh-uh" and kills the block that isn't there.

 

One interesting way to check is to actually build the mod and put it in a player environment (i.e. your normal Forge install, not the Eclipse environment) and all (or at least most) of the messages will then be prefixed with <Client> or <Server> as appropriate.

Posted

Thank you guys a lot for the help, I really appreciate it and I've applauded you all as I have managed to get this to work. For anyone curious I changed the code in the event class from this.

@ForgeSubscribe
public void bonemealUsed(BonemealEvent event)
{
	if(event.world.getBlockId(event.X, event.Y, event.Z) == Main.blockTulipTreeSapling.blockID)
	{
		((BlockTulipTreeSapling)Main.blockTulipTreeSapling).growTree(event.world, event.X, event.Y, event.Z, event.world.rand);
		event.setResult(Result.ALLOW);
	}
}

To this.

@ForgeSubscribe
public void bonemealUsed(BonemealEvent event)
{
	if(event.world.getBlockId(event.X, event.Y, event.Z) == Main.blockTulipTreeSapling.blockID && event.world.isRemote == false)
	{
		((BlockTulipTreeSapling)Main.blockTulipTreeSapling).growTree(event.world, event.X, event.Y, event.Z, event.world.rand);
		event.setResult(Result.ALLOW);
	}
}

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.