aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-10-19 10:54:08 +0200
committerGitHub <noreply@github.com>2020-10-19 10:54:08 +0200
commit6d9bd4fff43c6e76766816908758127737dde642 (patch)
tree986dc123e9a87ed1216ce74ebc267f1ec7adfb2e /src/main/java/gregtech/common
parentd9bdde27be5d401f72b93614576ec48ed0a22049 (diff)
downloadGT5-Unofficial-6d9bd4fff43c6e76766816908758127737dde642.tar.gz
GT5-Unofficial-6d9bd4fff43c6e76766816908758127737dde642.tar.bz2
GT5-Unofficial-6d9bd4fff43c6e76766816908758127737dde642.zip
Bee Definition Cleanup (#326)
* Bee Definition Cleanup Removed a Lot of boilerplate code, by using Consumers instead of Overrides Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> * Made Use of Static imports + use "Color" class for better IDE integration & readability + parameterised some Generics + reroute some Method overloads Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> * fixed an oversight Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> * fixed a typo Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java14
-rw-r--r--src/main/java/gregtech/common/bees/GT_AlleleHelper.java11
-rw-r--r--src/main/java/gregtech/common/bees/GT_Bee_Mutation.java5
3 files changed, 23 insertions, 7 deletions
diff --git a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java
index 83dc82e6f9..41726b4fc5 100644
--- a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java
+++ b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java
@@ -8,9 +8,19 @@ import forestry.apiculture.genetics.alleles.AlleleBeeSpecies;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
+import java.awt.*;
+
public class GT_AlleleBeeSpecies extends AlleleBeeSpecies {
- public GT_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);
+ public GT_AlleleBeeSpecies(String uid,
+ boolean dominant,
+ String unlocalizedName,
+ String authority,
+ String unlocalizedDescription,
+ IClassification branch,
+ String binomial,
+ Color primaryColor,
+ Color secondaryColor) {
+ super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor.getRGB(), secondaryColor.getRGB());
AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.SPECIES);
}
diff --git a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java
index cb54f5d4a1..e1db4c2ac0 100644
--- a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java
+++ b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java
@@ -21,7 +21,7 @@ public class GT_AlleleHelper extends AlleleHelper {
private static final String modId = Constants.ID;
- private Map<Class, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>();
+ private Map<Class<?>, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>();
public void init() {
if (PluginManager.Module.APICULTURE.isEnabled()) {
@@ -114,12 +114,17 @@ public class GT_AlleleHelper extends AlleleHelper {
}
alleleMaps.put(Boolean.class, booleans);
}
-
+ @SuppressWarnings("unchecked")
public static void initialisation(){
GT_AlleleHelper helper = new GT_AlleleHelper();
try {
- helper.alleleMaps = (Map<Class, Map<?, ? extends IAllele>>) FieldUtils.readField(FieldUtils.getField(AlleleHelper.class,"alleleMaps",true),AlleleHelper.instance,true);
+ helper.alleleMaps = (Map<Class<?>, Map<?, ? extends IAllele>>)
+ FieldUtils.readField(
+ FieldUtils.getField(AlleleHelper.class,"alleleMaps",true),
+ AlleleHelper.instance,
+ true
+ );
} catch (IllegalAccessException e) {
e.printStackTrace();
}
diff --git a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java
index 7b61505fc7..ca919e7cf2 100644
--- a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java
+++ b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java
@@ -16,7 +16,7 @@ import java.util.List;
public class GT_Bee_Mutation extends BeeMutation {
- private float split = 1;
+ private final float split;
public GT_Bee_Mutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance, float split) {
super(bee0, bee1, result, chance);
@@ -52,6 +52,7 @@ public class GT_Bee_Mutation extends BeeMutation {
return processedChance;
}
+ @SuppressWarnings("unchecked")
private float getBasicChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float mutationChance = this.getBaseChance();
List<IMutationCondition> mutationConditions = null;
@@ -61,7 +62,7 @@ public class GT_Bee_Mutation extends BeeMutation {
if (f == null)
return mutationChance;
try {
- mutationConditions = f.get(this) instanceof List ? (List) f.get(this) : null;
+ mutationConditions = f.get(this) instanceof List ? (List<IMutationCondition>) f.get(this) : null;
} catch (IllegalAccessException e) {
e.printStackTrace();
}