Started by
Zergmazter
on
Topic category: General discussion
I've googled it, searched the forums here, searched the minecraft forums, and anything I could imagine but there seems to be no info on how to select Birch, Acacia, Dark Oak, etc woods for code.
For example if (event.world.getBlock(X, Y, Z) == Blocks.log), Blocks.log will always assume it's Oak, and there is no way of choosing any of the other ones, that I know of. I spent 8 months trying to make an event handler and I finally did it. This however is beyond me. Without any documentation Im solely dependent on finding random code by chance that actually does what I'm trying to do. Please help me.
Edited by Zergmazter on Tue, 08/07/2018 - 16:22
The fact that you are using a version before introducing blockstate system makes it kinda messy, but what you want to do is ,after the check for the block itself, checking for a metadata value of the block, that you can get using World#getBlockMetadata() The method takes as arguments the coordinates of the block and returns a value of type int. All you have to do is then to do a check for whatever metadata you need.
Omg Thank you Nuparu00!!!! I had spent 30 hours trying to find the answer and you just gave me the key. It's all working woohoo! Thanks!!!
Ok so everything worked so far, but my code is having a bug when I try to place metadata on the
event.world.setBlock(X, Y, Z, Blocks.planks); //Currently Blocks.stone as a place holder//. If I do
event.world.setBlock(X, Y, Z, Blocks.planks,1,0); I get a block update error in the minecraft environment test. I can hear the block being placed but there is no visual update, therefore it still looks like the log:1 block. After doing a quick block update by breaking the neighboring block, then finally planks:1 becomes visible. The code:
The bugged code:
The flag argument in World#setBlock() has to be 3, if you want it to be updated OR you can use the World#setBlock() method, that does not take the flag argument + World#setBlockMetadataWithNotify(), which takes 3 arguments of type int for coordinates, one int for metadata and one int for the flag (again with value 3)
Thank you so much Nuparu00
I'm getting the hang of this. It's all working now. I finally have an idea what those Int are for.