diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
6 files changed, 1370 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index a4af51f4e5..9bdf9a83dd 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -6,6 +6,8 @@ import java.lang.reflect.Method; import cpw.mods.fml.common.Optional; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.forestry.bees.custom.GTPP_Bees; +import gtPlusPlus.xmod.forestry.bees.custom.GTPP_Branch_Definition; import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry; import gtPlusPlus.xmod.forestry.bees.recipe.FR_Gregtech_Recipes; import net.minecraft.block.Block; @@ -15,13 +17,13 @@ public class HANDLER_FR { public static void preInit(){ if (LoadedMods.Forestry){ - FR_ItemRegistry.Register(); - } + FR_ItemRegistry.Register(); + } } public static void Init(){ if (LoadedMods.Forestry){ - + new GTPP_Bees(); } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java new file mode 100644 index 0000000000..8217fafdcb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/CustomCombs.java @@ -0,0 +1,117 @@ +package gtPlusPlus.xmod.forestry.bees.custom; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.util.Utils; + +public enum CustomCombs { + //Custom Bees + + //Rubbers & Silicons + SILICON("silicon", true, Materials.Silicon, 100), + RUBBER("rubber", true, Materials.Rubber, 100), + PLASTIC("polyethylene", true, Materials.Plastic, 75), + PTFE("polytetrafluoroethylene", true, GTPP_Bees.PTFE, 50), + PBS("styrene butadiene", true, GTPP_Bees.PBS, 25), + + //Fuels + BIOMASS("biomass", true, Materials.Biomass, 100), + ETHANOL("ethanol", true, Materials.Ethanol, 75), + DIESEL("diesel", true, Materials.Fuel, 50), + NITRO("nitro", true, Materials.NitroFuel, 25), + HOOTCH("hootch", true, Materials.Silicon, 50), + ROCKETFUEL("rocket", true, Materials.Silicon, 25), + + + //Materials which are hard, if not impossible to obtain. + FLUORINE("fluorine", true, Materials.Fluorine, 25), + COKE("coke", true, Materials._NULL, 50), + FORCE("force", true, Materials.Force, 50), + NIKOLITE("nikolite", true, Materials.Nikolite, 75), + MITHRIL("mithril", true, Materials.Mithril, 10), + ADAMANTIUM("adamantium", true, Materials.Adamantium, 5), + + //Trash + SALT("salt", true, Materials.Salt, 75), + SAND("sand", true, Materials.Sand, 100), + + ; + + private static int[][] colours = new int[][]{ + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, //SILICON + {Utils.rgbtoHexValue(55, 55, 55), Utils.rgbtoHexValue(75, 75, 75)}, //RUBBER + {Utils.rgbtoHexValue(245, 245, 245), Utils.rgbtoHexValue(175, 175, 175)}, //PLASTIC + {Utils.rgbtoHexValue(150, 150, 150), Utils.rgbtoHexValue(75, 75, 75)}, //PTFE + {Utils.rgbtoHexValue(33, 26, 24), Utils.rgbtoHexValue(23, 16, 14)}, //PBS + //Unused + {Utils.rgbtoHexValue(33, 225, 24), Utils.rgbtoHexValue(23, 175, 14)}, //Biofuel + {Utils.rgbtoHexValue(255, 128, 0), Utils.rgbtoHexValue(220, 156, 32)}, //Ethanol + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(30, 230, 230), Utils.rgbtoHexValue(10, 150, 150)}, // Fluorine + {Utils.rgbtoHexValue(250, 250, 20), Utils.rgbtoHexValue(200, 200, 5)}, // Force + {Utils.rgbtoHexValue(60, 180, 200), Utils.rgbtoHexValue(40, 150, 170)}, // Nikolite + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, // + {Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)}, + {0x666666, 0x525252}, + {0x2E8F5B, 0xDCC289}, + {0x4C4C4C, 0x333333}, + {0x808080, 0x999999}, + {0x57CFFB, 0xBBEEFF}, + {0x7D0F0F, 0xD11919}, + {0x1947D1, 0x476CDA}, + {0xE6005C, 0xCC0052}, + {0x0033CC, 0x00248F}, + {0xCCFFFF, 0xA3CCCC}, + {0x248F24, 0xCCFFCC}, + {0x248F24, 0x2EB82E}, + {0xD4D4D4, 0x58300B}, + {0xFF6600, 0xE65C00}, + {0xD4D4D4, 0xDDDDDD}, + {0x666699, 0xA3A3CC}, + {0xDA9147, 0xDE9C59}, + {0x808080, 0x999999}, + {0x8585AD, 0x9D9DBD}, + {0xF0DEF0, 0xF2E1F2}, + {0xC2C2D6, 0xCECEDE}, + {0xE6B800, 0xCFA600}, + {0x008AB8, 0xD6D6FF}, + {0xD5D5D5, 0xAAAAAA}, + {0xCC99FF, 0xDBB8FF}, + {0xEBA1EB, 0xF2C3F2}, + {0x62626D, 0x161620}, + {0xE6E6E6, 0xFFFFCC}, + {0xDADADA, 0xD1D1E0}, + {0x19AF19, 0x169E16}, + {0x335C33, 0x6B8F00}, + {0x003300, 0x002400}, + }; + public boolean showInList; + public Materials material; + public int chance; + private String name; + private CustomCombs(String pName, boolean show, Materials material, int chance) { + this.name = pName; + this.material = material; + this.chance = chance; + this.showInList = show; + } + + public void setHidden() { + this.showInList = false; + } + + public String getName() { +// return "gt.comb."+this.name; + return GT_LanguageManager.addStringLocalization("comb." + this.name, this.name.substring(0, 1).toUpperCase() + this.name.substring(1) + " Comb"); + } + + public int[] getColours() { + return colours[this.ordinal()]; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java new file mode 100644 index 0000000000..00d8c4307d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -0,0 +1,879 @@ +package gtPlusPlus.xmod.forestry.bees.custom; + +import forestry.api.apiculture.*; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.apiculture.genetics.Bee; +import forestry.apiculture.genetics.BeeDefinition; +import forestry.apiculture.genetics.BeeVariation; +import forestry.apiculture.genetics.IBeeDefinition; +import forestry.core.genetics.alleles.AlleleHelper; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.BiomeDictionary.Type; + +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.commons.lang3.text.WordUtils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Locale; + +public enum GTPP_Bee_Definition implements IBeeDefinition { + + + SILICON(GTPP_Branch_Definition.ORGANIC, "Silicon", true, Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getSlagComb(), 0.10f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SILICON), 0.20f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getGregtechBeeType("SLIMEBALL"), getGregtechBeeType("STICKYRESIN"), 10); + } + }, + + RUBBER(GTPP_Branch_Definition.ORGANIC, "Rubber", true, Utils.rgbtoHexValue(55, 55, 55), Utils.rgbtoHexValue(75, 75, 75)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getSlagComb(), 0.10f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.RUBBER), 0.30f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getGregtechBeeType("SLIMEBALL"), getGregtechBeeType("STICKYRESIN"), 10); + } + }, + + PLASTIC(GTPP_Branch_Definition.ORGANIC, "Plastic", true, Utils.rgbtoHexValue(245, 245, 245), Utils.rgbtoHexValue(175, 175, 175)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PLASTIC), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(RUBBER.species, getGregtechBeeType("OIL"), 10); + } + }, + + PTFE(GTPP_Branch_Definition.ORGANIC, "Ptfe", true, Utils.rgbtoHexValue(150, 150, 150), Utils.rgbtoHexValue(75, 75, 75)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PTFE), 0.10f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(RUBBER.species, PLASTIC.species, 10); + } + }, + + PBS(GTPP_Branch_Definition.ORGANIC, "Pbs", true, Utils.rgbtoHexValue(33, 26, 24), Utils.rgbtoHexValue(23, 16, 14)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PTFE), 0.10f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(PTFE.species, PLASTIC.species, 10); + } + }, + + + + + /** + * Fuels + */ + + BIOMASS(GTPP_Branch_Definition.ORGANIC, "Biomass", true, Utils.rgbtoHexValue(33, 225, 24), Utils.rgbtoHexValue(23, 175, 14)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SAND), 0.40f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.BIOMASS), 0.20f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Industrious"), getSpecies("Rural"), 10); + tMutation.restrictBiomeType(Type.FOREST); + } + }, + + ETHANOL(GTPP_Branch_Definition.ORGANIC, "Ethanol", true, Utils.rgbtoHexValue(255, 128, 0), Utils.rgbtoHexValue(220, 156, 32)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SAND), 0.40f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.BIOMASS), 0.20f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(BIOMASS.species, getSpecies("Farmed"), 5); + tMutation.restrictBiomeType(Type.FOREST); + } + }, + + + + + + + + + + + + + + + + + + + + + + /** + * Materials + */ + + + FLUORINE(GTPP_Branch_Definition.ORGANIC, "Fluorine", true, Utils.rgbtoHexValue(30, 230, 230), Utils.rgbtoHexValue(10, 150, 150)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.40f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.FLUORINE), 0.05f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.COLD); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getGregtechBeeType("LAPIS"), getGregtechBeeType("SAPPHIRE"), 5); + tMutation.restrictBiomeType(Type.COLD); + } + }, + + //Coke + + + + //Force + FORCE(GTPP_Branch_Definition.METAL, "Force", true, Utils.rgbtoHexValue(250, 250, 20), Utils.rgbtoHexValue(200, 200, 5)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SAND), 0.25f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.FORCE), 0.25f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SALT), 0.05f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.HOT); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getGregtechBeeType("STEEL"), getGregtechBeeType("GOLD"), 10); + tMutation.restrictBiomeType(Type.HOT); + } + }, + + //Nikolite + NIKOLITE(GTPP_Branch_Definition.METAL, "Nikolite", true, Utils.rgbtoHexValue(60, 180, 200), Utils.rgbtoHexValue(40, 150, 170)) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(getStoneComb(), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.NIKOLITE), 0.05f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.HOT); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getGregtechBeeType("ALUMINIUM"), getGregtechBeeType("SILVER"), 8); + tMutation.restrictBiomeType(Type.HOT); + } + }, + + + + + + + + /* + + + CLAY(GTPP_Branch_Definition.ORGANIC, "Clay", true, 0x19d0ec, 0xffdc16) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); + beeSpecies.addProduct(new ItemStack(Items.clay_ball, 1), 0.15f); + beeSpecies.setHumidity(EnumHumidity.DAMP); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.MEADOWS.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Industrious"), getSpecies("Diligent"), 20); + } + }, + SLIMEBALL(GTPP_Branch_Definition.ORGANIC, "SlimeBall", true, 0x4E9E55, 0x00FF15) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 15), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STICKY), 0.30f); + beeSpecies.setHumidity(EnumHumidity.DAMP); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.MARSHY.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Marshy"), CLAY.species, 15); + } + }, + PEAT(GTPP_Branch_Definition.ORGANIC, "Peat", true, 0x906237, 0x58300B) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.LIGNIE), 0.30f); + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.RURAL.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Rural"), CLAY.species, 20); + } + }, + STICKYRESIN(GTPP_Branch_Definition.ORGANIC, "StickyResin", true, 0x2E8F5B, 0xDCC289) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); + beeSpecies.addProduct(ItemList.IC2_Resin.get(1, new Object[0]), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.MEADOWS.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(SLIMEBALL.species, PEAT.species, 25); + } + }, + COAL(GTPP_Branch_Definition.ORGANIC, "Coal", true, 0x666666, 0x525252) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.LIGNIE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.COAL), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.AUSTERE.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Industrious"), PEAT.species, 18); + } + }, + OIL(GTPP_Branch_Definition.ORGANIC, "Oil", true, 0x4C4C4C, 0x333333) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 0), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.OIL), 0.15f); + beeSpecies.setHumidity(EnumHumidity.DAMP); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + beeSpecies.setNocturnal(); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.MEADOWS.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(COAL.species, STICKYRESIN.species, 8); + } + }, + REDSTONE(GTPP_Branch_Definition.GEM, "Redstone", true, 0x7D0F0F, 0xD11919) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.REDSTONE), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Industrious"), getSpecies("Demonic"), 20); + } + }, + LAPIS(GTPP_Branch_Definition.GEM, "Lapis", true, 0x1947D1, 0x476CDA) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.LAPIS), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Demonic"), getSpecies("Imperial"), 20); + } + }, + CERTUS(GTPP_Branch_Definition.GEM, "CertusQuartz", true, 0x57CFFB, 0xBBEEFF) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.CERTUS), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Hermitic"), LAPIS.species, 20); + } + }, + RUBY(GTPP_Branch_Definition.GEM, "Ruby", true, 0xE6005C, 0xCC0052) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.RUBY), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(REDSTONE.species, DIAMOND.species, 10); + } + }, + SAPPHIRE(GTPP_Branch_Definition.GEM, "Sapphire", true, 0x0033CC, 0x00248F) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SAPPHIRE), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(CERTUS.species, LAPIS.species, 10); + } + }, + DIAMOND(GTPP_Branch_Definition.GEM, "Diamond", true, 0xCCFFFF, 0xA3CCCC) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.DIAMOND), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(CERTUS.species, COAL.species, 6); + } + }, + OLIVINE(GTPP_Branch_Definition.GEM, "Olivine", true, 0x248F24, 0xCCFFCC) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.OLIVINE), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(CERTUS.species, getSpecies("Ended"), 10); + } + }, + EMERALD(GTPP_Branch_Definition.GEM, "Emerald", true, 0x248F24, 0x2EB82E) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STONE), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.EMERALD), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.COLD); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(OLIVINE.species, DIAMOND.species, 8); + } + }, + COPPER(GTPP_Branch_Definition.METAL, "Copper", true, 0xFF6600, 0xE65C00) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.COPPER), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(getSpecies("Majestic"), CLAY.species, 25); + } + }, + TIN(GTPP_Branch_Definition.METAL, "Tin", true, 0xD4D4D4, 0xDDDDDD) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.TIN), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(CLAY.species, getSpecies("Diligent"), 25); + } + }, + LEAD(GTPP_Branch_Definition.METAL, "Lead", true, 0x666699, 0xA3A3CC) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.LEAD), 0.15f); + beeSpecies.setHumidity(EnumHumidity.DAMP); + beeSpecies.setTemperature(EnumTemperature.WARM); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(COAL.species, COPPER.species, 25); + } + }, + IRON(GTPP_Branch_Definition.METAL, "Iron", true, 0xDA9147, 0xDE9C59) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.IRON), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(TIN.species, COPPER.species, 25); + } + }, + STEEL(GTPP_Branch_Definition.METAL, "Steel", true, 0x808080, 0x999999) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.STEEL), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(IRON.species, COAL.species, 20); + } + }, + NICKEL(GTPP_Branch_Definition.METAL, "Nickel", true, 0x8585AD, 0x8585AD) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.NICKEL), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(IRON.species, COPPER.species, 25); + } + }, + ZINC(GTPP_Branch_Definition.METAL, "Zinc", true, 0xF0DEF0, 0xF2E1F2) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.ZINC), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(IRON.species, TIN.species, 20); + } + }, + SILVER(GTPP_Branch_Definition.METAL, "Silver", true, 0xC2C2D6, 0xCECEDE) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SILVER), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(LEAD.species, TIN.species, 20); + } + }, + GOLD(GTPP_Branch_Definition.METAL, "Gold", true, 0xEBC633, 0xEDCC47) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.GOLD), 0.15f); + beeSpecies.setHumidity(EnumHumidity.NORMAL); + beeSpecies.setTemperature(EnumTemperature.NORMAL); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(LEAD.species, COPPER.species, 20); + } + }, + ALUMINIUM(GTPP_Branch_Definition.RAREMETAL, "Aluminium", true, 0xB8B8FF, 0xD6D6FF) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.ALUMINIUM), 0.15f); + beeSpecies.setHumidity(EnumHumidity.ARID); + beeSpecies.setTemperature(EnumTemperature.HOT); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(NICKEL.species, ZINC.species, 18); + } + }, + TITANIUM(GTPP_Branch_Definition.RAREMETAL, "Titanium", true, 0xCC99FF, 0xDBB8FF) { + @Override + protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SLAG), 0.30f); + beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.TITANIUM), 0.15f); + beeSpecies.setHumidity(EnumHumidity.ARID); + beeSpecies.setTemperature(EnumTemperature.HOT); + } + + @Override + protected void setAlleles(IAllele[] template) { + template = BeeDefinition.COMMON.getTemplate(); + } + + @Override + protected void registerMutations() { + IBeeMutationCustom tMutation = registerMutation(REDSTONE.species, ALUMINIUM.species, 5); + } + }*/ + + ; + + + private final GTPP_Branch_Definition branch; + private final IAlleleBeeSpeciesCustom species; + + private IAllele[] template; + private IBeeGenome genome; + + GTPP_Bee_Definition(GTPP_Branch_Definition branch, String binomial, boolean dominant, int primary, int secondary) { + String lowercaseName = this.toString().toLowerCase(Locale.ENGLISH); + String species = "species" + WordUtils.capitalize(lowercaseName); + + String uid = "forestry." + species; + String description = "for.description." + species; + String name = "for.bees.species." + lowercaseName; + + this.branch = branch; + this.species = BeeManager.beeFactory.createSpecies(uid, dominant, "Sengir", name, description, branch.getBranch(), binomial, primary, secondary); + } + + public static void initBees() { + for (GTPP_Bee_Definition bee : values()) { + bee.init(); + } + for (GTPP_Bee_Definition bee : values()) { + bee.registerMutations(); + } + } + + private static IAlleleBeeSpecies getSpecies(String name) { + return (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele((new StringBuilder()).append("forestry.species").append(name).toString()); + } + + protected abstract void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies); + + protected abstract void setAlleles(IAllele[] template); + + protected abstract void registerMutations(); + + private void init() { + setSpeciesProperties(species); + + template = branch.getTemplate(); + AlleleHelper.instance.set(template, EnumBeeChromosome.SPECIES, species); + setAlleles(template); + + genome = BeeManager.beeRoot.templateAsGenome(template); + + BeeManager.beeRoot.registerTemplate(template); + } + + protected final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance) { + IAllele[] template = getTemplate(); + Utils.LOG_INFO("[Bees-Debug] parent1: "+(parent1 != null)); + Utils.LOG_INFO("[Bees-Debug] parent2: "+(parent2 != null)); + Utils.LOG_INFO("[Bees-Debug] chance: "+(chance)); + Utils.LOG_INFO("[Bees-Debug] template: "+(template != null)); + return BeeManager.beeMutationFactory.createMutation(parent1, parent2, template, chance); + } + + @Override + public final IAllele[] getTemplate() { + return Arrays.copyOf(template, template.length); + } + + @Override + public final IBeeGenome getGenome() { + return genome; + } + + @Override + public final IBee getIndividual() { + return new Bee(genome); + } + + @Override + public final ItemStack getMemberStack(EnumBeeType beeType) { + IBee bee = getIndividual(); + return BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal()); + } + + public final IBeeDefinition getRainResist() { + return new BeeVariation.RainResist(this); + } + + private static ItemStack getSlagComb(){ + return issStackValid(ItemUtils.getSimpleStack(GTPP_Bees.Comb_Slag, 1)); + } + private static ItemStack getStoneComb(){ + return issStackValid(ItemUtils.getSimpleStack(GTPP_Bees.Comb_Stone, 1)); + } + + private static ItemStack issStackValid(ItemStack result){ + if (result == null){ + return ItemUtils.getSimpleStack(ModItems.AAA_Broken); + } + return result; + } + + public static IAlleleBeeSpecies getGregtechBeeType(String name){ + Class<?> gtBees; + try { + Class gtBeeTypes = Class.forName("gregtech.loaders.misc.GT_BeeDefinition"); + Enum gtBeeEnumObject = Enum.valueOf(gtBeeTypes, name); + Field gtBeesField = FieldUtils.getDeclaredField(gtBeeTypes, "species", true); + gtBeesField.setAccessible(true); + ReflectionUtils.makeAccessible(gtBeesField); + Object beeType = gtBeesField.get(gtBeeEnumObject); + return (IAlleleBeeSpecies) beeType; + } + catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java new file mode 100644 index 0000000000..d26e34ba89 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -0,0 +1,125 @@ +package gtPlusPlus.xmod.forestry.bees.custom; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import cpw.mods.fml.common.Loader; +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class GTPP_Bees { + + //Base Comb Item + public static ItemCustomComb combs; + + //Combs obtained via reflection + public static ItemStack Comb_Slag; + public static ItemStack Comb_Stone; + + //Materials obtained via reflection + public static Materials PTFE; + public static Materials PBS; + + //public static GTPP_Branch_Definition definition; + + + public GTPP_Bees() { + if (Loader.isModLoaded("Forestry") /*&& tryGetBeesBoolean()*/) { + + //Set Bee Defs from GT via Reflection + //definition = new GTPP_Branch_Definition(); + + //Set Materials and Comb stacks from GT via Reflection + setMaterials(); + + combs = new ItemCustomComb(); + combs.initCombsRecipes(); + GTPP_Bee_Definition.initBees(); + } + } + + private static boolean tryGetBeesBoolean(){ + try { + Class<?> mProxy = Class.forName("gregtech.GT_Mod.gregtechproxy"); + Field mNerf = FieldUtils.getDeclaredField(mProxy, "mGTBees", true); + boolean returnValue = (boolean) mNerf.get(GT_Mod.gregtechproxy); + return returnValue; + } + catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { + return false; + } + } + + private void setMaterials(){ + try { + + Class<?> gtBees = Class.forName("gregtech.loaders.misc.GT_Bees"); + Class<?> gtCombItemClass = Class.forName("gregtech.common.items.ItemComb"); + Class gtCombEnumClass = Class.forName("gregtech.common.items.CombType"); + Field gtCombs = FieldUtils.getDeclaredField(gtBees, "combs", true); + gtCombs.setAccessible(true); + ReflectionUtils.makeAccessible(gtCombs); + Enum gtCombTypeSlag = Enum.valueOf(gtCombEnumClass, "SLAG"); + Enum gtCombTypeStone = Enum.valueOf(gtCombEnumClass, "STONE"); + Item oCombObject = (Item) gtCombs.get(null); + + Utils.LOG_INFO("[Bees-Debug] Field getModifiers: "+gtCombs.getModifiers()); + Utils.LOG_INFO("[Bees-Debug] Field toGenericString: "+gtCombs.toGenericString()); + Utils.LOG_INFO("[Bees-Debug] Field getClass: "+gtCombs.getClass()); + Utils.LOG_INFO("[Bees-Debug] Field isEnumConstant: "+gtCombs.isEnumConstant()); + Utils.LOG_INFO("[Bees-Debug] Field isSynthetic: "+gtCombs.isSynthetic()); + Utils.LOG_INFO("[Bees-Debug] Field get(gtBees) != null: "+(gtCombs.get(gtBees) != null)); + Utils.LOG_INFO("[Bees-Debug] Field isAccessible: "+gtCombs.isAccessible()); + + + Utils.LOG_INFO("[Bees] gtBees: "+(gtBees != null)); + Utils.LOG_INFO("[Bees] gtCombItemClass: "+(gtCombItemClass != null)); + Utils.LOG_INFO("[Bees] gtCombEnumClass: "+(gtCombEnumClass != null)); + Utils.LOG_INFO("[Bees] gtCombs: "+(gtCombs != null)); + Utils.LOG_INFO("[Bees] gtCombTypeSlag: "+(gtCombTypeSlag != null)); + Utils.LOG_INFO("[Bees] gtCombTypeStone: "+(gtCombTypeStone != null)); + Utils.LOG_INFO("[Bees] oCombObject: "+(oCombObject != null)); + + + if (gtCombItemClass.isInstance(oCombObject)){ + Method getStackForType; + getStackForType = gtCombItemClass.getDeclaredMethod("getStackForType", gtCombEnumClass); + + if (getStackForType != null) { + Utils.LOG_INFO("[Bees] Found Method: getStackForType"); + } + if (Comb_Slag == null){ + Comb_Slag = (ItemStack) getStackForType.invoke(gtBees, gtCombTypeSlag); + } + if (Comb_Stone == null){ + Comb_Stone = (ItemStack) getStackForType.invoke(gtBees, gtCombTypeStone); + } + } + else { + Utils.LOG_INFO("[Bees] oCombObject was not an instance of gregtech.common.items.ItemComb"); + } + + } + catch (NullPointerException | ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | SecurityException | InvocationTargetException e){ + Utils.LOG_INFO("[Bees] Bad Reflection. setMaterials()"); + } + + PTFE = trySetValue("Polytetrafluoroethylene"); + PBS = trySetValue("StyreneButadieneRubber"); + } + + private Materials trySetValue(String material){ + Materials mTemp = Materials.valueOf(material); + if (mTemp != null){ + return mTemp; + } + return Materials._NULL; + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Branch_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Branch_Definition.java new file mode 100644 index 0000000000..add7198bd8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Branch_Definition.java @@ -0,0 +1,80 @@ +package gtPlusPlus.xmod.forestry.bees.custom; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IClassification; +import gtPlusPlus.core.util.Utils; + +public enum GTPP_Branch_Definition { + + ORGANIC("ORGANIC"), + GEM("GEM"), + METAL("METAL"), + RAREMETAL("RAREMETAL"), + RADIOACTIVE("RADIOACTIVE"); + + final String mFieldName; + final Enum mActualValues; + GTPP_Branch_Definition(String mValue){ + this.mFieldName = mValue; + this.mActualValues = setEnumVar(mValue); + } + + public final IAllele[] getTemplate() { + Class gtBranchDefClass; + try { + gtBranchDefClass = Class.forName("gregtech.loaders.misc.GT_BranchDefinition"); + Enum enumA = mActualValues; + Method methodMyMethod = gtBranchDefClass.getMethod("getTemplate"); + + Utils.LOG_INFO("[Bees] gtBranchDefClass: "+(gtBranchDefClass != null)); + Utils.LOG_INFO("[Bees] enumA: "+(enumA != null)); + Utils.LOG_INFO("[Bees] methodMyMethod: "+(methodMyMethod != null)); + + return (IAllele[]) methodMyMethod.invoke(enumA); + } + catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Utils.LOG_INFO("[Bees] Bad Reflection. getTemplate()"); + e.printStackTrace(); + //gregtech.loaders.misc.GT_BranchDefinition.getTemplate() + return null; + } + } + + public final IClassification getBranch() { + Class gtBranchDefClass; + try { + gtBranchDefClass = Class.forName("gregtech.loaders.misc.GT_BranchDefinition"); + Enum enum_MY_SAMPLE_ENUM = mActualValues; + Method methodMyMethod = gtBranchDefClass.getMethod("getBranch"); + + + Utils.LOG_INFO("[Bees] gtBranchDefClass: "+(gtBranchDefClass != null)); + Utils.LOG_INFO("[Bees] enum_MY_SAMPLE_ENUM: "+(enum_MY_SAMPLE_ENUM != null)); + Utils.LOG_INFO("[Bees] methodMyMethod: "+(methodMyMethod != null)); + + return (IClassification) methodMyMethod.invoke(enum_MY_SAMPLE_ENUM); + } + catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Utils.LOG_INFO("[Bees] Bad Reflection. getBranch()"); + e.printStackTrace(); + return null; + } + } + + private Enum setEnumVar(String value){ + try { + Class gtBranchDefClass = Class.forName("gregtech.loaders.misc.GT_BranchDefinition"); + Enum branchDef = Enum.valueOf(gtBranchDefClass, value); + return branchDef; + } + catch (ClassNotFoundException e){ + return null; + } + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java new file mode 100644 index 0000000000..a927f217d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java @@ -0,0 +1,164 @@ +package gtPlusPlus.xmod.forestry.bees.custom; + +import com.google.common.collect.ImmutableMap; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.api.recipes.RecipeManagers; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.lang.reflect.Field; +import java.util.List; + +import org.apache.commons.lang3.reflect.FieldUtils; + +public class ItemCustomComb extends Item { + @SideOnly(Side.CLIENT) + private IIcon secondIcon; + + public ItemCustomComb() { + super(); + this.setCreativeTab(Tabs.tabApiculture); + this.setHasSubtypes(true); + this.setUnlocalizedName("gtpp.comb"); + GameRegistry.registerItem(this, "gtpp.comb", CORE.MODID); + } + + public ItemStack getStackForType(CustomCombs type) { + return new ItemStack(this, 1, type.ordinal()); + } + + public ItemStack getStackForType(CustomCombs type, int count) { + return new ItemStack(this, count, type.ordinal()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tabs, List list) { + for (CustomCombs type : CustomCombs.values()) { + if (type.showInList) { + list.add(this.getStackForType(type)); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public int getRenderPasses(int meta) { + return 2; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + this.itemIcon = par1IconRegister.registerIcon("forestry:beeCombs.0"); + this.secondIcon = par1IconRegister.registerIcon("forestry:beeCombs.1"); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return (pass == 0) ? itemIcon : secondIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) { + int meta = Math.max(0, Math.min(CustomCombs.values().length - 1, stack.getItemDamage())); + int colour = CustomCombs.values()[meta].getColours()[0]; + + if (pass >= 1) { + colour = CustomCombs.values()[meta].getColours()[1]; + } + + return colour; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return CustomCombs.values()[stack.getItemDamage()].getName(); + } + + public void initCombsRecipes() { + ItemStack tComb; + + tComb = getStackForType(CustomCombs.SILICON); + addSpecialCent(tComb, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Silicon, 1), 30); + //addProcess(tComb, Materials.Silver, 100); + //addProcess(tComb, Materials.Galena, 100); + + tComb = getStackForType(CustomCombs.RUBBER); + addSpecialCent(tComb, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Rubber, 1), 30); + tComb = getStackForType(CustomCombs.PLASTIC); + addSpecialCent(tComb, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Plastic, 1), 20); + tComb = getStackForType(CustomCombs.PTFE); + addSpecialCent(tComb, GT_OreDictUnificator.get(OrePrefixes.dustTiny, GTPP_Bees.PTFE, 1), 10); + tComb = getStackForType(CustomCombs.PBS); + addSpecialCent(tComb, GT_OreDictUnificator.get(OrePrefixes.dustTiny, GTPP_Bees.PBS, 1), 5); + + } + public void addSpecialCent(ItemStack tComb, ItemStack aOutput, int chance){ + GT_Values.RA.addCentrifugeRecipe(tComb, GT_Values.NI, GT_Values.NF, GT_Values.NF, aOutput, ItemList.FR_Wax.get(1, new Object[0]), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[] { chance * 100, 3000 }, 128, 5); + RecipeManagers.centrifugeManager.addRecipe(40, tComb, ImmutableMap.of(aOutput, chance * 0.01f, ItemList.FR_Wax.get(1, new Object[0]), 0.3f)); + } + + public void addSpecialCent(ItemStack tComb, ItemStack aOutput, int chance, ItemStack aOutput2, int chance2){ + GT_Values.RA.addCentrifugeRecipe(tComb, GT_Values.NI, GT_Values.NF, GT_Values.NF, aOutput, ItemList.FR_Wax.get(1, new Object[0]), aOutput2, GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[] { chance * 100, 3000, chance2 * 100 }, 128, 5); + RecipeManagers.centrifugeManager.addRecipe(40, tComb, ImmutableMap.of(aOutput, chance * 0.01f, ItemList.FR_Wax.get(1, new Object[0]), 0.3f,aOutput2,chance2 * 0.01f)); + } + + public void addSpecialCent(ItemStack tComb, ItemStack aOutput, int chance, ItemStack aOutput2, int chance2, ItemStack aOutput3, int chance3){ + GT_Values.RA.addCentrifugeRecipe(tComb, GT_Values.NI, GT_Values.NF, GT_Values.NF, aOutput, ItemList.FR_Wax.get(1, new Object[0]), aOutput2, aOutput3, GT_Values.NI, GT_Values.NI, new int[] { chance * 100, 3000, chance2 * 100, chance3*100 }, 128, 5); + RecipeManagers.centrifugeManager.addRecipe(40, tComb, ImmutableMap.of(aOutput, chance * 0.01f, ItemList.FR_Wax.get(1, new Object[0]), 0.3f,aOutput2,chance2 * 0.01f,aOutput3,chance3*0.01f)); + } + + public void addProcess(ItemStack tComb, Materials aMaterial, int chance){ + if(tryGetNerfBoolean()){ + GT_Values.RA.addChemicalRecipe(GT_Utility.copyAmount(9, tComb), GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1), Materials.Water.getFluid(1000), aMaterial.mOreByProducts.isEmpty() ? null : aMaterial.mOreByProducts.get(0).getMolten(144), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aMaterial, 4), 96); + GT_Values.RA.addAutoclaveRecipe(GT_Utility.copyAmount(16, tComb), Materials.UUMatter.getFluid(Math.max(1, ((aMaterial.getMass()+9)/10))), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aMaterial, 1), 10000, (int) (aMaterial.getMass() * 128), 384); + }else{ + GT_Values.RA.addCentrifugeRecipe(tComb, GT_Values.NI, GT_Values.NF, GT_Values.NF, GT_OreDictUnificator.get(OrePrefixes.dustTiny, aMaterial, 1), ItemList.FR_Wax.get(1, new Object[0]), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[] { chance * 100, 3000 }, 128, 5); + RecipeManagers.centrifugeManager.addRecipe(40, tComb, ImmutableMap.of(GT_OreDictUnificator.get(OrePrefixes.dustTiny, aMaterial, 1), chance * 0.01f, ItemList.FR_Wax.get(1, new Object[0]), 0.3f)); + } + } + + public void addProcess(ItemStack tComb, Materials aInMaterial, Materials aOutMaterial, int chance){ + if(tryGetNerfBoolean()){ + GT_Values.RA.addChemicalRecipe(GT_Utility.copyAmount(9, tComb), GT_OreDictUnificator.get(OrePrefixes.crushed, aInMaterial, 1), Materials.Water.getFluid(1000), aInMaterial.mOreByProducts.isEmpty() ? null : aInMaterial.mOreByProducts.get(0).getMolten(144), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aOutMaterial, 4), 96); + GT_Values.RA.addAutoclaveRecipe(GT_Utility.copyAmount(16, tComb), Materials.UUMatter.getFluid(Math.max(1, ((aOutMaterial.getMass()+9)/10))), GT_OreDictUnificator.get(OrePrefixes.crushedPurified, aOutMaterial, 1), 10000, (int) (aOutMaterial.getMass() * 128), 384); + }else{ + GT_Values.RA.addCentrifugeRecipe(tComb, GT_Values.NI, GT_Values.NF, GT_Values.NF, GT_OreDictUnificator.get(OrePrefixes.dustTiny, aOutMaterial, 1), ItemList.FR_Wax.get(1, new Object[0]), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[] { chance * 100, 3000 }, 128, 5); + RecipeManagers.centrifugeManager.addRecipe(40, tComb, ImmutableMap.of(GT_OreDictUnificator.get(OrePrefixes.dustTiny, aOutMaterial, 1), chance * 0.01f, ItemList.FR_Wax.get(1, new Object[0]), 0.3f)); + } + } + + private static boolean tryGetNerfBoolean(){ + try { + Class mProxy = Class.forName("gregtech.GT_Mod.gregtechproxy"); + Field mNerf = FieldUtils.getDeclaredField(mProxy, "mNerfedCombs", true); + boolean returnValue = (boolean) mNerf.get(GT_Mod.gregtechproxy); + return returnValue; + } + catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { + return false; + } + } + +}
\ No newline at end of file |