-
Notifications
You must be signed in to change notification settings - Fork 81
/
NetherTreesGenerator.java
143 lines (117 loc) · 6.31 KB
/
NetherTreesGenerator.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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.nether.block.leaves.BlockNetherLeaves;
import com.progwml6.natura.nether.block.leaves.BlockNetherLeaves2;
import com.progwml6.natura.nether.block.logs.BlockNetherLog;
import com.progwml6.natura.nether.block.logs.BlockNetherLog2;
import com.progwml6.natura.world.worldgen.trees.nether.BloodwoodTreeGenerator;
import com.progwml6.natura.world.worldgen.trees.nether.DarkwoodTreeGenerator;
import com.progwml6.natura.world.worldgen.trees.nether.FusewoodTreeGenerator;
import com.progwml6.natura.world.worldgen.trees.nether.GhostwoodTreeGenerator;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.fml.common.IWorldGenerator;
public class NetherTreesGenerator implements IWorldGenerator
{
public static NetherTreesGenerator INSTANCE = new NetherTreesGenerator();
//@formatter:off
DarkwoodTreeGenerator darkwoodTreeGen;
FusewoodTreeGenerator fusewoodTreeGen;
GhostwoodTreeGenerator ghostwoodTreeGen;
BloodwoodTreeGenerator bloodwoodTreeGen;
//@formatter:on
public NetherTreesGenerator()
{
IBlockState netherLog = NaturaNether.netherLog.getDefaultState();
IBlockState netherLog2 = NaturaNether.netherLog2.getDefaultState();
IBlockState netherLeaves = NaturaNether.netherLeaves.getDefaultState();
IBlockState netherLeaves2 = NaturaNether.netherLeaves2.getDefaultState();
this.darkwoodTreeGen = new DarkwoodTreeGenerator(3, netherLog.withProperty(BlockNetherLog.TYPE, BlockNetherLog.LogType.DARKWOOD), netherLeaves2.withProperty(BlockNetherLeaves2.TYPE, BlockNetherLeaves2.LeavesType.DARKWOOD), netherLeaves2.withProperty(BlockNetherLeaves2.TYPE, BlockNetherLeaves2.LeavesType.DARKWOOD_FLOWERING), netherLeaves2.withProperty(BlockNetherLeaves2.TYPE, BlockNetherLeaves2.LeavesType.DARKWOOD_FRUIT));
this.fusewoodTreeGen = new FusewoodTreeGenerator(3, netherLog.withProperty(BlockNetherLog.TYPE, BlockNetherLog.LogType.FUSEWOOD), netherLeaves.withProperty(BlockNetherLeaves.TYPE, BlockNetherLeaves.LeavesType.FUSEWOOD));
this.ghostwoodTreeGen = new GhostwoodTreeGenerator(netherLog.withProperty(BlockNetherLog.TYPE, BlockNetherLog.LogType.GHOSTWOOD), netherLeaves.withProperty(BlockNetherLeaves.TYPE, BlockNetherLeaves.LeavesType.GHOSTWOOD), true);
this.bloodwoodTreeGen = new BloodwoodTreeGenerator(netherLog2.withProperty(BlockNetherLog2.META, 15), netherLog2.withProperty(BlockNetherLog2.META, 0), netherLog2.withProperty(BlockNetherLog2.META, 1), netherLog2.withProperty(BlockNetherLog2.META, 2), netherLog2.withProperty(BlockNetherLog2.META, 3), netherLeaves.withProperty(BlockNetherLeaves.TYPE, BlockNetherLeaves.LeavesType.BLOODWOOD));
}
@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 chunkPos = new BlockPos(xPos, 0, zPos);
BlockPos position;
Biome biome = world.getChunkFromBlockCoords(chunkPos).getBiome(chunkPos, world.getBiomeProvider());
if (biome == null)
{
return;
}
if (this.shouldGenerateInDimension(world.provider.getDimension()))
{
if (BiomeDictionary.hasType(biome, Type.NETHER))
{
if (Config.generateBloodwood && random.nextInt(Config.bloodwoodSpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = 72;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.bloodwoodTreeGen.generateTree(random, world, position);
}
if (Config.generateDarkwood && random.nextInt(Config.darkwoodSpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(64) + 32;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.darkwoodTreeGen.generateTree(random, world, position);
}
if (Config.generateFusewood && random.nextInt(Config.fusewoodSpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(64) + 32;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.fusewoodTreeGen.generateTree(random, world, position);
}
if (Config.generateGhostwood && random.nextInt(Config.ghostwoodSpawnRarity) == 0)
{
for (int iter = 0; iter < 3; iter++)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = random.nextInt(80) + 16;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.ghostwoodTreeGen.generateTree(random, world, position);
}
}
}
}
}
public boolean shouldGenerateInDimension(int dimension)
{
for (int dimensionId : Config.netherWorldGenBlacklist)
{
if (dimension == dimensionId)
{
return false;
}
}
return true;
}
}