forked from KryptonCaptain/MagicBees
-
Notifications
You must be signed in to change notification settings - Fork 23
/
HiveDescription.java
188 lines (160 loc) · 7.67 KB
/
HiveDescription.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package magicbees.bees;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import magicbees.block.types.HiveType;
import magicbees.main.Config;
import magicbees.main.utils.BlockUtil;
import magicbees.main.utils.LogHelper;
import magicbees.world.feature.FeatureOreVein;
import magicbees.world.feature.HiveGenNether;
import magicbees.world.feature.HiveGenOblivion;
import magicbees.world.feature.HiveGenUnderground;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.apiculture.hives.HiveManager;
import forestry.api.apiculture.hives.IHiveDescription;
import forestry.api.apiculture.hives.IHiveGen;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
public enum HiveDescription implements IHiveDescription {
CURIOUS(HiveType.CURIOUS, 3.0f, HiveManager.genHelper.tree(), false, BiomeDictionary.Type.FOREST,
BiomeDictionary.Type.PLAINS, BiomeDictionary.Type.HILLS),
UNUSUAL(HiveType.UNUSUAL, 1.0f, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass), false,
BiomeDictionary.Type.PLAINS, BiomeDictionary.Type.MOUNTAIN, BiomeDictionary.Type.HILLS,
BiomeDictionary.Type.RIVER),
RESONANT(HiveType.RESONANT, 0.9f, HiveManager.genHelper.ground(Blocks.sand, Blocks.sandstone), false,
BiomeDictionary.Type.SANDY, BiomeDictionary.Type.MESA, BiomeDictionary.Type.HOT,
BiomeDictionary.Type.MAGICAL),
DEEP(HiveType.DEEP, 5.0f, new HiveGenUnderground(10, 15, 5), true, BiomeDictionary.Type.HILLS,
BiomeDictionary.Type.MOUNTAIN, BiomeDictionary.Type.MAGICAL) {
@Override
public void postGen(World world, int x, int y, int z) {
super.postGen(world, x, y, z);
Random random = world.rand;
FeatureOreVein.redstoneGen.generateVein(world, random, x + 1, y, z, 5);
FeatureOreVein.redstoneGen.generateVein(world, random, x - 1, y, z, 5);
FeatureOreVein.redstoneGen.generateVein(world, random, x, y + 1, z, 5);
FeatureOreVein.redstoneGen.generateVein(world, random, x, y - 1, z, 5);
FeatureOreVein.redstoneGen.generateVein(world, random, x, y, z + 1, 5);
FeatureOreVein.redstoneGen.generateVein(world, random, x, y, z - 1, 5);
}
},
INFERNAL(HiveType.INFERNAL, 50.0f, new HiveGenNether(0, 175, 6), true, BiomeDictionary.Type.NETHER) {
@Override
public void postGen(World world, int x, int y, int z) {
super.postGen(world, x, y, z);
Random random = world.rand;
FeatureOreVein.netherQuartzGen.generateVein(world, random, x + 1, y, z, 4);
FeatureOreVein.netherQuartzGen.generateVein(world, random, x - 1, y, z, 4);
FeatureOreVein.netherQuartzGen.generateVein(world, random, x, y + 1, z, 4);
FeatureOreVein.netherQuartzGen.generateVein(world, random, x, y - 1, z, 4);
FeatureOreVein.netherQuartzGen.generateVein(world, random, x, y, z + 1, 4);
FeatureOreVein.netherQuartzGen.generateVein(world, random, x, y, z - 1, 4);
}
},
INFERNAL_OVERWORLD(HiveType.INFERNAL, 0.95f, new HiveGenUnderground(5, 13, 6), true, BiomeDictionary.Type.MAGICAL,
BiomeDictionary.Type.HOT) {
@Override
public void postGen(World world, int x, int y, int z) {
super.postGen(world, x, y, z);
Random random = world.rand;
FeatureOreVein.glowstoneGen.generateVein(world, random, x + 1, y, z, world.rand.nextInt(4) + 1);
FeatureOreVein.glowstoneGen.generateVein(world, random, x - 1, y, z, world.rand.nextInt(4) + 1);
if (BlockUtil.canBlockReplaceAt(world, x, y + 1, z, Blocks.stone)) {
world.setBlock(x, y + 1, z, Blocks.glowstone, 0, 3);
}
if (BlockUtil.canBlockReplaceAt(world, x, y - 1, z, Blocks.stone)) {
world.setBlock(x, y - 1, z, Blocks.glowstone, 0, 3);
}
FeatureOreVein.glowstoneGen.generateVein(world, random, x, y, z + 1, world.rand.nextInt(4) + 1);
FeatureOreVein.glowstoneGen.generateVein(world, random, x, y, z - 1, world.rand.nextInt(4) + 1);
}
},
OBLIVION(HiveType.OBLIVION, 20.0f, new HiveGenOblivion(), true, BiomeDictionary.Type.END) {
@Override
public void postGen(World world, int x, int y, int z) {
super.postGen(world, x, y, z);
int obsidianSpikeHeight = world.rand.nextInt(8) + 3;
for (int i = 1; i < obsidianSpikeHeight && y - i > 0; ++i) {
world.setBlock(x, y - i, z, Blocks.obsidian, 0, 2);
}
}
},
OBLIVION_OVERWORLD(HiveType.OBLIVION, 0.87f, new HiveGenUnderground(5, 5, 5), true, BiomeDictionary.Type.MAGICAL,
BiomeDictionary.Type.COLD) {
@Override
public void postGen(World world, int x, int y, int z) {
super.postGen(world, x, y, z);
Random random = world.rand;
FeatureOreVein.endStoneGen.generateVein(world, random, x + 1, y, z, world.rand.nextInt(6) + 1);
FeatureOreVein.endStoneGen.generateVein(world, random, x - 1, y, z, world.rand.nextInt(6) + 1);
FeatureOreVein.endStoneGen.generateVein(world, random, x, y + 1, z, world.rand.nextInt(3) + 1);
FeatureOreVein.endStoneGen.generateVein(world, random, x, y - 1, z, world.rand.nextInt(3) + 1);
FeatureOreVein.endStoneGen.generateVein(world, random, x, y, z + 1, world.rand.nextInt(6) + 1);
FeatureOreVein.endStoneGen.generateVein(world, random, x, y, z - 1, world.rand.nextInt(6) + 1);
}
};
private static boolean logSpawns = Config.logHiveSpawns;
private final HiveType hiveType;
private final float genChance;
private final List<BiomeDictionary.Type> biomes = new ArrayList<BiomeDictionary.Type>();
private final IHiveGen hiveGen;
private final boolean spawnsIgnoreClimate;
private HiveDescription(HiveType type, float chance, IHiveGen genType, boolean ignoreClimate,
BiomeDictionary.Type... goodBiomeTypes) {
hiveType = type;
genChance = chance;
hiveGen = genType;
spawnsIgnoreClimate = ignoreClimate;
for (BiomeDictionary.Type biomeType : goodBiomeTypes) {
biomes.add(biomeType);
}
}
@Override
public IHiveGen getHiveGen() {
return hiveGen;
}
@Override
public Block getBlock() {
return Config.hive;
}
@Override
public int getMeta() {
return hiveType.ordinal();
}
@Override
public boolean isGoodBiome(BiomeGenBase biome) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
for (BiomeDictionary.Type type : types) {
if (biomes.contains(type)) {
return true;
}
}
return false;
}
@Override
public boolean isGoodHumidity(EnumHumidity humidity) {
return spawnsIgnoreClimate || hiveType.getOccupant().canWorkInHumidity(humidity);
}
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return spawnsIgnoreClimate || hiveType.getOccupant().canWorkInTemperature(temperature);
}
@Override
public float getGenChance() {
return genChance;
}
@Override
public void postGen(World world, int x, int y, int z) {
if (logSpawns) {
LogHelper.info(
"Spawned " + this.toString()
.toLowerCase(Locale.ENGLISH) + " hive at: X " + x + ", Y: " + y + ", Z: " + z);
}
}
}