diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index d296f018e..b016b6271 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -59,6 +59,7 @@ public class ForestryCore { EnumErrorCode.init(); + PluginManager.runSetup(); PluginManager.runPreInit(); } diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index 3d8de1280..1aea9ad2f 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -225,45 +225,45 @@ public class Allele implements IAllele { public static IAlleleButterflySpecies lepiLLacewing; // / ALL // GENERIC - public static Allele boolFalse; - public static Allele boolTrue; + public static final Allele boolFalse = new AlleleBoolean("boolFalse", false); + public static final Allele boolTrue = new AlleleBoolean("boolTrue", true); - public static Allele int1; - public static Allele int2; - public static Allele int3; - public static Allele int4; - public static Allele int5; - public static Allele int6; - public static Allele int7; - public static Allele int8; - public static Allele int9; - public static Allele int10; + public static final Allele int1 = new AlleleInteger("i1d", 1, true); + public static final Allele int2 = new AlleleInteger("i2d", 2, true); + public static final Allele int3 = new AlleleInteger("i3d", 3, true); + public static final Allele int4 = new AlleleInteger("i4d", 4, true); + public static final Allele int5 = new AlleleInteger("i5d", 5, true); + public static final Allele int6 = new AlleleInteger("i6d", 6, true); + public static final Allele int7 = new AlleleInteger("i7d", 7, true); + public static final Allele int8 = new AlleleInteger("i8d", 8, true); + public static final Allele int9 = new AlleleInteger("i9d", 9, true); + public static final Allele int10 = new AlleleInteger("i10d", 10, true); // / BEES // SPEED 1100 - 1199 - public static Allele speedSlowest; - public static Allele speedSlower; - public static Allele speedSlow; - public static Allele speedNorm; - public static Allele speedFast; - public static Allele speedFaster; - public static Allele speedFastest; + public static final Allele speedSlowest = new AlleleFloat("speedSlowest", 0.3f, true).setName("speed", "slowest"); + public static final Allele speedSlower = new AlleleFloat("speedSlower", 0.6f, true).setName("speed", "slower"); + public static final Allele speedSlow = new AlleleFloat("speedSlow", 0.8f, true).setName("speed", "slow"); + public static final Allele speedNorm = new AlleleFloat("speedNorm", 1.0f).setName("speed", "normal"); + public static final Allele speedFast = new AlleleFloat("speedFast", 1.2f, true).setName("speed", "fast"); + public static final Allele speedFaster = new AlleleFloat("speedFaster", 1.4f).setName("speed", "faster"); + public static final Allele speedFastest = new AlleleFloat("speedFastest", 1.7f).setName("speed", "fastest"); // / BEES // LIFESPAN 1200 - 1299 - public static Allele lifespanShortest; - public static Allele lifespanShorter; - public static Allele lifespanShort; - public static Allele lifespanShortened; - public static Allele lifespanNormal; - public static Allele lifespanElongated; - public static Allele lifespanLong; - public static Allele lifespanLonger; - public static Allele lifespanLongest; + public static final Allele lifespanShortest = new AlleleInteger("lifespanShortest", 10, false).setName("gui.shortestlife"); + public static final Allele lifespanShorter = new AlleleInteger("lifespanShorter", 20, true).setName("gui.shorterlife"); + public static final Allele lifespanShort = new AlleleInteger("lifespanShort", 30, true).setName("gui.shortlife"); + public static final Allele lifespanShortened = new AlleleInteger("lifespanShortened", 35, true).setName("gui.shortenedlife"); + public static final Allele lifespanNormal = new AlleleInteger("lifespanNormal", 40).setName("gui.normallife"); + public static final Allele lifespanElongated = new AlleleInteger("lifespanElongated", 45, true).setName("gui.elongatedlife"); + public static final Allele lifespanLong = new AlleleInteger("lifespanLong", 50).setName("gui.longlife"); + public static final Allele lifespanLonger = new AlleleInteger("lifespanLonger", 60).setName("gui.longerlife"); + public static final Allele lifespanLongest = new AlleleInteger("lifespanLongest", 70).setName("gui.longestlife"); // / BEES // FERTILITY 1300 - 1349 - public static Allele fertilityLow; - public static Allele fertilityNormal; - public static Allele fertilityHigh; - public static Allele fertilityMaximum; + public static final Allele fertilityLow = new AlleleInteger("fertilityLow", 1, true); + public static final Allele fertilityNormal = new AlleleInteger("fertilityNormal", 2, true); + public static final Allele fertilityHigh = new AlleleInteger("fertilityHigh", 3); + public static final Allele fertilityMaximum = new AlleleInteger("fertilityMaximum", 4); // / TREES // GROWTH PROVIDER 1350 - 1399 public static IAlleleGrowth growthLightlevel; @@ -285,41 +285,41 @@ public class Allele implements IAllele { public static IAlleleFruit fruitJujube; // / TREES // HEIGHT 1400 - 1449 - public static Allele heightSmallest; - public static Allele heightSmaller; - public static Allele heightSmall; - public static Allele heightAverage; - public static Allele heightLarge; - public static Allele heightLarger; - public static Allele heightLargest; - public static Allele heightGigantic; + public static final Allele heightSmallest = new AlleleFloat("heightSmallest", 0.25f).setName("height", "smallest"); + public static final Allele heightSmaller = new AlleleFloat("heightSmaller", 0.5f).setName("height", "smaller"); + public static final Allele heightSmall = new AlleleFloat("heightSmall", 0.75f).setName("height", "small"); + public static final Allele heightAverage = new AlleleFloat("heightMax10", 1.0f).setName("height", "average"); + public static final Allele heightLarge = new AlleleFloat("heightLarge", 1.25f).setName("height", "large"); + public static final Allele heightLarger = new AlleleFloat("heightLarger", 1.5f).setName("height", "larger"); + public static final Allele heightLargest = new AlleleFloat("heightLargest", 1.75f).setName("height", "largest"); + public static final Allele heightGigantic = new AlleleFloat("heightGigantic", 2.0f).setName("height", "gigantic"); /// BUTTERFLIES // SIZE - public static Allele sizeSmallest; - public static Allele sizeSmaller; - public static Allele sizeSmall; - public static Allele sizeAverage; - public static Allele sizeLarge; - public static Allele sizeLarger; - public static Allele sizeLargest; + public static final Allele sizeSmallest = new AlleleFloat("sizeSmallest", 0.3f).setName("size", "smallest"); + public static final Allele sizeSmaller = new AlleleFloat("sizeSmaller", 0.4f).setName("size", "smaller"); + public static final Allele sizeSmall = new AlleleFloat("sizeSmall", 0.5f).setName("size", "small"); + public static final Allele sizeAverage = new AlleleFloat("sizeAverage", 0.6f).setName("size", "average"); + public static final Allele sizeLarge = new AlleleFloat("sizeLarge", 0.75f).setName("size", "large"); + public static final Allele sizeLarger = new AlleleFloat("sizeLarger", 0.9f).setName("size", "larger"); + public static final Allele sizeLargest = new AlleleFloat("sizeLargest", 1.0f).setName("size", "largest"); // / BOTH // TOLERANCE 1450 - 1499 - public static Allele toleranceNone; - public static Allele toleranceBoth1; - public static Allele toleranceBoth2; - public static Allele toleranceBoth3; - public static Allele toleranceBoth4; - public static Allele toleranceBoth5; - public static Allele toleranceUp1; - public static Allele toleranceUp2; - public static Allele toleranceUp3; - public static Allele toleranceUp4; - public static Allele toleranceUp5; - public static Allele toleranceDown1; - public static Allele toleranceDown2; - public static Allele toleranceDown3; - public static Allele toleranceDown4; - public static Allele toleranceDown5; + public static final Allele toleranceNone = new AlleleTolerance("toleranceNone", EnumTolerance.NONE); + public static final Allele toleranceBoth1 = new AlleleTolerance("toleranceBoth1", EnumTolerance.BOTH_1, true); + public static final Allele toleranceBoth2 = new AlleleTolerance("toleranceBoth2", EnumTolerance.BOTH_2); + public static final Allele toleranceBoth3 = new AlleleTolerance("toleranceBoth3", EnumTolerance.BOTH_3); + public static final Allele toleranceBoth4 = new AlleleTolerance("toleranceBoth4", EnumTolerance.BOTH_4); + public static final Allele toleranceBoth5 = new AlleleTolerance("toleranceBoth5", EnumTolerance.BOTH_5); + public static final Allele toleranceUp1 = new AlleleTolerance("toleranceUp1", EnumTolerance.UP_1, true); + public static final Allele toleranceUp2 = new AlleleTolerance("toleranceUp2", EnumTolerance.UP_2); + public static final Allele toleranceUp3 = new AlleleTolerance("toleranceUp3", EnumTolerance.UP_3); + public static final Allele toleranceUp4 = new AlleleTolerance("toleranceUp4", EnumTolerance.UP_4); + public static final Allele toleranceUp5 = new AlleleTolerance("toleranceUp5", EnumTolerance.UP_5); + public static final Allele toleranceDown1 = new AlleleTolerance("toleranceDown1", EnumTolerance.DOWN_1, true); + public static final Allele toleranceDown2 = new AlleleTolerance("toleranceDown2", EnumTolerance.DOWN_2); + public static final Allele toleranceDown3 = new AlleleTolerance("toleranceDown3", EnumTolerance.DOWN_3); + public static final Allele toleranceDown4 = new AlleleTolerance("toleranceDown4", EnumTolerance.DOWN_4); + public static final Allele toleranceDown5 = new AlleleTolerance("toleranceDown5", EnumTolerance.DOWN_5); // / BEES // FLOWER PROVIDERS 1500 - 1599 public static Allele flowersVanilla; @@ -333,56 +333,56 @@ public class Allele implements IAllele { public static Allele flowersGourd; // / TREES // FERTILITY 1600 - 1649 - public static Allele saplingsLowest; - public static Allele saplingsLower; - public static Allele saplingsLow; - public static Allele saplingsAverage; - public static Allele saplingsHigh; - public static Allele saplingsHigher; - public static Allele saplingsHighest; + public static final Allele saplingsLowest = new AlleleFloat("saplingsLowest", 0.01f, true).setName("saplings", "lowest"); + public static final Allele saplingsLower = new AlleleFloat("saplingsLower", 0.025f, true).setName("saplings", "lower"); + public static final Allele saplingsLow = new AlleleFloat("saplingsLow", 0.035f, true).setName("saplings", "low"); + public static final Allele saplingsAverage = new AlleleFloat("saplingsDefault", 0.05f, true).setName("saplings", "average"); + public static final Allele saplingsHigh = new AlleleFloat("saplingsDouble", 0.1f, true).setName("saplings", "high"); + public static final Allele saplingsHigher = new AlleleFloat("saplingsTriple", 0.2f, true).setName("saplings", "higher"); + public static final Allele saplingsHighest = new AlleleFloat("saplingsHighest", 0.3f, true).setName("saplings", "highest"); // / TREES // YIELD 1650 - 1699 - public static Allele yieldLowest; - public static Allele yieldLower; - public static Allele yieldLow; - public static Allele yieldAverage; - public static Allele yieldHigh; - public static Allele yieldHigher; - public static Allele yieldHighest; + public static final Allele yieldLowest = new AlleleFloat("yieldLowest", 0.025f, true).setName("yield", "lowest"); + public static final Allele yieldLower = new AlleleFloat("yieldLower", 0.05f, true).setName("yield", "lower"); + public static final Allele yieldLow = new AlleleFloat("yieldLow", 0.1f, true).setName("yield", "low"); + public static final Allele yieldAverage = new AlleleFloat("yieldDefault", 0.2f, true).setName("yield", "average"); + public static final Allele yieldHigh = new AlleleFloat("yieldHigh", 0.3f, false).setName("yield", "high"); + public static final Allele yieldHigher = new AlleleFloat("yieldHigher", 0.35f, false).setName("yield", "higher"); + public static final Allele yieldHighest = new AlleleFloat("yieldHighest", 0.4f, false).setName("yield", "highest"); // TREES // SAPPINESS - public static Allele sappinessLowest; - public static Allele sappinessLower; - public static Allele sappinessLow; - public static Allele sappinessAverage; - public static Allele sappinessHigh; - public static Allele sappinessHigher; - public static Allele sappinessHighest; + public static final Allele sappinessLowest = new AlleleFloat("sappinessLowest", 0.1f, true).setName("sappiness", "lowest"); + public static final Allele sappinessLower = new AlleleFloat("sappinessLower", 0.2f, true).setName("sappiness", "lower"); + public static final Allele sappinessLow = new AlleleFloat("sappinessLow", 0.3f, true).setName("sappiness", "low"); + public static final Allele sappinessAverage = new AlleleFloat("sappinessAverage", 0.4f, true).setName("sappiness", "average"); + public static final Allele sappinessHigh = new AlleleFloat("sappinessHigh", 0.6f, true).setName("sappiness", "high"); + public static final Allele sappinessHigher = new AlleleFloat("sappinessHigher", 0.8f, false).setName("sappiness", "higher"); + public static final Allele sappinessHighest = new AlleleFloat("sappinessHighest", 1.0f, false).setName("sappiness", "highest"); // TREES // MATURATION TIME - public static Allele maturationSlowest; - public static Allele maturationSlower; - public static Allele maturationSlow; - public static Allele maturationAverage; - public static Allele maturationFast; - public static Allele maturationFaster; - public static Allele maturationFastest; + public static final Allele maturationSlowest = new AlleleInteger("maturationSlowest", 10, true).setName("maturity", "slowest"); + public static final Allele maturationSlower = new AlleleInteger("maturationSlower", 7).setName("maturity", "slower"); + public static final Allele maturationSlow = new AlleleInteger("maturationSlow", 5, true).setName("maturity", "slow"); + public static final Allele maturationAverage = new AlleleInteger("maturationAverage", 4).setName("maturity", "average"); + public static final Allele maturationFast = new AlleleInteger("maturationFast", 3).setName("maturity", "fast"); + public static final Allele maturationFaster = new AlleleInteger("maturationFaster", 2).setName("maturity", "faster"); + public static final Allele maturationFastest = new AlleleInteger("maturationFastest", 1).setName("maturity", "fastest"); // / BEES // FLOWER GROWTH 1700 - 1749 - public static Allele floweringSlowest; - public static Allele floweringSlower; - public static Allele floweringSlow; - public static Allele floweringAverage; - public static Allele floweringFast; - public static Allele floweringFaster; - public static Allele floweringFastest; - public static Allele floweringMaximum; + public static final Allele floweringSlowest = new AlleleInteger("floweringSlowest", 5, true).setName("flowering", "slowest"); + public static final Allele floweringSlower = new AlleleInteger("floweringSlower", 10).setName("flowering", "slower"); + public static final Allele floweringSlow = new AlleleInteger("floweringSlow", 15).setName("flowering", "slow"); + public static final Allele floweringAverage = new AlleleInteger("floweringAverage", 20).setName("flowering", "average"); + public static final Allele floweringFast = new AlleleInteger("floweringFast", 25).setName("flowering", "fast"); + public static final Allele floweringFaster = new AlleleInteger("floweringFaster", 30).setName("flowering", "faster"); + public static final Allele floweringFastest = new AlleleInteger("floweringFastest", 35).setName("flowering", "fastest"); + public static final Allele floweringMaximum = new AlleleInteger("floweringMaximum", 99, true).setName("flowering", "maximum"); // / BOTH // TERRITORY 1750 - 1799 - public static Allele territoryDefault; - public static Allele territoryLarge; - public static Allele territoryLarger; - public static Allele territoryLargest; + public static final Allele territoryDefault = new AlleleArea("territoryDefault", new int[]{9, 6, 9}).setName("territory", "average"); + public static final Allele territoryLarge = new AlleleArea("territoryLarge", new int[]{11, 8, 11}).setName("territory", "large"); + public static final Allele territoryLarger = new AlleleArea("territoryLarger", new int[]{13, 12, 13}).setName("territory", "larger"); + public static final Allele territoryLargest = new AlleleArea("territoryLargest", new int[]{15, 13, 15}).setName("territory", "largest"); // / BEES // EFFECTS 1800 - 1899 public static Allele effectNone; @@ -412,164 +412,20 @@ public class Allele implements IAllele { public static Allele butterflyNone; // These are "secondary" plant attributes, i.e. the tree can double as one. - public static Allele plantTypeNone; - public static Allele plantTypePlains; - public static Allele plantTypeDesert; - public static Allele plantTypeBeach; - public static Allele plantTypeCave; - public static Allele plantTypeWater; - public static Allele plantTypeNether; - public static Allele plantTypeCrop; + public static final Allele plantTypeNone = new AllelePlantType("plantTypeNone", EnumSet.noneOf(EnumPlantType.class), true); + public static final Allele plantTypePlains = new AllelePlantType("plantTypePlains", EnumPlantType.Plains); + public static final Allele plantTypeDesert = new AllelePlantType("plantTypeDesert", EnumPlantType.Desert); + public static final Allele plantTypeBeach = new AllelePlantType("plantTypeBeach", EnumPlantType.Beach); + public static final Allele plantTypeCave = new AllelePlantType("plantTypeCave", EnumPlantType.Cave); + public static final Allele plantTypeWater = new AllelePlantType("plantTypeWater", EnumPlantType.Water); + public static final Allele plantTypeNether = new AllelePlantType("plantTypeNether", EnumPlantType.Nether); + public static final Allele plantTypeCrop = new AllelePlantType("plantTypeCrop", EnumPlantType.Crop); // / TREES // FIREPROOF - public static Allele fireproofFalse; - public static Allele fireproofTrue; - - public static void initialize() { - // ALL // GENERIC - boolFalse = new AlleleBoolean("boolFalse", false); - boolTrue = new AlleleBoolean("boolTrue", true); - - int1 = new AlleleInteger("i1d", 1, true); - int2 = new AlleleInteger("i2d", 2, true); - int3 = new AlleleInteger("i3d", 3, true); - int4 = new AlleleInteger("i4d", 4, true); - int5 = new AlleleInteger("i5d", 5, true); - int6 = new AlleleInteger("i6d", 6, true); - int7 = new AlleleInteger("i7d", 7, true); - int8 = new AlleleInteger("i8d", 8, true); - int9 = new AlleleInteger("i9d", 9, true); - int10 = new AlleleInteger("i10d", 10, true); - - // BEES // SPEED - speedSlowest = new AlleleFloat("speedSlowest", 0.3f, true).setName("speed", "slowest"); - speedSlower = new AlleleFloat("speedSlower", 0.6f, true).setName("speed", "slower"); - speedSlow = new AlleleFloat("speedSlow", 0.8f, true).setName("speed", "slow"); - speedNorm = new AlleleFloat("speedNorm", 1.0f).setName("speed", "normal"); - speedFast = new AlleleFloat("speedFast", 1.2f, true).setName("speed", "fast"); - speedFaster = new AlleleFloat("speedFaster", 1.4f).setName("speed", "faster"); - speedFastest = new AlleleFloat("speedFastest", 1.7f).setName("speed", "fastest"); - - // BEES // LIFESPAN - lifespanShortest = new AlleleInteger("lifespanShortest", 10, false).setName("gui.shortestlife"); - lifespanShorter = new AlleleInteger("lifespanShorter", 20, true).setName("gui.shorterlife"); - lifespanShort = new AlleleInteger("lifespanShort", 30, true).setName("gui.shortlife"); - lifespanShortened = new AlleleInteger("lifespanShortened", 35, true).setName("gui.shortenedlife"); - lifespanNormal = new AlleleInteger("lifespanNormal", 40).setName("gui.normallife"); - lifespanElongated = new AlleleInteger("lifespanElongated", 45, true).setName("gui.elongatedlife"); - lifespanLong = new AlleleInteger("lifespanLong", 50).setName("gui.longlife"); - lifespanLonger = new AlleleInteger("lifespanLonger", 60).setName("gui.longerlife"); - lifespanLongest = new AlleleInteger("lifespanLongest", 70).setName("gui.longestlife"); - - // BEES // FERTILITY - fertilityLow = new AlleleInteger("fertilityLow", 1, true); - fertilityNormal = new AlleleInteger("fertilityNormal", 2, true); - fertilityHigh = new AlleleInteger("fertilityHigh", 3); - fertilityMaximum = new AlleleInteger("fertilityMaximum", 4); - - // TREES // HEIGHT - heightSmallest = new AlleleFloat("heightSmallest", 0.25f).setName("height", "smallest"); - heightSmaller = new AlleleFloat("heightSmaller", 0.5f).setName("height", "smaller"); - heightSmall = new AlleleFloat("heightSmall", 0.75f).setName("height", "small"); - heightAverage = new AlleleFloat("heightMax10", 1.0f).setName("height", "average"); - heightLarge = new AlleleFloat("heightLarge", 1.25f).setName("height", "large"); - heightLarger = new AlleleFloat("heightLarger", 1.5f).setName("height", "larger"); - heightLargest = new AlleleFloat("heightLargest", 1.75f).setName("height", "largest"); - heightGigantic = new AlleleFloat("heightGigantic", 2.0f).setName("height", "gigantic"); - - // BUTTERFLIES // SIZE - sizeSmallest = new AlleleFloat("sizeSmallest", 0.3f).setName("size", "smallest"); - sizeSmaller = new AlleleFloat("sizeSmaller", 0.4f).setName("size", "smaller"); - sizeSmall = new AlleleFloat("sizeSmall", 0.5f).setName("size", "small"); - sizeAverage = new AlleleFloat("sizeAverage", 0.6f).setName("size", "average"); - sizeLarge = new AlleleFloat("sizeLarge", 0.75f).setName("size", "large"); - sizeLarger = new AlleleFloat("sizeLarger", 0.9f).setName("size", "larger"); - sizeLargest = new AlleleFloat("sizeLargest", 1.0f).setName("size", "largest"); - - // BEES // TOLERANCE - toleranceNone = new AlleleTolerance("toleranceNone", EnumTolerance.NONE); - toleranceBoth1 = new AlleleTolerance("toleranceBoth1", EnumTolerance.BOTH_1, true); - toleranceBoth2 = new AlleleTolerance("toleranceBoth2", EnumTolerance.BOTH_2); - toleranceBoth3 = new AlleleTolerance("toleranceBoth3", EnumTolerance.BOTH_3); - toleranceBoth4 = new AlleleTolerance("toleranceBoth4", EnumTolerance.BOTH_4); - toleranceBoth5 = new AlleleTolerance("toleranceBoth5", EnumTolerance.BOTH_5); - toleranceUp1 = new AlleleTolerance("toleranceUp1", EnumTolerance.UP_1, true); - toleranceUp2 = new AlleleTolerance("toleranceUp2", EnumTolerance.UP_2); - toleranceUp3 = new AlleleTolerance("toleranceUp3", EnumTolerance.UP_3); - toleranceUp4 = new AlleleTolerance("toleranceUp4", EnumTolerance.UP_4); - toleranceUp5 = new AlleleTolerance("toleranceUp5", EnumTolerance.UP_5); - toleranceDown1 = new AlleleTolerance("toleranceDown1", EnumTolerance.DOWN_1, true); - toleranceDown2 = new AlleleTolerance("toleranceDown2", EnumTolerance.DOWN_2); - toleranceDown3 = new AlleleTolerance("toleranceDown3", EnumTolerance.DOWN_3); - toleranceDown4 = new AlleleTolerance("toleranceDown4", EnumTolerance.DOWN_4); - toleranceDown5 = new AlleleTolerance("toleranceDown5", EnumTolerance.DOWN_5); - - // TREES // FERTILITY - saplingsLowest = new AlleleFloat("saplingsLowest", 0.01f, true).setName("saplings", "lowest"); - saplingsLower = new AlleleFloat("saplingsLower", 0.025f, true).setName("saplings", "lower"); - saplingsLow = new AlleleFloat("saplingsLow", 0.035f, true).setName("saplings", "low"); - saplingsAverage = new AlleleFloat("saplingsDefault", 0.05f, true).setName("saplings", "average"); - saplingsHigh = new AlleleFloat("saplingsDouble", 0.1f, true).setName("saplings", "high"); - saplingsHigher = new AlleleFloat("saplingsTriple", 0.2f, true).setName("saplings", "higher"); - saplingsHighest = new AlleleFloat("saplingsHighest", 0.3f, true).setName("saplings", "highest"); - - // TREES // YIELD - yieldLowest = new AlleleFloat("yieldLowest", 0.025f, true).setName("yield", "lowest"); - yieldLower = new AlleleFloat("yieldLower", 0.05f, true).setName("yield", "lower"); - yieldLow = new AlleleFloat("yieldLow", 0.1f, true).setName("yield", "low"); - yieldAverage = new AlleleFloat("yieldDefault", 0.2f, true).setName("yield", "average"); - yieldHigh = new AlleleFloat("yieldHigh", 0.3f, false).setName("yield", "high"); - yieldHigher = new AlleleFloat("yieldHigher", 0.35f, false).setName("yield", "higher"); - yieldHighest = new AlleleFloat("yieldHighest", 0.4f, false).setName("yield", "highest"); - - // TREES // SAPPINESS - sappinessLowest = new AlleleFloat("sappinessLowest", 0.1f, true).setName("sappiness", "lowest"); - sappinessLower = new AlleleFloat("sappinessLower", 0.2f, true).setName("sappiness", "lower"); - sappinessLow = new AlleleFloat("sappinessLow", 0.3f, true).setName("sappiness", "low"); - sappinessAverage = new AlleleFloat("sappinessAverage", 0.4f, true).setName("sappiness", "average"); - sappinessHigh = new AlleleFloat("sappinessHigh", 0.6f, true).setName("sappiness", "high"); - sappinessHigher = new AlleleFloat("sappinessHigher", 0.8f, false).setName("sappiness", "higher"); - sappinessHighest = new AlleleFloat("sappinessHighest", 1.0f, false).setName("sappiness", "highest"); - - // TREES // MATURATION TIME - maturationSlowest = new AlleleInteger("maturationSlowest", 10, true).setName("maturity", "slowest"); - maturationSlower = new AlleleInteger("maturationSlower", 7).setName("maturity", "slower"); - maturationSlow = new AlleleInteger("maturationSlow", 5, true).setName("maturity", "slow"); - maturationAverage = new AlleleInteger("maturationAverage", 4).setName("maturity", "average"); - maturationFast = new AlleleInteger("maturationFast", 3).setName("maturity", "fast"); - maturationFaster = new AlleleInteger("maturationFaster", 2).setName("maturity", "faster"); - maturationFastest = new AlleleInteger("maturationFastest", 1).setName("maturity", "fastest"); - - // BEES // FLOWER GROWTH - floweringSlowest = new AlleleInteger("floweringSlowest", 5, true).setName("flowering", "slowest"); - floweringSlower = new AlleleInteger("floweringSlower", 10).setName("flowering", "slower"); - floweringSlow = new AlleleInteger("floweringSlow", 15).setName("flowering", "slow"); - floweringAverage = new AlleleInteger("floweringAverage", 20).setName("flowering", "average"); - floweringFast = new AlleleInteger("floweringFast", 25).setName("flowering", "fast"); - floweringFaster = new AlleleInteger("floweringFaster", 30).setName("flowering", "faster"); - floweringFastest = new AlleleInteger("floweringFastest", 35).setName("flowering", "fastest"); - floweringMaximum = new AlleleInteger("floweringMaximum", 99, true).setName("flowering", "maximum"); - - // BOTH // TERRITORY - territoryDefault = new AlleleArea("territoryDefault", new int[]{9, 6, 9}).setName("territory", "average"); - territoryLarge = new AlleleArea("territoryLarge", new int[]{11, 8, 11}).setName("territory", "large"); - territoryLarger = new AlleleArea("territoryLarger", new int[]{13, 12, 13}).setName("territory", "larger"); - territoryLargest = new AlleleArea("territoryLargest", new int[]{15, 13, 15}).setName("territory", "largest"); - - // TREES // PLANTS - plantTypeNone = new AllelePlantType("plantTypeNone", EnumSet.noneOf(EnumPlantType.class), true); - plantTypePlains = new AllelePlantType("plantTypePlains", EnumPlantType.Plains); - - plantTypeDesert = new AllelePlantType("plantTypeDesert", EnumPlantType.Desert); - plantTypeBeach = new AllelePlantType("plantTypeBeach", EnumPlantType.Beach); - plantTypeCave = new AllelePlantType("plantTypeCave", EnumPlantType.Cave); - plantTypeWater = new AllelePlantType("plantTypeWater", EnumPlantType.Water); - plantTypeNether = new AllelePlantType("plantTypeNether", EnumPlantType.Nether); - plantTypeCrop = new AllelePlantType("plantTypeCrop", EnumPlantType.Crop); - - fireproofFalse = new AlleleBoolean("fireproofFalse", false); - fireproofTrue = new AlleleBoolean("fireproofTrue", true); + public static final Allele fireproofFalse = new AlleleBoolean("fireproofFalse", false); + public static final Allele fireproofTrue = new AlleleBoolean("fireproofTrue", true); + public static void setupLegacyAPI() { // LEGACY MAPPINGS ILegacyHandler legacy = (ILegacyHandler) AlleleManager.alleleRegistry; @@ -703,7 +559,6 @@ public class Allele implements IAllele { legacy.registerLegacyMapping(1751, "forestry.territoryLarge"); legacy.registerLegacyMapping(1752, "forestry.territoryLarger"); legacy.registerLegacyMapping(1753, "forestry.territoryLargest"); - } @Override diff --git a/src/main/java/forestry/plugins/ForestryPlugin.java b/src/main/java/forestry/plugins/ForestryPlugin.java index 2f3a45f9f..86d117eb1 100755 --- a/src/main/java/forestry/plugins/ForestryPlugin.java +++ b/src/main/java/forestry/plugins/ForestryPlugin.java @@ -41,10 +41,13 @@ public abstract class ForestryPlugin { return EnumSet.of(PluginManager.Module.CORE); } - protected void preInit() { + protected void setupAPI() { } - protected void disabledPreInit() { + protected void disabledSetupAPI() { + } + + protected void preInit() { } protected void doInit() { @@ -53,9 +56,6 @@ public abstract class ForestryPlugin { protected void postInit() { } - protected void disabledPostInit() { - } - public boolean processIMCMessage(IMCMessage message) { return false; } @@ -101,6 +101,9 @@ public abstract class ForestryPlugin { protected void registerItems() { } + protected void registerTriggers() { + } + protected void registerBackpackItems() { } diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 0ef94a125..c6ab280de 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -188,12 +188,10 @@ public class PluginApiculture extends ForestryPlugin { public static MachineDefinition definitionBeehouse; public static MachineDefinition definitionAnalyzer; - @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public void preInit() { - super.preInit(); - - MinecraftForge.EVENT_BUS.register(this); + @SuppressWarnings({"unchecked", "rawtypes"}) + protected void setupAPI() { + super.setupAPI(); HiveManager.hiveRegistry = hiveRegistry = new HiveRegistry(); HiveManager.genHelper = new HiveGenHelper(); @@ -201,6 +199,25 @@ public class PluginApiculture extends ForestryPlugin { FlowerManager.flowerRegistry = new FlowerRegistry(); + BeeManager.villageBees = new ArrayList[]{new ArrayList(), new ArrayList()}; + + // Init bee interface + AlleleManager.alleleRegistry.registerSpeciesRoot(PluginApiculture.beeInterface = new BeeHelper()); + + // Modes + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.easy); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.normal); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hard); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hardcore); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.insane); + } + + @Override + public void preInit() { + super.preInit(); + + MinecraftForge.EVENT_BUS.register(this); + ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture"); ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture); ForestryBlock.apiculture.block().setHarvestLevel("axe", 0); @@ -240,10 +257,6 @@ public class PluginApiculture extends ForestryPlugin { ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemForestryBlock.class, "beehives"); - // Init bee interface - AlleleManager.alleleRegistry.registerSpeciesRoot(PluginApiculture.beeInterface = new BeeHelper()); - BeeManager.villageBees = new ArrayList[]{new ArrayList(), new ArrayList()}; - // Candles ForestryBlock.candle.registerBlock(new BlockCandle(), ItemCandleBlock.class, "candle"); ForestryBlock.stump.registerBlock(new BlockStump(), ItemForestryBlock.class, "stump"); @@ -262,13 +275,6 @@ public class PluginApiculture extends ForestryPlugin { VillageHandlerApiculture.registerVillageComponents(); } - // Modes - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.easy); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.normal); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hard); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hardcore); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.insane); - // Commands PluginCore.rootCommand.addChildCommand(new CommandBee()); } @@ -428,10 +434,6 @@ public class PluginApiculture extends ForestryPlugin { ForestryItem.scoop.item().setHarvestLevel("scoop", 3); } - @Override - protected void registerBackpackItems() { - } - @Override protected void registerCrates() { ICrateRegistry crateRegistry = StorageManager.crateRegistry; @@ -703,7 +705,7 @@ public class PluginApiculture extends ForestryPlugin { definitionChest.register(); } - public IRecipe[] createAlyzerRecipes(Block block, int meta) { + public static IRecipe[] createAlyzerRecipes(Block block, int meta) { ArrayList recipes = new ArrayList(); recipes.add(ShapedRecipeCustom.createShapedRecipe(new ItemStack(block, 1, meta), "XTX", " Y ", "X X", 'Y', ForestryItem.sturdyCasing, 'T', ForestryItem.beealyzer, 'X', "ingotBronze")); recipes.add(ShapedRecipeCustom.createShapedRecipe(new ItemStack(block, 1, meta), "XTX", " Y ", "X X", 'Y', ForestryItem.sturdyCasing, 'T', ForestryItem.treealyzer, 'X', "ingotBronze")); @@ -733,7 +735,7 @@ public class PluginApiculture extends ForestryPlugin { swampDrops.add(new HiveDrop(BeeTemplates.getValiantTemplate(), new ItemStack[]{ForestryItem.beeComb.getItemStack(1, 15)}, 3)); } - private void registerDungeonLoot() { + private static void registerDungeonLoot() { int rarity; if (Config.dungeonLootRare) { rarity = 5; @@ -760,7 +762,7 @@ public class PluginApiculture extends ForestryPlugin { ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getBeeItemFromTemplate(BeeTemplates.getMeadowsTemplate(), EnumBeeType.PRINCESS), 1, 1, 5)); } - private ItemStack getBeeItemFromTemplate(IAllele[] template, EnumBeeType beeType) { + private static ItemStack getBeeItemFromTemplate(IAllele[] template, EnumBeeType beeType) { IBee bee = new Bee(PluginApiculture.beeInterface.templateAsGenome(template)); ItemStack beeItem; switch (beeType) { @@ -810,7 +812,7 @@ public class PluginApiculture extends ForestryPlugin { BeeManager.hiveDrops[7] = swarmDrops; } - private void createHives() { + private static void createHives() { hiveRegistry.registerHive(HiveRegistry.forest, HiveDescription.FOREST); hiveRegistry.registerHive(HiveRegistry.meadows, HiveDescription.MEADOWS); hiveRegistry.registerHive(HiveRegistry.desert, HiveDescription.DESERT); @@ -830,7 +832,7 @@ public class PluginApiculture extends ForestryPlugin { hiveRegistry.addDrops(HiveRegistry.swamp, swampDrops); } - private void createAlleles() { + private static void createAlleles() { IClassification hymnoptera = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "hymnoptera", "Hymnoptera"); AlleleManager.alleleRegistry.getClassification("class.insecta").addMemberGroup(hymnoptera); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 4ac4b4f55..5e22d7225 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -194,6 +194,21 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.fences1, ForestryBlock.fences2); + @Override + protected void setupAPI() { + super.setupAPI(); + + // Init tree interface + AlleleManager.alleleRegistry.registerSpeciesRoot(PluginArboriculture.treeInterface = new TreeHelper()); + + // Modes + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.easy); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.normal); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hard); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hardcore); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.insane); + } + @Override public void preInit() { super.preInit(); @@ -290,15 +305,9 @@ public class PluginArboriculture extends ForestryPlugin { 'Y', Blocks.chest)) .setFaces(0, 1, 2, 3, 4, 4, 0, 7)); - // Init tree interface - AlleleManager.alleleRegistry.registerSpeciesRoot(PluginArboriculture.treeInterface = new TreeHelper()); - // Init rendering proxy.initializeRendering(); - // Create alleles - createAlleles(); - // Register vanilla and forestry fence ids validFences.add(ForestryBlock.fences1.block()); validFences.add(ForestryBlock.fences2.block()); @@ -306,15 +315,14 @@ public class PluginArboriculture extends ForestryPlugin { validFences.add(Blocks.fence_gate); validFences.add(Blocks.nether_brick_fence); - // Modes - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.easy); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.normal); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hard); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hardcore); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.insane); - // Commands PluginCore.rootCommand.addChildCommand(new CommandTree()); + + // Create alleles + createAlleles(); + createMutations(); + registerTemplates(); + registerErsatzGenomes(); } @Override @@ -327,10 +335,6 @@ public class PluginArboriculture extends ForestryPlugin { GameRegistry.registerTileEntity(TileFruitPod.class, "forestry.Pods"); definitionChest.register(); - createMutations(); - registerTemplates(); - registerErsatzGenomes(); - MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture()); if (Config.enableVillager) { @@ -590,7 +594,7 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addRecipe(ForestryItem.grafter.getItemStack(), " B", " # ", "# ", 'B', "ingotBronze", '#', Items.stick); } - private void createAlleles() { + private static void createAlleles() { // Divisions IClassification angiosperms = AlleleManager.alleleRegistry.createAndRegisterClassification( @@ -1037,7 +1041,7 @@ public class PluginArboriculture extends ForestryPlugin { } - private void registerTemplates() { + private static void registerTemplates() { treeInterface.registerTemplate(TreeTemplates.getOakTemplate()); treeInterface.registerTemplate(TreeTemplates.getBirchTemplate()); treeInterface.registerTemplate(TreeTemplates.getSpruceTemplate()); @@ -1084,7 +1088,7 @@ public class PluginArboriculture extends ForestryPlugin { treeInterface.registerTemplate(TreeTemplates.getDateTemplate()); } - private void registerErsatzGenomes() { + private static void registerErsatzGenomes() { AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 0), new Tree( TreeTemplates.templateAsGenome(TreeTemplates.getOakTemplate()))); AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 1), new Tree( @@ -1112,7 +1116,7 @@ public class PluginArboriculture extends ForestryPlugin { TreeTemplates.templateAsGenome(TreeTemplates.getDarkOakTemplate()))); } - private void createMutations() { + private static void createMutations() { // Decidious TreeTemplates.limeA = new TreeMutation(Allele.treeBirch, Allele.treeOak, @@ -1213,22 +1217,7 @@ public class PluginArboriculture extends ForestryPlugin { @Override public IFuelHandler getFuelHandler() { - return new IFuelHandler() { - @Override - public int getBurnTime(ItemStack fuel) { - if (ForestryItem.sapling.isItemEqual(fuel)) { - return 100; - } - - for (ForestryBlock slab : slabs) { - if (slab.isItemEqual(fuel)) { - return 150; - } - } - - return 0; - } - }; + return new FuelHandler(); } @Override @@ -1250,25 +1239,25 @@ public class PluginArboriculture extends ForestryPlugin { return super.processIMCMessage(message); } - private void registerDungeonLoot() { + private static void registerDungeonLoot() { ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(ForestryItem.grafter.getItemStack(), 1, 1, 8)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); if (PluginManager.Module.APICULTURE.isEnabled()) { - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(this.getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); } } - private ItemStack getTreeItemFromTemplate(IAllele[] template, EnumGermlingType type) { + private static ItemStack getTreeItemFromTemplate(IAllele[] template, EnumGermlingType type) { ITree tree = new Tree(PluginArboriculture.treeInterface.templateAsGenome(template)); ItemStack treeItem; switch (type) { @@ -1284,4 +1273,21 @@ public class PluginArboriculture extends ForestryPlugin { treeItem.setTagCompound(nbtTagCompound); return treeItem; } + + private static class FuelHandler implements IFuelHandler { + @Override + public int getBurnTime(ItemStack fuel) { + if (ForestryItem.sapling.isItemEqual(fuel)) { + return 100; + } + + for (ForestryBlock slab : slabs) { + if (slab.isItemEqual(fuel)) { + return 150; + } + } + + return 0; + } + } } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index ae6a25e63..a11c2f92a 100644 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -84,11 +84,8 @@ public class PluginCore extends ForestryPlugin { public static final RootCommand rootCommand = new RootCommand(); @Override - public void preInit() { - super.preInit(); - - rootCommand.addChildCommand(new CommandVersion()); - rootCommand.addChildCommand(new CommandPlugins()); + protected void setupAPI() { + super.setupAPI(); ChipsetManager.solderManager = new ItemSolderingIron.SolderManager(); @@ -101,7 +98,15 @@ public class PluginCore extends ForestryPlugin { AlleleManager.climateHelper = new ClimateHelper(); alleleRegistry.initialize(); - Allele.initialize(); + Allele.setupLegacyAPI(); + } + + @Override + public void preInit() { + super.preInit(); + + rootCommand.addChildCommand(new CommandVersion()); + rootCommand.addChildCommand(new CommandPlugins()); ForestryBlock.core.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "core"); @@ -276,14 +281,6 @@ public class PluginCore extends ForestryPlugin { ForestryItem.fruits.registerItem(new ItemFruit(), "fruits"); } - @Override - public void postInit() { - } - - @Override - protected void registerBackpackItems() { - } - @Override protected void registerCrates() { ICrateRegistry crateRegistry = StorageManager.crateRegistry; @@ -450,19 +447,21 @@ public class PluginCore extends ForestryPlugin { @Override public IFuelHandler getFuelHandler() { - return new IFuelHandler() { + return new FuelHandler(); + } - @Override - public int getBurnTime(ItemStack fuel) { - if (fuel != null && fuel.getItem() == ForestryItem.peat.item()) { - return 2000; - } - if (fuel != null && fuel.getItem() == ForestryItem.bituminousPeat.item()) { - return 4200; - } + private static class FuelHandler implements IFuelHandler { - return 0; + @Override + public int getBurnTime(ItemStack fuel) { + if (fuel != null && fuel.getItem() == ForestryItem.peat.item()) { + return 2000; } - }; + if (fuel != null && fuel.getItem() == ForestryItem.bituminousPeat.item()) { + return 4200; + } + + return 0; + } } } diff --git a/src/main/java/forestry/plugins/PluginEnergy.java b/src/main/java/forestry/plugins/PluginEnergy.java index d5343c59a..abfdb8a98 100755 --- a/src/main/java/forestry/plugins/PluginEnergy.java +++ b/src/main/java/forestry/plugins/PluginEnergy.java @@ -23,8 +23,6 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; -import forestry.core.interfaces.IOreDictionaryHandler; -import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.utils.ShapedRecipeCustom; import forestry.energy.GuiHandlerEnergy; @@ -97,34 +95,8 @@ public class PluginEnergy extends ForestryPlugin { definitionEngineClockwork.register(); } - @Override - protected void registerItems() { - } - - @Override - protected void registerBackpackItems() { - } - - @Override - protected void registerRecipes() { - } - - @Override - protected void registerCrates() { - } - @Override public IGuiHandler getGuiHandler() { return new GuiHandlerEnergy(); } - - @Override - public ISaveEventHandler getSaveEventHandler() { - return null; - } - - @Override - public IOreDictionaryHandler getDictionaryHandler() { - return null; - } } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index 49be9d85b..d11c6c465 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.plugins; -import java.util.Arrays; +import com.google.common.collect.ImmutableList; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -68,10 +68,25 @@ public class PluginFactory extends ForestryPlugin { public static MachineDefinition definitionWorktable; @Override - protected void disabledPreInit() { - super.disabledPreInit(); + protected void setupAPI() { + super.setupAPI(); - RecipeManagers.craftingProviders = Arrays.asList( + RecipeManagers.craftingProviders = ImmutableList.of( + RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager(), + RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager(), + RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager(), + RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager(), + RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager(), + RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager(), + RecipeManagers.stillManager = new MachineStill.RecipeManager() + ); + } + + @Override + protected void disabledSetupAPI() { + super.disabledSetupAPI(); + + RecipeManagers.craftingProviders = ImmutableList.of( RecipeManagers.carpenterManager = new DummyManagers.CarpenterManager(), RecipeManagers.centrifugeManager = new DummyManagers.CentrifugeManager(), RecipeManagers.fabricatorManager = new DummyManagers.FabricatorManager(), @@ -86,16 +101,6 @@ public class PluginFactory extends ForestryPlugin { public void preInit() { super.preInit(); - RecipeManagers.craftingProviders = Arrays.asList( - RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager(), - RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager(), - RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager(), - RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager(), - RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager(), - RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager(), - RecipeManagers.stillManager = new MachineStill.RecipeManager() - ); - ForestryBlock.factoryTESR.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "factory"); BlockBase factoryTESR = ((BlockBase) ForestryBlock.factoryTESR.block()); @@ -215,11 +220,11 @@ public class PluginFactory extends ForestryPlugin { 'W', Blocks.crafting_table, 'C', Blocks.chest)) .setFaces(0, 1, 2, 3, 4, 4)); + } - // Triggers - if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) { - FactoryTriggers.initialize(); - } + @Override + protected void registerTriggers() { + FactoryTriggers.initialize(); } @Override diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index d6ca8c3de..507f8adda 100644 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -85,10 +85,15 @@ public class PluginFarming extends ForestryPlugin { public static ItemStack farmFertilizer; @Override - public void preInit() { - super.preInit(); + protected void setupAPI() { + super.setupAPI(); Farmables.farmInterface = new FarmHelper(); + } + + @Override + public void preInit() { + super.preInit(); ForestryBlock.mushroom.registerBlock(new BlockMushroom(), ItemTypedBlock.class, "mushroom"); @@ -130,11 +135,6 @@ public class PluginFarming extends ForestryPlugin { proxy.initializeRendering(); - // Triggers - if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) { - FarmingTriggers.initialize(); - } - // Layouts ICircuitLayout layoutManaged = new CircuitLayout("farms.managed"); ChipsetManager.circuitRegistry.registerLayout(layoutManaged); @@ -142,6 +142,11 @@ public class PluginFarming extends ForestryPlugin { ChipsetManager.circuitRegistry.registerLayout(layoutManual); } + @Override + protected void registerTriggers() { + FarmingTriggers.initialize(); + } + @Override public void doInit() { super.doInit(); diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index 6dddfaf8e..e4a3df810 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -36,8 +36,8 @@ import forestry.food.items.ItemInfuser; public class PluginFood extends ForestryPlugin { @Override - public void preInit() { - super.preInit(); + protected void setupAPI() { + super.setupAPI(); // Init seasoner BeverageManager.infuserManager = new ItemInfuser.MixtureManager(); @@ -72,10 +72,6 @@ public class PluginFood extends ForestryPlugin { LiquidHelper.injectLiquidContainer(Fluids.SHORT_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); } - @Override - protected void registerBackpackItems() { - } - @Override protected void registerRecipes() { // INFUSER @@ -85,22 +81,8 @@ public class PluginFood extends ForestryPlugin { 'X', "ingotBronze"); } - @Override - protected void registerCrates() { - } - @Override public IGuiHandler getGuiHandler() { return new GuiHandlerFood(); } - - @Override - public ISaveEventHandler getSaveEventHandler() { - return null; - } - - @Override - public IOreDictionaryHandler getDictionaryHandler() { - return null; - } } diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index d537f74f1..61890778d 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -84,12 +84,18 @@ public class PluginLepidopterology extends ForestryPlugin { public static MachineDefinition definitionChest; @Override - public void preInit() { - ForestryBlock.lepidopterology.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "lepidopterology"); - ForestryBlock.lepidopterology.block().setCreativeTab(Tabs.tabLepidopterology); + protected void setupAPI() { + super.setupAPI(); AlleleManager.alleleRegistry.registerSpeciesRoot(PluginLepidopterology.butterflyInterface = new ButterflyHelper()); createAlleles(); + registerTemplates(); + } + + @Override + public void preInit() { + ForestryBlock.lepidopterology.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "lepidopterology"); + ForestryBlock.lepidopterology.block().setCreativeTab(Tabs.tabLepidopterology); } @Override @@ -121,7 +127,6 @@ public class PluginLepidopterology extends ForestryPlugin { Utils.registerEntity(EntityButterfly.class, "butterflyGE", 0, 0x000000, 0xffffff, 50, 1, true); proxy.initializeRendering(); - registerTemplates(); BlockBase lepidopterology = ((BlockBase) ForestryBlock.lepidopterology.block()); definitionChest = lepidopterology.addDefinition((new MachineDefinition(Defaults.DEFINITION_LEPICHEST_META, "forestry.LepiChest", TileLepidopteristChest.class, @@ -159,7 +164,7 @@ public class PluginLepidopterology extends ForestryPlugin { Items.redstone, 'D', Items.diamond); } - private void createAlleles() { + private static void createAlleles() { IClassification lepidoptera = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "lepidoptera", "Lepidoptera"); AlleleManager.alleleRegistry.getClassification("class.insecta").addMemberGroup(lepidoptera); @@ -273,7 +278,13 @@ public class PluginLepidopterology extends ForestryPlugin { Allele.butterflyNone = new AlleleEffectNone("bfNone", false); } - private void registerTemplates() { + private static IClassification createButterflyBranch(IClassification family, String scientific) { + IClassification branch = new Branch("moth." + scientific.toLowerCase(Locale.ENGLISH), scientific); + branch.setParent(family); + return branch; + } + + private static void registerTemplates() { butterflyInterface.registerTemplate(ButterflyTemplates.getBrimstoneMothTemplate()); butterflyInterface.registerTemplate(ButterflyTemplates.getLatticedHeathTemplate()); butterflyInterface.registerTemplate(ButterflyTemplates.getAtlasMothTemplate()); @@ -319,12 +330,6 @@ public class PluginLepidopterology extends ForestryPlugin { } - private IClassification createButterflyBranch(IClassification family, String scientific) { - IClassification branch = new Branch("moth." + scientific.toLowerCase(Locale.ENGLISH), scientific); - branch.setParent(family); - return branch; - } - @Override public IGuiHandler getGuiHandler() { return new GuiHandlerLepidopterology(); diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index 92cc87c7b..b61db5747 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -63,6 +63,15 @@ public class PluginMail extends ForestryPlugin { public static MachineDefinition definitionPhilatelist; public static StampInfo[] stampDefinitions; + @Override + protected void setupAPI() { + super.setupAPI(); + + PostManager.postRegistry = new PostRegistry(); + PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.PLAYER)); + PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.TRADER)); + } + @Override public void preInit() { super.preInit(); @@ -71,11 +80,6 @@ public class PluginMail extends ForestryPlugin { new TickHandlerMailClient(); - // Triggers - if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) { - MailTriggers.initialize(); - } - ForestryBlock.mail.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "mail"); ShapedRecipeCustom recipe = ShapedRecipeCustom.createShapedRecipe(ForestryBlock.mail.getItemStack(1, Defaults.DEFINITION_MAILBOX_META), @@ -102,10 +106,11 @@ public class PluginMail extends ForestryPlugin { definitionPhilatelist = mail.addDefinition(new MachineDefinition(Defaults.DEFINITION_PHILATELIST_META, "forestry.Philatelist", MachinePhilatelist.class) .setFaces(0, 1, 2, 3, 2, 2, 0, 7)); + } - PostManager.postRegistry = new PostRegistry(); - PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.PLAYER)); - PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.TRADER)); + @Override + protected void registerTriggers() { + MailTriggers.initialize(); } @Override @@ -117,11 +122,6 @@ public class PluginMail extends ForestryPlugin { definitionPhilatelist.register(); } - @Override - public void postInit() { - super.postInit(); - } - @Override public IGuiHandler getGuiHandler() { return new GuiHandlerMail(); @@ -151,14 +151,6 @@ public class PluginMail extends ForestryPlugin { ForestryItem.catalogue.registerItem(new ItemCatalogue(), "catalogue"); } - @Override - protected void registerBackpackItems() { - } - - @Override - protected void registerCrates() { - } - @Override protected void registerRecipes() { // Letters @@ -203,9 +195,4 @@ public class PluginMail extends ForestryPlugin { public ISaveEventHandler getSaveEventHandler() { return new SaveEventHandlerMail(); } - - @Override - public IOreDictionaryHandler getDictionaryHandler() { - return null; - } } diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 52bedef58..33a13ade8 100644 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -61,8 +61,7 @@ public class PluginManager { private static Stage stage = Stage.SETUP; public enum Stage { - - SETUP, PRE_INIT, PRE_INIT_DISABLED, INIT, POST_INIT, POST_INIT_DISABLED, FINISHED + SETUP, SETUP_DISABLED, PRE_INIT, INIT, POST_INIT, FINISHED } public enum Module { @@ -142,84 +141,6 @@ public class PluginManager { return loadedModules.contains(module); } - public static void runPreInit() { - stage = Stage.SETUP; - Locale locale = Locale.getDefault(); - Locale.setDefault(Locale.ENGLISH); - - Configuration config = new Configuration(new File(Forestry.instance.getConfigFolder(), MODULE_CONFIG_FILE_NAME)); - - config.load(); - config.addCustomCategoryComment(CATEGORY_MODULES, "Disabling these modules can greatly change how the mod functions.\n" - + "Your mileage may vary, please report any issues."); - - Set toLoad = EnumSet.allOf(Module.class); - Iterator it = toLoad.iterator(); - while (it.hasNext()) { - Module m = it.next(); - if (!m.canBeDisabled()) { - continue; - } - if (!isEnabled(config, m)) { - it.remove(); - Proxies.log.info("Module disabled: {0}", m); - continue; - } - ForestryPlugin plugin = m.instance; - if (!plugin.isAvailable()) { - it.remove(); - Proxies.log.info("Module {0} failed to load: {1}", plugin, plugin.getFailMessage()); - continue; - } - } - boolean changed; - do { - changed = false; - it = toLoad.iterator(); - while (it.hasNext()) { - Module m = it.next(); - Set deps = m.instance().getDependancies(); - if (!toLoad.containsAll(deps)) { - it.remove(); - changed = true; - Proxies.log.warning("Module {0} is missing dependencies: {1}", m, deps); - continue; - } - } - } while (changed); - - unloadedModules.removeAll(toLoad); - loadedModules.addAll(toLoad); - - if (config.hasChanged()) { - config.save(); - } - - Locale.setDefault(locale); - - stage = Stage.PRE_INIT; - for (Module m : loadedModules) { - ForestryPlugin plugin = m.instance; - loadPlugin(plugin); - } - - for (Module m : loadedModules) { - ForestryPlugin plugin = m.instance; - Proxies.log.fine("Pre-Init Start: {0}", plugin); - plugin.preInit(); - plugin.registerItems(); - Proxies.log.fine("Pre-Init Complete: {0}", plugin); - } - - stage = Stage.PRE_INIT_DISABLED; - for (Module m : unloadedModules) { - ForestryPlugin plugin = m.instance; - Proxies.log.fine("Disabled-Pre-Init Start: {0}", plugin); - plugin.disabledPreInit(); - Proxies.log.fine("Disabled-Pre-Init Complete: {0}", plugin); - } - } - private static void loadPlugin(ForestryPlugin plugin) { Proxies.log.fine("Registering Handlers for Plugin: {0}", plugin); @@ -259,17 +180,110 @@ public class PluginManager { } } + private static void configureModules() { + Locale locale = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + + Configuration config = new Configuration(new File(Forestry.instance.getConfigFolder(), MODULE_CONFIG_FILE_NAME)); + + config.load(); + config.addCustomCategoryComment(CATEGORY_MODULES, "Disabling these modules can greatly change how the mod functions.\n" + + "Your mileage may vary, please report any issues."); + + Set toLoad = EnumSet.allOf(Module.class); + Iterator it = toLoad.iterator(); + while (it.hasNext()) { + Module m = it.next(); + if (!m.canBeDisabled()) { + continue; + } + if (!isEnabled(config, m)) { + it.remove(); + Proxies.log.info("Module disabled: {0}", m); + continue; + } + ForestryPlugin plugin = m.instance; + if (!plugin.isAvailable()) { + it.remove(); + Proxies.log.info("Module {0} failed to load: {1}", plugin, plugin.getFailMessage()); + continue; + } + } + + boolean changed; + do { + changed = false; + it = toLoad.iterator(); + while (it.hasNext()) { + Module m = it.next(); + Set deps = m.instance().getDependancies(); + if (!toLoad.containsAll(deps)) { + it.remove(); + changed = true; + Proxies.log.warning("Module {0} is missing dependencies: {1}", m, deps); + continue; + } + } + } while (changed); + + unloadedModules.removeAll(toLoad); + loadedModules.addAll(toLoad); + + if (config.hasChanged()) { + config.save(); + } + + Locale.setDefault(locale); + } + + public static void runSetup() { + stage = Stage.SETUP; + configureModules(); + + for (Module m : loadedModules) { + ForestryPlugin plugin = m.instance; + Proxies.log.fine("Setup Start: {0}", plugin); + plugin.setupAPI(); + Proxies.log.fine("Setup Complete: {0}", plugin); + } + + stage = Stage.SETUP_DISABLED; + for (Module m : unloadedModules) { + ForestryPlugin plugin = m.instance; + Proxies.log.fine("Disabled-Setup Start: {0}", plugin); + plugin.disabledSetupAPI(); + Proxies.log.fine("Disabled-Setup Complete: {0}", plugin); + } + } + + public static void runPreInit() { + stage = Stage.PRE_INIT; + for (Module m : loadedModules) { + ForestryPlugin plugin = m.instance; + loadPlugin(plugin); + } + + for (Module m : loadedModules) { + ForestryPlugin plugin = m.instance; + Proxies.log.fine("Pre-Init Start: {0}", plugin); + plugin.preInit(); + plugin.registerItems(); + if (Module.BUILDCRAFT_STATEMENTS.isEnabled()) { + plugin.registerTriggers(); + } + if (Module.STORAGE.isEnabled()) { + plugin.registerBackpackItems(); + plugin.registerCrates(); + } + Proxies.log.fine("Pre-Init Complete: {0}", plugin); + } + } + public static void runInit() { stage = Stage.INIT; for (Module m : loadedModules) { ForestryPlugin plugin = m.instance; Proxies.log.fine("Init Start: {0}", plugin); - - if (Module.STORAGE.isEnabled()) { - plugin.registerBackpackItems(); - plugin.registerCrates(); - } - plugin.doInit(); plugin.registerRecipes(); Proxies.log.fine("Init Complete: {0}", plugin); @@ -285,13 +299,6 @@ public class PluginManager { Proxies.log.fine("Post-Init Complete: {0}", plugin); } - stage = Stage.POST_INIT_DISABLED; - for (Module m : unloadedModules) { - ForestryPlugin plugin = m.instance; - Proxies.log.fine("Disabled-Post-Init Start: {0}", plugin); - plugin.disabledPostInit(); - Proxies.log.fine("Disabled-Post-Init Complete: {0}", plugin); - } stage = Stage.FINISHED; } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 8fb88b757..87631e868 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.plugins; +import java.awt.Color; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -96,7 +97,11 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl @Override @SuppressWarnings({"unchecked", "rawtypes"}) - public void preInit() { + protected void setupAPI() { + super.setupAPI(); + + StorageManager.crateRegistry = new CrateRegistry(); + BackpackManager.backpackInterface = new BackpackHelper(); BackpackManager.backpackItems = new ArrayList[6]; @@ -108,7 +113,35 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl BackpackManager.backpackItems[4] = adventurerItems; BackpackManager.backpackItems[5] = builderItems; - StorageManager.crateRegistry = new CrateRegistry(); + BackpackDefinition definition; + + if (PluginManager.Module.APICULTURE.isEnabled()) { + definition = new BackpackDefinitionApiarist("apiarist", new Color(0xc4923d).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + } + + if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { + definition = new BackpackDefinitionLepidopterist("lepidopterist", new Color(0x995b31).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + } + + definition = new BackpackDefinition("miner", new Color(0x36187d).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + + definition = new BackpackDefinition("digger", new Color(0x363cc5).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + + definition = new BackpackDefinition("forester", new Color(0x347427).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + + definition = new BackpackDefinition("hunter", new Color(0x412215).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + + definition = new BackpackDefinition("adventurer", new Color(0x7fb8c2).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); + + definition = new BackpackDefinition("builder", new Color(0xdd3a3a).getRGB()); + BackpackManager.definitions.put(definition.getKey(), definition); } @Override @@ -147,7 +180,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl } public static void registerCrate(ItemCrated crate) { - proxy.registerCrate(crate); + proxy.registerCrateForRendering(crate); crates.add(crate); } @@ -274,47 +307,41 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl ForestryItem.crate.registerItem((new ItemCrated(null, false)), "crate"); // BACKPACKS - BackpackDefinition definition; + IBackpackDefinition definition; if (PluginManager.Module.APICULTURE.isEnabled()) { - definition = new BackpackDefinitionApiarist("apiarist", 0xc4923d); - BackpackManager.definitions.put(definition.getKey(), definition); - ForestryItem.apiaristBackpack.registerItem(new ItemNaturalistBackpack(GuiId.ApiaristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabApiculture), "apiaristBag"); + definition = BackpackManager.definitions.get("apiarist"); + Item backpack = new ItemNaturalistBackpack(GuiId.ApiaristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabApiculture); + ForestryItem.apiaristBackpack.registerItem(backpack, "apiaristBag"); } if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { - definition = new BackpackDefinitionLepidopterist("lepidopterist", 0x995b31); - BackpackManager.definitions.put(definition.getKey(), definition); - ForestryItem.lepidopteristBackpack.registerItem(new ItemNaturalistBackpack(GuiId.LepidopteristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabLepidopterology), "lepidopteristBag"); + definition = BackpackManager.definitions.get("lepidopterist"); + Item backpack = new ItemNaturalistBackpack(GuiId.LepidopteristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabLepidopterology); + ForestryItem.lepidopteristBackpack.registerItem(backpack, "lepidopteristBag"); } - definition = new BackpackDefinition("miner", 0x36187d); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("miner"); ForestryItem.minerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "minerBag"); ForestryItem.minerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "minerBagT2"); - definition = new BackpackDefinition("digger", 0x363cc5); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("digger"); ForestryItem.diggerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "diggerBag"); ForestryItem.diggerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "diggerBagT2"); - definition = new BackpackDefinition("forester", 0x347427); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("forester"); ForestryItem.foresterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "foresterBag"); ForestryItem.foresterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "foresterBagT2"); - definition = new BackpackDefinition("hunter", 0x412215); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("hunter"); ForestryItem.hunterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "hunterBag"); ForestryItem.hunterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "hunterBagT2"); - definition = new BackpackDefinition("adventurer", 0x7fb8c2); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("adventurer"); ForestryItem.adventurerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "adventurerBag"); ForestryItem.adventurerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "adventurerBagT2"); - definition = new BackpackDefinition("builder", 0xdd3a3a); - BackpackManager.definitions.put(definition.getKey(), definition); + definition = BackpackManager.definitions.get("builder"); ForestryItem.builderBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "builderBag"); ForestryItem.builderBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "builderBagT2"); } diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java index c24bacc73..4fe25b5a5 100644 --- a/src/main/java/forestry/storage/CrateRegistry.java +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -22,17 +22,15 @@ import forestry.plugins.PluginStorage; public class CrateRegistry implements ICrateRegistry { - private void registerCrate(ItemStack stack, String uid, boolean useOreDict) { - if (PluginManager.getStage() != PluginManager.Stage.INIT) { - throw new RuntimeException("Tried to make a crate outside of Init"); - } - + private static void registerCrate(ItemStack stack, String uid, boolean useOreDict) { if (stack == null || stack.getItem() == null) { - throw new RuntimeException("Tried to make a crate without an item"); + Proxies.log.severe("Tried to make a crate without an item"); + return; } if (uid == null) { - throw new RuntimeException("Tried to make a crate without a uid"); + Proxies.log.severe("Tried to make a crate without a uid"); + return; } ItemCrated crate = new ItemCrated(stack, useOreDict); diff --git a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java index f64792940..0631ec35d 100755 --- a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java +++ b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import forestry.api.core.ForestryAPI; import forestry.api.storage.EnumBackpackType; +import forestry.api.storage.IBackpackDefinition; import forestry.plugins.PluginApiculture; import forestry.plugins.PluginLepidopterology; import forestry.storage.BackpackDefinition; @@ -47,7 +48,7 @@ public class ItemNaturalistBackpack extends ItemBackpack { private final int guiId; - public ItemNaturalistBackpack(int guiId, BackpackDefinition definition) { + public ItemNaturalistBackpack(int guiId, IBackpackDefinition definition) { super(definition, EnumBackpackType.APIARIST); this.guiId = guiId; } diff --git a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java index ce28c55ff..03ca3049e 100644 --- a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java +++ b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java @@ -20,7 +20,7 @@ public class ClientProxyStorage extends ProxyStorage { private static final CrateRenderingHandler crateRenderer = new CrateRenderingHandler(); @Override - public void registerCrate(ItemCrated crate) { + public void registerCrateForRendering(ItemCrated crate) { MinecraftForgeClient.registerItemRenderer(crate, crateRenderer); } } diff --git a/src/main/java/forestry/storage/proxy/ProxyStorage.java b/src/main/java/forestry/storage/proxy/ProxyStorage.java index a2043a210..80d89f497 100644 --- a/src/main/java/forestry/storage/proxy/ProxyStorage.java +++ b/src/main/java/forestry/storage/proxy/ProxyStorage.java @@ -14,7 +14,7 @@ import forestry.core.items.ItemCrated; public class ProxyStorage { - public void registerCrate(ItemCrated crate) { + public void registerCrateForRendering(ItemCrated crate) { } }