GiantNuker Posted January 1, 2017 Posted January 1, 2017 I need this to place a root block, how would i do this? here is my code: @SubscribeEvent(priority = EventPriority.LOWEST) public void addRootBlockWgen(DecorateBiomeEvent.Decorate event) { if (event.getType() == DecorateBiomeEvent.Decorate.EventType.TREE) { BlockPos root_pos = event.getPos().add(0, -2, 0); //BlockPlanks.EnumType t = event.getWorld().getBlockState(event.getPos()).getValue(BlockNewLog.VARIANT); event.getWorld().setBlockState(root_pos, TreesDropSaplings.roots.getStateFromMeta(TreesDropSaplings.roots.getMetaForState(0, BlockPlanks.EnumType.OAK))); } } The Y position is 0, how do I find the Y without using a for loop. Or is there a different method I can use? Quote
Koward Posted January 1, 2017 Posted January 1, 2017 I wrote something exactly like that some weeks ago for a project I contribute to. It works well but it also identifies 4 logs in some village houses (bottom corners). I can't see a way to fix that. The idea is : For each position in a 16x16 chunk intersection (cross shaped, that's what is populated after the event) start from the heighest block and go down until it reaches the terrain surface. Then, look two blocks above to check if they are logs. Your mistake was to use the Decorate event. If you look where it's called, you'll see it's called before tree (and big mushroom) generation. It's not something triggered for individual trees, you actually need to iterate through the chunk intersection. Actual source on Github : https://github.com/BeetoGuy/BetterWithMods/blob/master/src/main/java/betterwithmods/event/StumpingEventHandler.java https://github.com/BeetoGuy/BetterWithMods/blob/master/src/main/java/betterwithmods/blocks/BlockStump.java Quote
GiantNuker Posted January 1, 2017 Author Posted January 1, 2017 So the X and Z for the block position are A) The chunk numbers B) The X and Z coords of the chunk I was using .Post before but there is no .getType() method for that And what is the difference between LOG, LOG2 & LEAVES, LEAVES2 EDIT: Hastebin link isn't working anymore Quote
Draco18s Posted January 1, 2017 Posted January 1, 2017 B) The X and Z coords of the chunk Correct. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
GiantNuker Posted January 1, 2017 Author Posted January 1, 2017 Here's The Mod https://minecraft.curseforge.com/projects/forestspread Quote
Koward Posted January 2, 2017 Posted January 2, 2017 So the X and Z for the block position are A) The chunk numbers B) The X and Z coords of the chunk I was using .Post before but there is no .getType() method for that And what is the difference between LOG, LOG2 & LEAVES, LEAVES2 EDIT: Hastebin link isn't working anymore You can find the code with the Github links I gave in my post. In my method, x and z are World-based coordinates. The only time I use something Chunk-based is to get the highest block, and I explicitly convert x and z with &15. There's no getType() because it would not make any sense. The Decorate event is triggered before the generation of all <getType>. Before generation of trees, before generation of pumpkins, etc. The Post event is triggered after the generation of everything. We look for trees in the actual, final, generated world. I defined a pattern "tree" as some suitable block (like dirt or grass) with two logs above it, feel free to adapt the code for any other use. I'm aware my solution is not ideal, but I can't see a better one without new Forge hooks. About LOG2&LEAVES2, it's just Mojang who created new blocks when Acacia and Dark oak trees were added. Quote
GiantNuker Posted January 2, 2017 Author Posted January 2, 2017 Thanks for the info about LOG2 & LEAVES2, my last post had a link to the mod if you want to see v1.0, I checked it out with my brother, and it works really well, thanks for the worldgen advice! Quote
Recommended Posts
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.