forked from KryptonCaptain/MagicBees
-
Notifications
You must be signed in to change notification settings - Fork 23
/
HiveType.java
176 lines (140 loc) · 6.13 KB
/
HiveType.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
package magicbees.block.types;
import java.util.ArrayList;
import java.util.Collections;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import magicbees.bees.BeeGenomeManager;
import magicbees.bees.BeeSpecies;
import magicbees.bees.HiveDrop;
import magicbees.item.types.CombType;
import magicbees.main.CommonProxy;
import magicbees.main.Config;
import magicbees.main.utils.compat.ForestryHelper;
public enum HiveType {
CURIOUS("curious", BeeSpecies.MYSTICAL, 12, true),
UNUSUAL("unusual", BeeSpecies.UNUSUAL, 12, true),
RESONANT("resonant", BeeSpecies.SORCEROUS, 12, true),
DEEP("deep", BeeSpecies.ATTUNED, 4, false),
INFERNAL("infernal", BeeSpecies.INFERNAL, 15, false),
OBLIVION("oblivion", BeeSpecies.OBLIVION, 7, false),;
private static String[] nameList;
private String name;
private BeeSpecies occupant;
public boolean show;
private int lightLevel;
private ArrayList<IHiveDrop> drops;
@SideOnly(Side.CLIENT)
private IIcon[] icons;
public static HiveType getHiveFromMeta(int meta) {
HiveType type = CURIOUS;
if (meta > 0 && meta < HiveType.values().length) {
type = HiveType.values()[meta];
}
return type;
}
public static void initHiveData() {
ItemStack[] combs = new ItemStack[] { Config.combs.getStackForType(CombType.MUNDANE) };
HiveDrop valiantDrop = new HiveDrop(
BeeGenomeManager.addRainResist(ForestryHelper.getTemplateForestryForSpecies("Valiant")),
combs,
5);
CURIOUS.drops.add(new HiveDrop(BeeSpecies.MYSTICAL.getGenome(), combs, 80).setIgnoblePercentage(0.7f));
CURIOUS.drops.add(new HiveDrop(BeeGenomeManager.addRainResist(BeeSpecies.MYSTICAL.getGenome()), combs, 15));
CURIOUS.drops.add(valiantDrop);
UNUSUAL.drops.add(new HiveDrop(BeeSpecies.UNUSUAL.getGenome(), combs, 80).setIgnoblePercentage(0.7f));
UNUSUAL.drops.add(new HiveDrop(BeeGenomeManager.addRainResist(BeeSpecies.UNUSUAL.getGenome()), combs, 15));
UNUSUAL.drops.add(valiantDrop);
RESONANT.drops.add(new HiveDrop(BeeSpecies.SORCEROUS.getGenome(), combs, 80).setIgnoblePercentage(0.7f));
RESONANT.drops.add(new HiveDrop(BeeGenomeManager.addRainResist(BeeSpecies.SORCEROUS.getGenome()), combs, 20));
RESONANT.drops.add(valiantDrop);
DEEP.drops.add(new HiveDrop(BeeSpecies.ATTUNED.getGenome(), combs, 80).setIgnoblePercentage(0.65f));
DEEP.drops.add(new HiveDrop(BeeGenomeManager.addRainResist(BeeSpecies.ATTUNED.getGenome()), combs, 20));
DEEP.drops.add(valiantDrop);
combs = new ItemStack[] { Config.combs.getStackForType(CombType.MOLTEN),
new ItemStack(Items.glowstone_dust, 6) };
INFERNAL.drops.add(new HiveDrop(BeeSpecies.INFERNAL.getGenome(), combs, 80).setIgnoblePercentage(0.5f));
INFERNAL.drops.add(new HiveDrop(ForestryHelper.getTemplateForestryForSpecies("Steadfast"), combs, 3));
combs = new ItemStack[] { Config.combs.getStackForType(CombType.FORGOTTEN),
new ItemStack(Items.ender_pearl, 1) };
OBLIVION.drops.add(new HiveDrop(BeeSpecies.OBLIVION.getGenome(), combs, 80));
OBLIVION.drops.add(new HiveDrop(ForestryHelper.getTemplateForestryForSpecies("Steadfast"), combs, 9));
}
private HiveType(String hiveName, BeeSpecies occupant, int light, boolean visible) {
this.name = hiveName;
this.occupant = occupant;
this.lightLevel = light;
this.show = visible;
this.drops = new ArrayList<IHiveDrop>();
}
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister register) {
for (HiveType type : HiveType.values()) {
type.icons = new IIcon[2];
type.icons[0] = register.registerIcon(CommonProxy.DOMAIN + ":beehive." + type.ordinal() + ".top");
type.icons[1] = register.registerIcon(CommonProxy.DOMAIN + ":beehive." + type.ordinal() + ".side");
}
}
@SideOnly(Side.CLIENT)
public IIcon getIconForSide(int side) {
IIcon i = this.icons[0];
if (side != 0 && side != 1) {
i = this.icons[1];
}
return i;
}
public int getLightValue() {
return this.lightLevel;
}
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> hiveDrops = new ArrayList<ItemStack>();
int dart;
Collections.shuffle(this.drops);
// Get a princess.
int throttle = 0;
while (hiveDrops.size() <= 0 && throttle < 10) {
++throttle;
for (IHiveDrop drop : drops) {
dart = world.rand.nextInt(100);
if (dart <= drop.getChance(world, x, y, z)) {
hiveDrops.add(drop.getPrincess(world, x, y, z, fortune));
break;
}
}
}
// Get a drone, maybe.
for (IHiveDrop drop : drops) {
dart = world.rand.nextInt(100);
if (dart <= drop.getChance(world, x, y, z)) {
hiveDrops.addAll(drop.getDrones(world, x, y, z, fortune));
break;
}
}
// Get additional drops.
for (IHiveDrop drop : drops) {
dart = world.rand.nextInt(100);
if (dart <= drop.getChance(world, x, y, z)) {
hiveDrops.addAll(drop.getAdditional(world, x, y, z, fortune));
}
}
return hiveDrops;
}
public static String[] getAllNames() {
return (nameList == null) ? nameList = generateNames() : nameList;
}
public BeeSpecies getOccupant() {
return this.occupant;
}
private static String[] generateNames() {
String[] names = new String[values().length];
for (int i = 0; i < names.length; ++i) {
names[i] = values()[i].name;
}
return names;
}
}