package com.yolp900.itsjustacharm.common.events; import com.yolp900.itsjustacharm.common.world.TintedTreeGenerator; import net.minecraft.init.Biomes; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.Random; public class EventTintedTreeGenerator { @SubscribeEvent(priority = EventPriority.LOWEST) public void decorate(DecorateBiomeEvent.Decorate event) { World world = event.getWorld(); Biome biome = world.getBiomeGenForCoords(event.getPos()); Random rand = event.getRand(); if ((biome == Biomes.PLAINS || biome == Biomes.ICE_PLAINS || biome == Biomes.MUTATED_PLAINS || biome == Biomes.EXTREME_HILLS_WITH_TREES || biome == Biomes.MUTATED_EXTREME_HILLS_WITH_TREES) && event.getType() == DecorateBiomeEvent.Decorate.EventType.TREE) { if (rand.nextDouble() > 0.1) return; int x = rand.nextInt(16) + 8; int y = rand.nextInt(16) + 8; TintedTreeGenerator gen = new TintedTreeGenerator(); gen.generateTree(rand, world, world.getHeight(event.getPos().add(x, 0, y))); event.setResult(Event.Result.DENY); } } }