From e0a0ab559496f0f63701b264f69892acd0e925f2 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 3 Oct 2017 00:03:46 -0700 Subject: [PATCH] Add modId to alleles and use new Forge item.getCreatorModId feature --- build.gradle | 2 -- gradle.properties | 10 +++--- src/main/java/forestry/Forestry.java | 4 +-- .../forestry/api/apiculture/IBeeFactory.java | 10 +++++- .../api/arboriculture/ITreeFactory.java | 34 ++++++------------ .../java/forestry/api/genetics/IAllele.java | 8 +++++ .../apiculture/genetics/BeeDefinition.java | 5 +-- .../apiculture/genetics/BeeFactory.java | 10 +++++- .../genetics/alleles/AlleleBeeSpecies.java | 4 +-- .../arboriculture/genetics/TreeFactory.java | 4 +-- .../genetics/alleles/AlleleTreeSpecies.java | 35 +++++-------------- .../java/forestry/core/genetics/ItemGE.java | 7 ++++ .../core/genetics/alleles/Allele.java | 11 ++++-- .../genetics/alleles/AlleleCategorized.java | 2 +- .../core/genetics/alleles/AlleleSpecies.java | 5 +-- .../alleles/AlleleButterflySpecies.java | 9 +---- 16 files changed, 80 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index 6e0b981cb..241211d2c 100644 --- a/build.gradle +++ b/build.gradle @@ -161,8 +161,6 @@ curseforge { changelog = file('changelog.html') changelogType = 'html' releaseType = 'beta' - addGameVersion '1.12' - addGameVersion '1.12.1' } } diff --git a/gradle.properties b/gradle.properties index 6b34a34e5..699e0f944 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ mcversion=1.12.2 -forgeversion=14.23.0.2486 +forgeversion=14.23.0.2501 mcp_mappings=snapshot_20170918 curse_project_id=59751 tesla_version=1.0.60 tesla_mcversion=1.12 -jei_version=4.7.8.92 -jei_mcversion=1.12.1 +jei_version=4.8.0.103 +jei_mcversion=1.12.2 ic2_version=2.8.24-ex112 version_major=5 -version_minor=5 -version_patch=6 +version_minor=6 +version_patch=0 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index e56673e06..dc9b4a51f 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -59,8 +59,8 @@ import forestry.plugins.compat.PluginNatura; name = Constants.MOD_NAME, version = Constants.VERSION, guiFactory = "forestry.core.config.ForestryGuiConfigFactory", - acceptedMinecraftVersions = "[1.12, 1.12.2]", - dependencies = "required-after:forge@[14.21.1.2395,);" + acceptedMinecraftVersions = "[1.12.2,1.13.0)", + dependencies = "required-after:forge@[14.23.0.2500,);" + "after:jei@[4.7.8.91,);" + "after:" + PluginIC2.modId + ";" + "after:" + PluginNatura.modId + ";" diff --git a/src/main/java/forestry/api/apiculture/IBeeFactory.java b/src/main/java/forestry/api/apiculture/IBeeFactory.java index 71a099167..6ef6b6a4f 100644 --- a/src/main/java/forestry/api/apiculture/IBeeFactory.java +++ b/src/main/java/forestry/api/apiculture/IBeeFactory.java @@ -14,6 +14,7 @@ public interface IBeeFactory { * Automatically registered with AlleleManager.alleleRegistry.registerAllele() * See IAlleleBeeSpeciesBuilder and IAlleleSpeciesBuilder for adding additional properties to the returned species. * + * @param modId The modId of the mod that is creating the species * @param uid Unique Identifier for this species * @param dominant Whether this species is genetically dominant (false means it is recessive) * @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry. @@ -24,8 +25,9 @@ public interface IBeeFactory { * @param primaryColor The outline color of this species * @param secondaryColor The body color of this species * @return a new bee species allele. + * @since Forestry 5.6.0. */ - IAlleleBeeSpeciesBuilder createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor); + IAlleleBeeSpeciesBuilder createSpecies(String modId, String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor); /** * Creates a new bee branch. @@ -36,4 +38,10 @@ public interface IBeeFactory { * @return a new bee branch */ IClassification createBranch(String uid, String scientific); + + /** + * @deprecated since Forestry 5.6.0. use {@link #createSpecies(String, String, boolean, String, String, String, IClassification, String, int, int)} + */ + @Deprecated + IAlleleBeeSpeciesBuilder createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor); } diff --git a/src/main/java/forestry/api/arboriculture/ITreeFactory.java b/src/main/java/forestry/api/arboriculture/ITreeFactory.java index 7bf67a82f..fd6be743d 100644 --- a/src/main/java/forestry/api/arboriculture/ITreeFactory.java +++ b/src/main/java/forestry/api/arboriculture/ITreeFactory.java @@ -5,32 +5,12 @@ ******************************************************************************/ package forestry.api.arboriculture; +import javax.annotation.Nullable; import java.awt.Color; import forestry.api.genetics.IClassification; public interface ITreeFactory { - /** - * Creates a new tree species. - * Automatically registered with AlleleManager.alleleRegistry.registerAllele() - * See IAlleleTreeSpeciesBuilder and IAlleleSpeciesBuilder for adding additional properties to the returned species. - * - * @param uid Unique Identifier for this species - * @param unlocalizedName Unlocalized name for this species - * @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry. - * @param unlocalizedDescription Unlocalized description for this species - * @param dominant Whether this species is genetically dominant (false means it is recessive) - * @param branch Classification of this species - * @param binomial Binomial name of the species sans genus. "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null. - * @param modID The modID from the mod of the species - * @param leafSpriteProvider The leaf sprite provider for this species - * @param germlingModelProvider The germling model provider for this species - * @param woodProvider The wood texture provider. It is used to get wood textures for the charcoal pile. - * @param generator The tree generator - * @return a new tree species allele. - */ - IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator); - /** * Creates a new tree species. * Automatically registered with AlleleManager.alleleRegistry.registerAllele() @@ -48,10 +28,18 @@ public interface ITreeFactory { * @param germlingModelProvider The germling model provider for this species * @param woodProvider The wood texture provider. It is used to get wood textures for the charcoal pile. * @param generator The tree generator + * @param leafProvider The leaf provider * @return a new tree species allele. */ - IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator, ILeafProvider leafProvider); - + IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator, @Nullable ILeafProvider leafProvider); + + /** + * @deprecated since Forestry 5.6.0. use {@link #createSpecies(String, String, String, String, boolean, IClassification, String, String, ILeafSpriteProvider, IGermlingModelProvider, IWoodProvider, ITreeGenerator, ILeafProvider)} + */ + @Deprecated + IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator); + + /** * Get one of the built-in Forestry leaf types. Default type is deciduous. */ diff --git a/src/main/java/forestry/api/genetics/IAllele.java b/src/main/java/forestry/api/genetics/IAllele.java index 0ab691d1e..6f98dd1a7 100644 --- a/src/main/java/forestry/api/genetics/IAllele.java +++ b/src/main/java/forestry/api/genetics/IAllele.java @@ -21,6 +21,14 @@ public interface IAllele { */ String getUID(); + /** + * @return modId of the mod that created this allele + * @since Forestry 5.6.0 + */ + default String getModID() { + return "forestry"; + } + /** * @return true if the allele is dominant, false otherwise. */ diff --git a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java index a8febe271..c096074e4 100644 --- a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java +++ b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java @@ -994,12 +994,13 @@ public enum BeeDefinition implements IBeeDefinition { String lowercaseName = this.toString().toLowerCase(Locale.ENGLISH); String species = "species" + WordUtils.capitalize(lowercaseName); - String uid = Constants.MOD_ID + '.' + species; + String modId = Constants.MOD_ID; + String uid = modId + '.' + species; String description = "for.description." + species; String name = "for.bees.species." + lowercaseName; this.branch = branch; - IAlleleBeeSpeciesBuilder speciesBuilder = BeeManager.beeFactory.createSpecies(uid, dominant, "Sengir", name, description, branch.getBranch(), binomial, primary.getRGB(), secondary.getRGB()); + IAlleleBeeSpeciesBuilder speciesBuilder = BeeManager.beeFactory.createSpecies(modId, uid, dominant, "Sengir", name, description, branch.getBranch(), binomial, primary.getRGB(), secondary.getRGB()); if (isSecret()) { speciesBuilder.setIsSecret(); } diff --git a/src/main/java/forestry/apiculture/genetics/BeeFactory.java b/src/main/java/forestry/apiculture/genetics/BeeFactory.java index 421cecfcb..8fd9c642a 100644 --- a/src/main/java/forestry/apiculture/genetics/BeeFactory.java +++ b/src/main/java/forestry/apiculture/genetics/BeeFactory.java @@ -17,8 +17,10 @@ import forestry.api.genetics.IClassification; import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; public class BeeFactory implements IBeeFactory { + @Override public IAlleleBeeSpeciesBuilder createSpecies( + String modId, String uid, boolean dominant, String authority, @@ -35,11 +37,17 @@ public class BeeFactory implements IBeeFactory { Preconditions.checkNotNull(branch); Preconditions.checkNotNull(binomial); - return new AlleleBeeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor); + return new AlleleBeeSpecies(modId, uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor); } @Override public IClassification createBranch(String uid, String scientific) { return new BranchBees(uid, scientific); } + + @Override + @Deprecated + public IAlleleBeeSpeciesBuilder createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) { + return createSpecies("forestry", uid, dominant, authority, unlocalizedName, unlocalizedDescription, branch, binomial, primaryColor, secondaryColor); + } } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java index 343502431..53b8db540 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java @@ -51,8 +51,8 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private IJubilanceProvider jubilanceProvider; private boolean nocturnal = false; - public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) { - super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial); + public AlleleBeeSpecies(String modId, String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) { + super(modId, uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial); beeModelProvider = DefaultBeeModelProvider.instance; beeSpriteColourProvider = new DefaultBeeSpriteColourProvider(primaryColor, secondaryColor); diff --git a/src/main/java/forestry/arboriculture/genetics/TreeFactory.java b/src/main/java/forestry/arboriculture/genetics/TreeFactory.java index e86680b0b..3af6de746 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeFactory.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeFactory.java @@ -26,8 +26,9 @@ import forestry.arboriculture.models.SpriteProviderLeaves; public class TreeFactory implements ITreeFactory { @Override + @Deprecated public IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator) { - return new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, modID, leafSpriteProvider, germlingModelProvider, woodProvider, generator); + return new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, modID, leafSpriteProvider, germlingModelProvider, woodProvider, generator, null); } @Override @@ -35,7 +36,6 @@ public class TreeFactory implements ITreeFactory { return new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, modID, leafSpriteProvider, germlingModelProvider, woodProvider, generator, leafProvider); } - @Override public ILeafSpriteProvider getLeafIconProvider(EnumLeafType enumLeafType, Color color, Color colorPollinated) { return new SpriteProviderLeaves(enumLeafType, color, colorPollinated); diff --git a/src/main/java/forestry/arboriculture/genetics/alleles/AlleleTreeSpecies.java b/src/main/java/forestry/arboriculture/genetics/alleles/AlleleTreeSpecies.java index 4587db204..fdbe06eba 100644 --- a/src/main/java/forestry/arboriculture/genetics/alleles/AlleleTreeSpecies.java +++ b/src/main/java/forestry/arboriculture/genetics/alleles/AlleleTreeSpecies.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.genetics.alleles; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -51,28 +52,11 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci private final IGermlingModelProvider germlingModelProvider; private final ILeafSpriteProvider leafSpriteProvider; private final List fruits = new ArrayList<>(); - private final String modID; private EnumPlantType nativeType = EnumPlantType.Plains; private final ILeafProvider leafProvider; private IGrowthProvider growthProvider = new ClimateGrowthProvider(); private float rarity = 0.0F; - public AlleleTreeSpecies( - String uid, - String unlocalizedName, - String authority, - String unlocalizedDescription, - boolean isDominant, - IClassification branch, - String binomial, - String modID, - ILeafSpriteProvider leafSpriteProvider, - IGermlingModelProvider germlingModelProvider, - IWoodProvider woodProvider, - ITreeGenerator generator) { - this(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial, modID, leafSpriteProvider, germlingModelProvider, woodProvider, generator, new LeafProvider()); - } - public AlleleTreeSpecies( String uid, String unlocalizedName, @@ -86,16 +70,18 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator, - ILeafProvider leafProvider) { - super(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial); + @Nullable ILeafProvider leafProvider) { + super(modID, uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial); this.generator = generator; this.germlingModelProvider = germlingModelProvider; this.woodProvider = woodProvider; this.leafSpriteProvider = leafIconProvider; - this.leafProvider = leafProvider; - - this.modID = modID; + if (leafProvider == null) { + this.leafProvider = new LeafProvider(); + } else { + this.leafProvider = leafProvider; + } } @Override @@ -197,11 +183,6 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci public ILeafProvider getLeafProvider() { return leafProvider; } - - @Override - public String getModID() { - return modID; - } @Override public float getResearchSuitability(ItemStack itemstack) { diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index 21176a7f0..3f9fd22ab 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -82,4 +82,11 @@ public abstract class ItemGE extends ItemForestry { list.add("<" + Translator.translateToLocal("for.gui.unknown") + ">"); } } + + @Nullable + @Override + public String getCreatorModId(ItemStack itemStack) { + IAlleleSpecies species = getSpecies(itemStack); + return species.getModID(); + } } diff --git a/src/main/java/forestry/core/genetics/alleles/Allele.java b/src/main/java/forestry/core/genetics/alleles/Allele.java index c8c295a79..a546c74e9 100644 --- a/src/main/java/forestry/core/genetics/alleles/Allele.java +++ b/src/main/java/forestry/core/genetics/alleles/Allele.java @@ -14,12 +14,13 @@ import forestry.api.genetics.IAllele; import forestry.core.utils.Translator; public abstract class Allele implements IAllele { - + private final String modId; private final String uid; private final boolean isDominant; private final String unlocalizedName; - protected Allele(String uid, String unlocalizedName, boolean isDominant) { + protected Allele(String modId, String uid, String unlocalizedName, boolean isDominant) { + this.modId = modId; this.uid = uid; this.isDominant = isDominant; this.unlocalizedName = unlocalizedName; @@ -30,12 +31,18 @@ public abstract class Allele implements IAllele { return uid; } + @Override + public String getModID() { + return modId; + } + @Override public boolean isDominant() { return isDominant; } @Override + @Deprecated public String getName() { return Translator.translateToLocal(getUnlocalizedName()); } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleCategorized.java b/src/main/java/forestry/core/genetics/alleles/AlleleCategorized.java index 736b01647..7156bf65c 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleCategorized.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleCategorized.java @@ -14,7 +14,7 @@ import org.apache.commons.lang3.text.WordUtils; */ public abstract class AlleleCategorized extends Allele { protected AlleleCategorized(String modId, String category, String valueName, boolean isDominant) { - super(getUid(modId, category, valueName), getUnlocalizedName(modId, category, valueName), isDominant); + super(modId, getUid(modId, category, valueName), getUnlocalizedName(modId, category, valueName), isDominant); } private static String getUid(String modId, String category, String valueName) { diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java b/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java index 05fc98714..f2a410ce4 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java @@ -51,14 +51,15 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil @Nullable private Integer complexityOverride = null; - protected AlleleSpecies(String uid, + protected AlleleSpecies(String modId, + String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean isDominant, IClassification branch, String binomial) { - super(uid, unlocalizedName, isDominant); + super(modId, uid, unlocalizedName, isDominant); this.branch = branch; this.binomial = binomial; diff --git a/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java b/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java index c2a151dc7..d6651e7d7 100644 --- a/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java +++ b/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java @@ -46,7 +46,6 @@ import forestry.core.genetics.alleles.AlleleSpecies; public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButterflySpecies, IAlleleButterflySpeciesBuilder { private final String texture; - private final String modID; private final Color serumColour; private float rarity = 0.1f; private float flightDistance = 5.0f; @@ -60,10 +59,9 @@ public class AlleleButterflySpecies extends AlleleSpecies public AlleleButterflySpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, String modID, String texturePath, boolean isDominant, IClassification branch, String binomial, Color serumColour) { - super(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial); + super(modID, uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial); this.serumColour = serumColour; - this.modID = modID; this.texture = texturePath; } @@ -211,9 +209,4 @@ public class AlleleButterflySpecies extends AlleleSpecies TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); textureMap.registerSprite(new ResourceLocation(spriteName)); } - - @Override - public String getModID() { - return modID; - } }