moonlyer Posted April 15, 2018 Posted April 15, 2018 (edited) Hi modders, My goal is to make some block generate on the surface realtime with some probability, just like tall grass on dirt block. For example, make dead bush appear on sand. Vanilla minecraft does this generation on tick, when block's random tick is set to true. But for sand it is false. I could override vanilla sand block and make it randomly tick, but it seems this way would have compatibility issues (if some other mod overrides basic sand too). Another option that I see - is to listen to some chunk event (for example load chunk), get access to that chunk, check if surface block is sand and with some probability - generate dead bush. This way I do not need to override any blocks, but I'm not sure about perfomance. Is there a better way to achieve my goal, or I should stick to my options? Edited April 29, 2018 by moonlyer Quote
moonlyer Posted April 15, 2018 Author Posted April 15, 2018 17 minutes ago, diesieben07 said: From your post it is not clear if you are talking about a world-generation feature or something like crops growing. Please clarify. It's something like crops growing. To be precise i want to do exactly the same like tall grass and flowers spawning randomly on the grass while the game is running, but on other already existing blocks too (vanilla or other mods). The most obvious way for me is too override existing blocks in the registry with my custom class. public class CustomBlockSand extends BlockSand { CustomBlockSand() { super(); this.setTickRandomly(true); this.setRegistryName("minecraft:sand"); this.setUnlocalizedName("sand"); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { //My tallgrass/flower spawning code } } But I feel overriding existing blocks will ruin compatibility with other mods, so I'm looking for a better way to do this. Quote
moonlyer Posted April 15, 2018 Author Posted April 15, 2018 Thanks, I thought so. Well, time to do some code shenanigans then , maybe it will get me somewhere. Quote
moonlyer Posted April 29, 2018 Author Posted April 29, 2018 If someone interested, I managed to generate tall grass realtime without overriding vanilla blocks by accesing chunk in ChunkEvent.Load event, and generating needed blocks, like worldgen does. I haven't noticed much perfomance drops. @SubscribeEvent public void onChunkLoad (ChunkEvent.Load event) { if (!event.getWorld().isRemote) { //Get random x,z in chunk; Search for surface y; Check if possible to place; Places block Elcraft.elcraftRealtimeGenerator.GenDustInChunk(event.getChunk()); } } 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.