MAKAPKA Posted June 29, 2022 Share Posted June 29, 2022 (edited) How can I change Vanilla Minecraft Blocks that have a Custom Tag to my Custom Block using Random Ticking? Should I do this with ModFeatures or ModEvents? Differences between Features and Events? I already have ModTags and Custom Tag. Edited June 29, 2022 by MAKAPKA Quote Link to comment Share on other sites More sharing options...
MAKAPKA Posted June 29, 2022 Author Share Posted June 29, 2022 9 minutes ago, diesieben07 said: Please clarify what you mean by "ModFeatures", "ModEvents", "ModTags" and "Custom Tag". ModFeatures.class = Custom Features .class in My Own Mod ModEvents.class = Custom Events .class: package net.makapka.blacksoilmod.event; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.makapka.blacksoilmod.BlackSoilMod; @Mod.EventBusSubscriber(modid = BlackSoilMod.MOD_ID) public class ModEvents { @SubscribeEvent public static void turnToDryGrassBlock(BlockEvent event) { } } ModTags.class = Custom Tags .class: package net.makapka.blacksoilmod.util; import net.makapka.blacksoilmod.BlackSoilMod; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; public class ModTags { public static class Blocks { // Custom Tag: public static final TagKey<Block> DRY_GRASS_REPLACEABLE = tag("dried_grass_replaceable"); private static TagKey<Block> tag(String name) { return BlockTags.create(new ResourceLocation(BlackSoilMod.MOD_ID, name)); } private static TagKey<Block> forgeTag(String name) { return BlockTags.create(new ResourceLocation("forge", name)); } } public static class Items { private static TagKey<Item> tag(String name) { return ItemTags.create(new ResourceLocation(BlackSoilMod.MOD_ID, name)); } private static TagKey<Item> forgeTag(String name) { return ItemTags.create(new ResourceLocation("forge", name)); } } } dried_grass_replaceable.json : { "replace": false, "values": [ "minecraft:grass_block", "minecraft:podzol", "minecraft:mycelium" ] } Quote Link to comment Share on other sites More sharing options...
warjort Posted June 29, 2022 Share Posted June 29, 2022 AFAIK, there is no general event for random ticks on any block? The only thing I can see is forge's CropGrowEvent which only applies to StemBlocks. Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
JimiIT92 Posted June 29, 2022 Share Posted June 29, 2022 A Feature is generally used (or at least in 99% of the cases is what I've used them for) for something that can be "placed" naturally inside the world (like ores, flowers, trees, structures....). An Event is something that Forge fires when something particular occurs (like an entity being spawned, a block being placed, a message bein sent...). So in this case what you want to use is an Event that listens for a blocks ticking and then, if some random criteria you decide are met, you can turn it into your own custom block. Unfortunately, as warjort said... 32 minutes ago, warjort said: AFAIK, there is no general event for random ticks on any block So unless it comes out you need to find a "manual" solution to achieve what you want Quote Don't blame me if i always ask for your help. I just want to learn to be better Link to comment Share on other sites More sharing options...
MAKAPKA Posted June 29, 2022 Author Share Posted June 29, 2022 (edited) 1 hour ago, JimiIT92 said: So unless it comes out you need to find a "manual" solution to achieve what you want Is it possible to do this inside the Custom Block I'm going to turn the Vanilla Blocks into? I need to change Vanilla Grass Block to Custom Dried Grass Block, provided it has Lava or Fire next to it. Maybe it's easier to add a Custom Dried Grass Block to the world generation and make it propagate? Edited June 29, 2022 by MAKAPKA Quote Link to comment Share on other sites More sharing options...
warjort Posted June 29, 2022 Share Posted June 29, 2022 47 minutes ago, MAKAPKA said: Is it possible to do this inside the Custom Block I'm going to turn the Vanilla Blocks into? How would minecraft know to call code on a block that doesn't exist yet? Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
MAKAPKA Posted June 29, 2022 Author Share Posted June 29, 2022 4 minutes ago, warjort said: How would minecraft know to call code on a block that doesn't exist yet? You're right! The function I meant is the same with the propagating block. Quote Link to comment Share on other sites More sharing options...
warjort Posted June 29, 2022 Share Posted June 29, 2022 Spitballing: An alternate approach (not using random ticks) would be write your own WorldTickEvent handler that randomly changes blocks. Your world tick handler would iterate over the loaded chunks and choose random blocks in each, applying whatever logic you want. The issue is how to know the loaded chunks. This would probably involve some book-keeping on your part where you keep track of this yourself using the ChunkEvent.Load/Unload event? Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
Syric Posted June 29, 2022 Share Posted June 29, 2022 That seems... excessive. Perhaps override the default lava pool feature to include some seed blocks of dry grass, which then spread if they receive a random tick and are near lava? It does a little of what you want, I guess. A way to override the functions of a vanilla block would instantly solve your problem. This thread suggests outright replacing vanilla blocks with your new block (functionally identical to grass but with a randomtick method that dries it in the right circumstances). I'm leery of messing with vanilla because it seems like a compatibility hazard, but it might be worth investigating. Quote Link to comment Share on other sites More sharing options...
warjort Posted June 29, 2022 Share Posted June 29, 2022 If you do use that approach, I think you want to further iterate on chunk.getSections() to avoid looking parts of the chunk that are just void/air and are not really there. Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
warjort Posted June 29, 2022 Share Posted June 29, 2022 9 minutes ago, Syric said: That seems... excessive. Perhaps override the default lava pool feature to include some seed blocks of dry grass, which then spread if they receive a random tick and are near lava? It does a little of what you want, I guess. A way to override the functions of a vanilla block would instantly solve your problem. This thread suggests outright replacing vanilla blocks with your new block (functionally identical to grass but with a randomtick method that dries it in the right circumstances). I'm leery of messing with vanilla because it seems like a compatibility hazard, but it might be worth investigating. Overwriting vanilla blocks can break other mods that have used mixins to do more refined changes to them. Using mixins is another way to get the behaviour asked for on this thread. But it means it will only work for the blocks that have been modified in advance while the original poster wants to define them dynamically using tags. Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
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.