diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/forestry/bees/registry | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/forestry/bees/registry')
5 files changed, 371 insertions, 306 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_AlleleBeeSpecies.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_AlleleBeeSpecies.java index 222b1215eb..8258fbfcb5 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_AlleleBeeSpecies.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_AlleleBeeSpecies.java @@ -9,32 +9,49 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class GTPP_AlleleBeeSpecies extends AlleleBeeSpecies { - - public GTPP_AlleleBeeSpecies(String uid, boolean dominant, String unlocalizedName, String authority, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) { - super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor); - AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.SPECIES); - } - @Override - public IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance) { - if (product == null || product.getItem() == null) { - product = new ItemStack(Items.boat); - } - if (chance <= 0.0f || chance > 1.0f) { - chance = 0.1f; - } - return super.addProduct(product, chance); - } + public GTPP_AlleleBeeSpecies( + String uid, + boolean dominant, + String unlocalizedName, + String authority, + String unlocalizedDescription, + IClassification branch, + String binomial, + int primaryColor, + int secondaryColor) { + super( + uid, + unlocalizedName, + authority, + unlocalizedDescription, + dominant, + branch, + binomial, + primaryColor, + secondaryColor); + AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.SPECIES); + } - @Override - public IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance) { - if (specialty == null || specialty.getItem() == null) { - specialty = new ItemStack(Items.boat); - } - if (chance <= 0.0f || chance > 1.0f) { - chance = 0.1f; - } - return super.addSpecialty(specialty, chance); - } + @Override + public IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance) { + if (product == null || product.getItem() == null) { + product = new ItemStack(Items.boat); + } + if (chance <= 0.0f || chance > 1.0f) { + chance = 0.1f; + } + return super.addProduct(product, chance); + } + @Override + public IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance) { + if (specialty == null || specialty.getItem() == null) { + specialty = new ItemStack(Items.boat); + } + if (chance <= 0.0f || chance > 1.0f) { + chance = 0.1f; + } + return super.addSpecialty(specialty, chance); + } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java index f94a178007..89cb54e603 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java @@ -3,13 +3,6 @@ package gtPlusPlus.xmod.forestry.bees.registry; import static forestry.api.apiculture.EnumBeeChromosome.*; import static forestry.api.core.EnumHumidity.ARID; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Locale; -import java.util.function.Consumer; - -import org.apache.commons.lang3.text.WordUtils; - import forestry.api.apiculture.*; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -31,12 +24,22 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.GTPP_CombType; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Locale; +import java.util.function.Consumer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.BiomeDictionary.Type; +import org.apache.commons.lang3.text.WordUtils; public enum GTPP_BeeDefinition implements IBeeDefinition { - - DRAGONBLOOD(GTPP_BranchDefinition.LEGENDARY, "Dragon Blood", STANDALONE.DRAGON_METAL, true, Utils.rgbtoHexValue(220, 20, 20), Utils.rgbtoHexValue(20, 20, 20), + DRAGONBLOOD( + GTPP_BranchDefinition.LEGENDARY, + "Dragon Blood", + STANDALONE.DRAGON_METAL, + true, + Utils.rgbtoHexValue(220, 20, 20), + Utils.rgbtoHexValue(20, 20, 20), beeSpecies -> { beeSpecies.addProduct(GT_ModHandler.getModItem(GT_Values.MOD_ID_FR, "beeCombs", 1, 8), 0.30f); beeSpecies.addSpecialty(GTPP_Bees.combs.getStackForType(GTPP_CombType.DRAGONBLOOD), 0.10f); @@ -54,10 +57,15 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { IBeeMutationCustom tMutation = dis.registerMutation("DRAGONESSENCE", "NEUTRONIUM", 2); tMutation.restrictHumidity(ARID); tMutation.requireResource(STANDALONE.DRAGON_METAL.getBlock(), 1); - tMutation.addMutationCondition(new GT_Bees.DimensionMutationCondition(1, "End"));//End Dim - } - ), - FORCE(GTPP_BranchDefinition.LEGENDARY, "Force", STANDALONE.FORCE, true, Utils.rgbtoHexValue(250, 250, 20), Utils.rgbtoHexValue(200, 200, 5), + tMutation.addMutationCondition(new GT_Bees.DimensionMutationCondition(1, "End")); // End Dim + }), + FORCE( + GTPP_BranchDefinition.LEGENDARY, + "Force", + STANDALONE.FORCE, + true, + Utils.rgbtoHexValue(250, 250, 20), + Utils.rgbtoHexValue(200, 200, 5), beeSpecies -> { beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.STONE), 0.30f); beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.SALT), 0.15f); @@ -75,220 +83,254 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { dis -> { IBeeMutationCustom tMutation = dis.registerMutation("STEEL", "GOLD", 10); tMutation.restrictHumidity(ARID); - tMutation.restrictBiomeType(Type.HOT); - } - ), - + tMutation.restrictBiomeType(Type.HOT); + }), ; - private final GTPP_BranchDefinition branch; - private final GTPP_AlleleBeeSpecies species; - private final Consumer<GTPP_AlleleBeeSpecies> mSpeciesProperties; - private final Consumer<IAllele[]> mAlleles; - private final Consumer<GTPP_BeeDefinition> mMutations; - private IAllele[] template; - private IBeeGenome genome; - - GTPP_BeeDefinition(GTPP_BranchDefinition branch, String binomial, Materials aMat, boolean dominant, int primary, int secondary, Consumer<GTPP_AlleleBeeSpecies> aSpeciesProperties, Consumer<IAllele[]> aAlleles, Consumer<GTPP_BeeDefinition> aMutations) { - this(branch, binomial, MaterialUtils.generateMaterialFromGtENUM(aMat), dominant, primary, secondary, aSpeciesProperties, aAlleles, aMutations); - } - - GTPP_BeeDefinition(GTPP_BranchDefinition branch, String binomial, Material aMat, boolean dominant, int primary, int secondary, Consumer<GTPP_AlleleBeeSpecies> aSpeciesProperties, Consumer<IAllele[]> aAlleles, Consumer<GTPP_BeeDefinition> aMutations) { - this.mAlleles = aAlleles; - this.mMutations = aMutations; - this.mSpeciesProperties = aSpeciesProperties; - String lowercaseName = this.toString().toLowerCase(Locale.ENGLISH); - String species = WordUtils.capitalize(binomial); - String uid = "gtpp.bee.species" + species; - String description = "for.description." + species; - String name = "for.bees.species." + lowercaseName; - GT_LanguageManager.addStringLocalization("for.bees.species." + lowercaseName, species, true); - GTPP_Bees.sMaterialMappings.put(binomial.toLowerCase().replaceAll(" ", ""), aMat); - this.branch = branch; - this.species = new GTPP_AlleleBeeSpecies(uid, dominant, name, "GT++", description, branch.getBranch(), binomial, primary, secondary); - } - - public static void initBees() { - for (GTPP_BeeDefinition bee : values()) { bee.init(); } - for (GTPP_BeeDefinition bee : values()) { bee.registerMutations(); } - } - - protected static IAlleleBeeEffect getEffect(byte modid, String name) { - String s; - switch (modid) { - case GTPP_Bees.EXTRABEES : - s = "extrabees.effect." + name; - break; - case GTPP_Bees.GENDUSTRY : - s = "gendustry.effect." + name; - break; - case GTPP_Bees.MAGICBEES : - s = "magicbees.effect" + name; - break; - case GTPP_Bees.GREGTECH : - s = "gregtech.effect" + name; - break; - default : - s = "forestry.effect" + name; - break; - - } - return (IAlleleBeeEffect) AlleleManager.alleleRegistry.getAllele(s); - } - - protected static IAlleleFlowers getFlowers(byte modid, String name) { - String s; - switch (modid) { - case GTPP_Bees.EXTRABEES : - s = "extrabees.flower." + name; - break; - case GTPP_Bees.GENDUSTRY : - s = "gendustry.flower." + name; - break; - case GTPP_Bees.MAGICBEES : - s = "magicbees.flower" + name; - break; - case GTPP_Bees.GREGTECH : - s = "gregtech.flower" + name; - break; - default : - s = "forestry.flowers" + name; - break; - - } - return (IAlleleFlowers) AlleleManager.alleleRegistry.getAllele(s); - } - - protected static IAlleleBeeSpecies getSpecies(byte modid, String name) { - String s; - switch (modid) { - case GTPP_Bees.EXTRABEES : - s = "extrabees.species." + name; - break; - case GTPP_Bees.GENDUSTRY : - s = "gendustry.bee." + name; - break; - case GTPP_Bees.MAGICBEES : - s = "magicbees.species" + name; - break; - case GTPP_Bees.GREGTECH : - s = "gregtech.species" + name; - break; - default : - s = "forestry.species" + name; - break; - - } - IAlleleBeeSpecies ret = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(s); - return ret; - } - - protected final void setSpeciesProperties(GTPP_AlleleBeeSpecies species2) { - this.mSpeciesProperties.accept(species2); - } - - protected final void setAlleles(IAllele[] template) { - this.mAlleles.accept(template); - } - - protected final void registerMutations() { - this.mMutations.accept(this); - } - - private void init() { - setSpeciesProperties(species); - - template = branch.getTemplate(); - AlleleHelper.instance.set(template, SPECIES, species); - setAlleles(template); - - genome = BeeManager.beeRoot.templateAsGenome(template); - - BeeManager.beeRoot.registerTemplate(template); - } - - protected final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance) { - return registerMutation(parent1, parent2, chance, 1f); - } - - protected final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance) { - return registerMutation(parent1, parent2, chance, 1f); - } - - protected final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance) { - return registerMutation(parent1, parent2, chance, 1f); - } - - protected final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance) { - return registerMutation(parent1, parent2, chance, 1f); - } - - protected final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, 1f); - } - - /** - * Diese neue Funtion erlaubt Mutationsraten unter 1%. Setze dazu die - * Mutationsrate als Bruch mit chance / chancedivider This new function - * allows Mutation percentages under 1%. Set them as a fraction with chance - * / chancedivider - */ - protected final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { - return new GTPP_Bee_Mutation(parent1, parent2, this.getTemplate(), chance, chancedivider); - } - - protected final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { - return registerMutation(parent1.species, parent2, chance, chancedivider); - } - - protected final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { - return registerMutation(parent1, parent2.species, chance, chancedivider); - } - - protected final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { - return registerMutation(parent1.species, parent2, chance, chancedivider); - } - - protected final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance, float chancedivider) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, chancedivider); - } - - @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) { - return BeeManager.beeRoot.getMemberStack(getIndividual(), beeType.ordinal()); - } - - public final IBeeDefinition getRainResist() { - return new BeeVariation.RainResist(this); - } - - private static final Class sGtBees = ReflectionUtils.getClass("gregtech.loaders.misc.GT_BeeDefinition"); - - public static IAlleleBeeSpecies getGregtechBeeType(String name) { - try { - Enum aBeeObject = ReflectionUtils.getEnum(sGtBees, name); - Field gtBeesField = ReflectionUtils.getField(sGtBees, "species"); - IAlleleBeeSpecies beeType = ReflectionUtils.getFieldValue(gtBeesField, aBeeObject); - return beeType != null ? beeType : null; - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } - - } + private final GTPP_BranchDefinition branch; + private final GTPP_AlleleBeeSpecies species; + private final Consumer<GTPP_AlleleBeeSpecies> mSpeciesProperties; + private final Consumer<IAllele[]> mAlleles; + private final Consumer<GTPP_BeeDefinition> mMutations; + private IAllele[] template; + private IBeeGenome genome; + + GTPP_BeeDefinition( + GTPP_BranchDefinition branch, + String binomial, + Materials aMat, + boolean dominant, + int primary, + int secondary, + Consumer<GTPP_AlleleBeeSpecies> aSpeciesProperties, + Consumer<IAllele[]> aAlleles, + Consumer<GTPP_BeeDefinition> aMutations) { + this( + branch, + binomial, + MaterialUtils.generateMaterialFromGtENUM(aMat), + dominant, + primary, + secondary, + aSpeciesProperties, + aAlleles, + aMutations); + } + + GTPP_BeeDefinition( + GTPP_BranchDefinition branch, + String binomial, + Material aMat, + boolean dominant, + int primary, + int secondary, + Consumer<GTPP_AlleleBeeSpecies> aSpeciesProperties, + Consumer<IAllele[]> aAlleles, + Consumer<GTPP_BeeDefinition> aMutations) { + this.mAlleles = aAlleles; + this.mMutations = aMutations; + this.mSpeciesProperties = aSpeciesProperties; + String lowercaseName = this.toString().toLowerCase(Locale.ENGLISH); + String species = WordUtils.capitalize(binomial); + String uid = "gtpp.bee.species" + species; + String description = "for.description." + species; + String name = "for.bees.species." + lowercaseName; + GT_LanguageManager.addStringLocalization("for.bees.species." + lowercaseName, species, true); + GTPP_Bees.sMaterialMappings.put(binomial.toLowerCase().replaceAll(" ", ""), aMat); + this.branch = branch; + this.species = new GTPP_AlleleBeeSpecies( + uid, dominant, name, "GT++", description, branch.getBranch(), binomial, primary, secondary); + } + + public static void initBees() { + for (GTPP_BeeDefinition bee : values()) { + bee.init(); + } + for (GTPP_BeeDefinition bee : values()) { + bee.registerMutations(); + } + } + + protected static IAlleleBeeEffect getEffect(byte modid, String name) { + String s; + switch (modid) { + case GTPP_Bees.EXTRABEES: + s = "extrabees.effect." + name; + break; + case GTPP_Bees.GENDUSTRY: + s = "gendustry.effect." + name; + break; + case GTPP_Bees.MAGICBEES: + s = "magicbees.effect" + name; + break; + case GTPP_Bees.GREGTECH: + s = "gregtech.effect" + name; + break; + default: + s = "forestry.effect" + name; + break; + } + return (IAlleleBeeEffect) AlleleManager.alleleRegistry.getAllele(s); + } + + protected static IAlleleFlowers getFlowers(byte modid, String name) { + String s; + switch (modid) { + case GTPP_Bees.EXTRABEES: + s = "extrabees.flower." + name; + break; + case GTPP_Bees.GENDUSTRY: + s = "gendustry.flower." + name; + break; + case GTPP_Bees.MAGICBEES: + s = "magicbees.flower" + name; + break; + case GTPP_Bees.GREGTECH: + s = "gregtech.flower" + name; + break; + default: + s = "forestry.flowers" + name; + break; + } + return (IAlleleFlowers) AlleleManager.alleleRegistry.getAllele(s); + } + + protected static IAlleleBeeSpecies getSpecies(byte modid, String name) { + String s; + switch (modid) { + case GTPP_Bees.EXTRABEES: + s = "extrabees.species." + name; + break; + case GTPP_Bees.GENDUSTRY: + s = "gendustry.bee." + name; + break; + case GTPP_Bees.MAGICBEES: + s = "magicbees.species" + name; + break; + case GTPP_Bees.GREGTECH: + s = "gregtech.species" + name; + break; + default: + s = "forestry.species" + name; + break; + } + IAlleleBeeSpecies ret = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(s); + return ret; + } + + protected final void setSpeciesProperties(GTPP_AlleleBeeSpecies species2) { + this.mSpeciesProperties.accept(species2); + } + + protected final void setAlleles(IAllele[] template) { + this.mAlleles.accept(template); + } + + protected final void registerMutations() { + this.mMutations.accept(this); + } + + private void init() { + setSpeciesProperties(species); + + template = branch.getTemplate(); + AlleleHelper.instance.set(template, SPECIES, species); + setAlleles(template); + + genome = BeeManager.beeRoot.templateAsGenome(template); + + BeeManager.beeRoot.registerTemplate(template); + } + + protected final IBeeMutationCustom registerMutation( + IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance) { + return registerMutation(parent1, parent2, chance, 1f); + } + + protected final IBeeMutationCustom registerMutation( + GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance) { + return registerMutation(parent1, parent2, chance, 1f); + } + + protected final IBeeMutationCustom registerMutation( + IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance) { + return registerMutation(parent1, parent2, chance, 1f); + } + + protected final IBeeMutationCustom registerMutation( + GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance) { + return registerMutation(parent1, parent2, chance, 1f); + } + + protected final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance) { + return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, 1f); + } + + /** + * Diese neue Funtion erlaubt Mutationsraten unter 1%. Setze dazu die + * Mutationsrate als Bruch mit chance / chancedivider This new function + * allows Mutation percentages under 1%. Set them as a fraction with chance + * / chancedivider + */ + protected final IBeeMutationCustom registerMutation( + IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { + return new GTPP_Bee_Mutation(parent1, parent2, this.getTemplate(), chance, chancedivider); + } + + protected final IBeeMutationCustom registerMutation( + GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { + return registerMutation(parent1.species, parent2, chance, chancedivider); + } + + protected final IBeeMutationCustom registerMutation( + IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { + return registerMutation(parent1, parent2.species, chance, chancedivider); + } + + protected final IBeeMutationCustom registerMutation( + GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { + return registerMutation(parent1.species, parent2, chance, chancedivider); + } + + protected final IBeeMutationCustom registerMutation( + String parent1, String parent2, int chance, float chancedivider) { + return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, chancedivider); + } + + @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) { + return BeeManager.beeRoot.getMemberStack(getIndividual(), beeType.ordinal()); + } + + public final IBeeDefinition getRainResist() { + return new BeeVariation.RainResist(this); + } + + private static final Class sGtBees = ReflectionUtils.getClass("gregtech.loaders.misc.GT_BeeDefinition"); + + public static IAlleleBeeSpecies getGregtechBeeType(String name) { + try { + Enum aBeeObject = ReflectionUtils.getEnum(sGtBees, name); + Field gtBeesField = ReflectionUtils.getField(sGtBees, "species"); + IAlleleBeeSpecies beeType = ReflectionUtils.getFieldValue(gtBeesField, aBeeObject); + return beeType != null ? beeType : null; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bee_Mutation.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bee_Mutation.java index 92a2a9fb30..c9bf32d07b 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bee_Mutation.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bee_Mutation.java @@ -7,19 +7,18 @@ import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; import forestry.apiculture.genetics.BeeMutation; import forestry.core.genetics.mutations.Mutation; +import java.lang.reflect.Field; +import java.util.List; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import org.apache.commons.lang3.reflect.FieldUtils; -import java.lang.reflect.Field; -import java.util.List; - - public class GTPP_Bee_Mutation extends BeeMutation { private final float split; - public GTPP_Bee_Mutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance, float split) { + public GTPP_Bee_Mutation( + IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance, float split) { super(bee0, bee1, result, chance); this.split = split; BeeManager.beeRoot.registerMutation(this); @@ -31,7 +30,12 @@ public class GTPP_Bee_Mutation extends BeeMutation { } @Override - public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) { + public float getChance( + IBeeHousing housing, + IAlleleBeeSpecies allele0, + IAlleleBeeSpecies allele1, + IBeeGenome genome0, + IBeeGenome genome1) { World world = housing != null ? housing.getWorld() : null; ChunkCoordinates housingCoordinates = housing != null ? housing.getCoordinates() : null; int x = housingCoordinates != null ? housingCoordinates.posX : 0; @@ -45,7 +49,8 @@ public class GTPP_Bee_Mutation extends BeeMutation { } IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing); - IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier(); + IBeeModifier beeModeModifier = + BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier(); processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance); processedChance *= beeModeModifier.getMutationModifier(genome0, genome1, processedChance); @@ -54,14 +59,21 @@ public class GTPP_Bee_Mutation extends BeeMutation { } @SuppressWarnings("unchecked") - private float getBasicChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) { + private float getBasicChance( + World world, + int x, + int y, + int z, + IAllele allele0, + IAllele allele1, + IGenome genome0, + IGenome genome1, + IClimateProvider climate) { float mutationChance = this.getBaseChance(); List<IMutationCondition> mutationConditions = null; Field f = FieldUtils.getDeclaredField(Mutation.class, "mutationConditions", true); - if (f == null) - f = FieldUtils.getField(Mutation.class, "mutationConditions", true); - if (f == null) - return mutationChance; + if (f == null) f = FieldUtils.getField(Mutation.class, "mutationConditions", true); + if (f == null) return mutationChance; try { mutationConditions = f.get(this) instanceof List ? (List<IMutationCondition>) f.get(this) : null; } catch (IllegalAccessException e) { @@ -70,7 +82,8 @@ public class GTPP_Bee_Mutation extends BeeMutation { if (mutationConditions != null) for (IMutationCondition mutationCondition : mutationConditions) { - mutationChance *= mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate); + mutationChance *= + mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate); if (mutationChance == 0) { return 0; } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java index 14b5a7e8ea..38ba689944 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.forestry.bees.registry; import static gregtech.api.enums.GT_Values.MOD_ID_FR; -import java.util.HashMap; - import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gtPlusPlus.api.objects.Logger; @@ -12,63 +10,62 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.*; import gtPlusPlus.xmod.forestry.bees.items.output.*; +import java.util.HashMap; public class GTPP_Bees { - - public final static byte FORESTRY = 0; - public final static byte EXTRABEES = 1; - public final static byte GENDUSTRY = 2; - public final static byte MAGICBEES = 3; - public final static byte GREGTECH = 4; + + public static final byte FORESTRY = 0; + public static final byte EXTRABEES = 1; + public static final byte GENDUSTRY = 2; + public static final byte MAGICBEES = 3; + public static final byte GREGTECH = 4; public static GTPP_Propolis propolis; public static GTPP_Pollen pollen; public static GTPP_Drop drop; public static GTPP_Comb combs; - - + public static HashMap<String, Material> sMaterialMappings = new HashMap<String, Material>(); - public static HashMap<Integer, GTPP_PropolisType> sPropolisMappings = new HashMap<Integer, GTPP_PropolisType>(); - public static HashMap<Integer, GTPP_PollenType> sPollenMappings = new HashMap<Integer, GTPP_PollenType>(); - public static HashMap<Integer, GTPP_DropType> sDropMappings = new HashMap<Integer, GTPP_DropType>(); - public static HashMap<Integer, GTPP_CombType> sCombMappings = new HashMap<Integer, GTPP_CombType>(); + public static HashMap<Integer, GTPP_PropolisType> sPropolisMappings = new HashMap<Integer, GTPP_PropolisType>(); + public static HashMap<Integer, GTPP_PollenType> sPollenMappings = new HashMap<Integer, GTPP_PollenType>(); + public static HashMap<Integer, GTPP_DropType> sDropMappings = new HashMap<Integer, GTPP_DropType>(); + public static HashMap<Integer, GTPP_CombType> sCombMappings = new HashMap<Integer, GTPP_CombType>(); public GTPP_Bees() { if (Loader.isModLoaded(MOD_ID_FR) && GT_Mod.gregtechproxy.mGTBees) { - - if (!ReflectionUtils.doesClassExist("gregtech.loaders.misc.GT_BeeDefinition")) { - CORE.crash("Missing gregtech.loaders.misc.GT_BeeDefinition."); - } - else { - Logger.BEES("Loading GT++ Bees!"); - } - Logger.BEES("Creating required items."); + if (!ReflectionUtils.doesClassExist("gregtech.loaders.misc.GT_BeeDefinition")) { + CORE.crash("Missing gregtech.loaders.misc.GT_BeeDefinition."); + } else { + Logger.BEES("Loading GT++ Bees!"); + } + + Logger.BEES("Creating required items."); propolis = new GTPP_Propolis(); pollen = new GTPP_Pollen(); drop = new GTPP_Drop(); combs = new GTPP_Comb(); - Logger.BEES("Loading types."); + Logger.BEES("Loading types."); initTypes(); - Logger.BEES("Adding recipes."); + Logger.BEES("Adding recipes."); GTPP_Drop.initDropsRecipes(); GTPP_Propolis.initPropolisRecipes(); GTPP_Comb.initCombsRecipes(); - Logger.BEES("Initialising bees."); + Logger.BEES("Initialising bees."); GTPP_BeeDefinition.initBees(); - - Logger.BEES("Done!"); + + Logger.BEES("Done!"); } } - + private static void initTypes() { - ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.registry.GTPP_BeeDefinition"); - ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_CombType"); - ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_DropType"); - ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_PollenType"); - ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_PropolisType"); + ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.registry.GTPP_BeeDefinition"); + ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_CombType"); + ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_DropType"); + ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_PollenType"); + ReflectionUtils.loadClass("gtPlusPlus.xmod.forestry.bees.handler.GTPP_PropolisType"); } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BranchDefinition.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BranchDefinition.java index 3c7630a434..76e195e9ef 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BranchDefinition.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BranchDefinition.java @@ -2,9 +2,6 @@ package gtPlusPlus.xmod.forestry.bees.registry; import static forestry.api.apiculture.EnumBeeChromosome.*; -import java.util.Arrays; -import java.util.function.Consumer; - import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.genetics.IAllele; @@ -12,9 +9,10 @@ import forestry.api.genetics.IClassification; import forestry.apiculture.genetics.alleles.AlleleEffect; import forestry.core.genetics.alleles.AlleleHelper; import forestry.core.genetics.alleles.EnumAllele.*; +import java.util.Arrays; +import java.util.function.Consumer; public enum GTPP_BranchDefinition { - LEGENDARY("gtpp.legendary", "Summa Potestas", alleles -> { AlleleHelper.instance.set(alleles, TEMPERATURE_TOLERANCE, Tolerance.BOTH_2); AlleleHelper.instance.set(alleles, HUMIDITY_TOLERANCE, Tolerance.BOTH_2); @@ -25,9 +23,7 @@ public enum GTPP_BranchDefinition { AlleleHelper.instance.set(alleles, FLOWERING, Flowering.SLOW); AlleleHelper.instance.set(alleles, SPEED, Speed.FASTEST); AlleleHelper.instance.set(alleles, TERRITORY, Territory.LARGER); - } - ) - ; + }); private static IAllele[] defaultTemplate; private final IClassification branch; |