-
Notifications
You must be signed in to change notification settings - Fork 1
/
FastCountRange.java
30 lines (24 loc) · 977 Bytes
/
FastCountRange.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.terraforged.feature.fast.impl;
import com.terraforged.feature.fast.FastDecorator;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.placement.CountRangeConfig;
import java.util.Random;
public class FastCountRange extends FastDecorator<CountRangeConfig> {
public FastCountRange() {
super(CountRangeConfig::deserialize);
}
@Override
protected int getCount(CountRangeConfig config) {
return config.count;
}
@Override
protected boolean next(IWorld world, ChunkGenerator<?> generator, Random random, CountRangeConfig config, BlockPos pos, BlockPos.Mutable mutable) {
int x = random.nextInt(16) + pos.getX();
int z = random.nextInt(16) + pos.getZ();
int y = random.nextInt(config.maximum - config.topOffset) + config.bottomOffset;
mutable.setPos(x, y, z);
return true;
}
}