Search in sources :

Example 1 with CactusFeature

use of com.almuradev.content.type.cactus.CactusFeature in project Almura by AlmuraDev.

the class CactusGeneratorImpl method decorate.

@SubscribeEvent
public void decorate(final DecorateBiomeEvent.Decorate event) {
    if (event.getType() != DecorateBiomeEvent.Decorate.EventType.CACTUS || event.getResult() == Event.Result.DENY) {
        return;
    }
    final World world = event.getWorld();
    if (!this.in(world)) {
        return;
    }
    final DoubleRange chance = this.chance(world.getBiome(event.getPos()));
    if (chance == null || chance.max() == 0) {
        return;
    }
    final Random random = event.getRand();
    if (random.nextDouble() <= (chance.random(random) / 100d)) {
        final int x = random.nextInt(16) + 8;
        final int z = random.nextInt(16) + 8;
        final BlockPos pos = world.getHeight(event.getPos().add(x, 0, z));
        ((CactusFeature) this.cactus.require()).generate(world, random, pos, this.requires);
        event.setResult(Event.Result.DENY);
    }
}
Also used : DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) CactusFeature(com.almuradev.content.type.cactus.CactusFeature) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

CactusFeature (com.almuradev.content.type.cactus.CactusFeature)1 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)1 Random (java.util.Random)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1