Well, you use Forge and then create a class that subscribes to the terrain event bus and has method to handle the decorate event. You also create classes that copy the ones you want to modify but with your changes. Then when the events fire you can check for the EventType (TREE and such) and then when the LAKES event happens you instead run your tree code and when the TREE event happens you run your lake code.
You're getting close, but you can't just change the event type. You need to actually call your world gen code to run during your event handler and then you need to cancel the event (by returning a Result.DENY) to prevent the vanilla from happening.
but the EventType are fired per chunk or is a round cycle?
The event is called several times during each chunk generation. It is called for each type. If you want to see that just add a print statement in your event handler to print out the chunk coordinates and the event type.
now i can printlog something like: CustomDeconet.minecraftforge.event.terraingen.DecorateBiomeEvent$Decorate@665729bc
at new map generation.
Any tips to do something better? maybe printlog the EventType?
@EventHandler
public void init(FMLPreInitializationEvent event)
{
RegisterTerrainEvent.CustomTerrainEvent();
}
public class RegisterTerrainEvent {
@SubscribeEvent
public static void CustomTerrainEvent() {
MinecraftForge.TERRAIN_GEN_BUS.register(new CustomDecorate());
System.out.println("TERRAIN_GEN_BUS_Custom");
}
}
public class CustomDecorate {
@SubscribeEvent
public void onTerrainGen(Decorate event) {
System.out.println("CustomDeco" + event);
}
}
I already told you how to swap them. After you test to see what type it is, then run the code for the other one instead. If it is type TREE then run LAKE gen code and if it is type LAKE run TREE gen code.
Hi Modders,
i got a request for minecraft 1.7.10 that i think need the use of ASM that i'm not so advanced to know how work.
i need the following:
in the class net.minecraft.world.biome.BiomeDecorator.class i want to move the method on line 336:
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE);
if (doGen && this.generateLakes)
{
for (j = 0; j < 50; ++j)
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
for (j = 0; j < 20; ++j)
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
}
between line 189 and 190 so it can execute before the tree generation.
and in the class net.minecraft.world.gen.feature.WorldGenTrees at line 120 and 133 adding the following correction marked in red:
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || p_76484_2_.nextInt(2) != 0 && i3 != 0)
{
Block block1 = p_76484_1_.getBlock(i2, k1, k2);
if (block1.isAir(p_76484_1_, i2, k1, k2) || block1.isLeaves(p_76484_1_, i2, k1, k2) || block1.getMaterial() == Material.vine)
{
this.setBlockAndNotifyAdequately(p_76484_1_, i2, k1, k2, Blocks.leaves, this.metaLeaves);
}
}
}
}
}
for (k1 = 0; k1 < l; ++k1)
{
block = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_);
if (block.isAir(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_) || block.isLeaves(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_) || block.getMaterial() == Material.vine)
{
this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_, Blocks.log, this.metaWood);
if (this.vinesGrow && k1 > 0)
{
if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_))
so the vines can be repleaced by logs.
Thx.
You can just handle the terrain gen decorate events and swap them around, and replace them with your edited versions. No need for ASM.
how i can do that? In the biome construction class of my mod?
Well, you use Forge and then create a class that subscribes to the terrain event bus and has method to handle the decorate event. You also create classes that copy the ones you want to modify but with your changes. Then when the events fire you can check for the EventType (TREE and such) and then when the LAKES event happens you instead run your tree code and when the TREE event happens you run your lake code.
i want to generate lake before of trees... i'm trying to code something but i think nothing work...
for sure all wrong but in my mind that may stop trees to generate but nothing work like i want
You're getting close, but you can't just change the event type. You need to actually call your world gen code to run during your event handler and then you need to cancel the event (by returning a Result.DENY) to prevent the vanilla from happening.
but the EventType are fired per chunk or is a round cycle?
The event is called several times during each chunk generation. It is called for each type. If you want to see that just add a print statement in your event handler to print out the chunk coordinates and the event type.
now i can printlog something like: CustomDeconet.minecraftforge.event.terraingen.DecorateBiomeEvent$Decorate@665729bc
at new map generation.
Any tips to do something better? maybe printlog the EventType?
little update.
now i can see the EventType and trees are generated before of lakes....
and that during initialiation:
[15:21:23] [Client thread/INFO] [TerrainGenFix]: Mod TerrainGenFix is missing the required element 'name'. Substituting TerrainGenFix
now i can disable them but don't know how to swap them.
I already told you how to swap them. After you test to see what type it is, then run the code for the other one instead. If it is type TREE then run LAKE gen code and if it is type LAKE run TREE gen code.
I dont know how to code what you say...
in the class ChunkProviderGenerate i found some lines that probabily generate lakes at line 414 - 433. This class is executed before BiomeDecorate?
yes i can completely disable lakes by doing that: