-
Notifications
You must be signed in to change notification settings - Fork 81
/
NetherBerryBushesGenerator.java
116 lines (93 loc) · 4.36 KB
/
NetherBerryBushesGenerator.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.progwml6.natura.world.worldgen;
import java.util.Random;
import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.nether.NaturaNether;
import com.progwml6.natura.world.worldgen.berry.nether.NetherBerryBushGenerator;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.fml.common.IWorldGenerator;
public class NetherBerryBushesGenerator implements IWorldGenerator
{
public static NetherBerryBushesGenerator INSTANCE = new NetherBerryBushesGenerator();
//@formatter:off
NetherBerryBushGenerator blightberryBushGen;
NetherBerryBushGenerator duskberryBushGen;
NetherBerryBushGenerator skyberryBushGen;
NetherBerryBushGenerator stingberryBushGen;
//@formatter:on
public NetherBerryBushesGenerator()
{
this.blightberryBushGen = new NetherBerryBushGenerator(NaturaNether.netherBerryBushBlightberry.getDefaultState());
this.duskberryBushGen = new NetherBerryBushGenerator(NaturaNether.netherBerryBushDuskberry.getDefaultState());
this.skyberryBushGen = new NetherBerryBushGenerator(NaturaNether.netherBerryBushSkyberry.getDefaultState());
this.stingberryBushGen = new NetherBerryBushGenerator(NaturaNether.netherBerryBushStingberry.getDefaultState());
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
this.generateNether(random, chunkX, chunkZ, world);
}
public void retroGen(Random random, int chunkX, int chunkZ, World world)
{
this.generateNether(random, chunkX, chunkZ, world);
world.getChunkFromChunkCoords(chunkX, chunkZ).setChunkModified();
}
public void generateNether(Random random, int chunkX, int chunkZ, World world)
{
int xSpawn, ySpawn, zSpawn;
int xPos = chunkX * 16 + 8;
int zPos = chunkZ * 16 + 8;
BlockPos position;
if (this.shouldGenerateInDimension(world.provider.getDimension()))
{
if (world.provider.doesWaterVaporize())
{
if (Config.generateBlightberries && random.nextInt(Config.blightberrySpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(Config.blightberrySpawnRange) + 16;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.blightberryBushGen.generateBush(random, world, position);
}
if (Config.generateDuskberries && random.nextInt(Config.duskberrySpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(Config.duskberrySpawnRange) + 16;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.duskberryBushGen.generateBush(random, world, position);
}
if (Config.generateSkyberries && random.nextInt(Config.skyberrySpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(Config.skyberrySpawnRange) + 16;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.skyberryBushGen.generateBush(random, world, position);
}
if (Config.generateStingberries && random.nextInt(Config.stingberrySpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(Config.stingberrySpawnRange) + 16;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.stingberryBushGen.generateBush(random, world, position);
}
}
}
}
public boolean shouldGenerateInDimension(int dimension)
{
for (int dimensionId : Config.netherWorldGenBlacklist)
{
if (dimension == dimensionId)
{
return false;
}
}
return true;
}
}