Posted June 23, 201411 yr 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. When I re-log or right click on the top leaf blocks they disappear. 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
June 23, 201411 yr 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/
June 23, 201411 yr Author 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.
June 24, 201411 yr 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. http://i1279.photobucket.com/albums/y523/textcraft/Jun%202014%20-%202/a77dd69ddfa9e622422c5e5cd7e377b14d5cdedec1b7a8e19dde68c9e22be6dfbf81219d3893f419da39a3ee5e6b4b0d3255bfef95601890afd8070929aa338b0dfc68d48355_zps0c847cf3.png[/img] I have a reputation for text walls. If you ask me a question I will most likely explain it in the most wordy way possible. -0 characters left
June 24, 201411 yr Author 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.