diff --git a/src/main/java/growthcraft/apples/common/Init.java b/src/main/java/growthcraft/apples/common/Init.java index ca8af0e9..d034512f 100644 --- a/src/main/java/growthcraft/apples/common/Init.java +++ b/src/main/java/growthcraft/apples/common/Init.java @@ -17,8 +17,8 @@ import growthcraft.cellar.shared.definition.BoozeDefinition; import growthcraft.cellar.shared.item.ItemBoozeBottle; import growthcraft.cellar.shared.processing.common.Residue; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.client.render.utils.ItemRenderUtils; -import growthcraft.core.shared.config.GrowthcraftCoreConfig; import growthcraft.core.shared.definition.BlockDefinition; import growthcraft.core.shared.definition.BlockTypeDefinition; import growthcraft.core.shared.definition.ItemDefinition; @@ -363,7 +363,7 @@ private static void registerFermentations() { .brewsFromFallback(spoilInputFs[AppleCiderTypes.APPLE_CIDER_POISONED.ordinal()], TickUtils.minutes(1), null) .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.045f), TickUtils.seconds(45)) - .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); } //////// diff --git a/src/main/java/growthcraft/bees/common/Init.java b/src/main/java/growthcraft/bees/common/Init.java index 85fbff72..eaa9de12 100644 --- a/src/main/java/growthcraft/bees/common/Init.java +++ b/src/main/java/growthcraft/bees/common/Init.java @@ -15,10 +15,10 @@ import growthcraft.bees.shared.init.GrowthcraftBeesItems; import growthcraft.bees.shared.init.GrowthcraftBeesItems.BeesWaxTypes; import growthcraft.bees.shared.init.GrowthcraftBeesItems.MeadTypes; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.CoreRegistry; import growthcraft.core.shared.GrowthcraftCoreApis; import growthcraft.core.shared.client.render.utils.ItemRenderUtils; -import growthcraft.core.shared.config.GrowthcraftCoreConfig; import growthcraft.core.shared.definition.BlockDefinition; import growthcraft.core.shared.definition.ItemDefinition; import growthcraft.cellar.shared.GrowthcraftCellarApis; @@ -350,7 +350,7 @@ private static void registerFermentations() { .brewsFromFallback(spoilInputFs[MeadTypes.MEAD_POISONED.ordinal()], TickUtils.minutes(1), null) .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.15f), TickUtils.seconds(90)) - .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); } diff --git a/src/main/java/growthcraft/cellar/shared/booze/BoozeRegistryHelper.java b/src/main/java/growthcraft/cellar/shared/booze/BoozeRegistryHelper.java index ce4a74e7..61036872 100644 --- a/src/main/java/growthcraft/cellar/shared/booze/BoozeRegistryHelper.java +++ b/src/main/java/growthcraft/cellar/shared/booze/BoozeRegistryHelper.java @@ -6,10 +6,6 @@ import growthcraft.cellar.shared.block.BlockFluidBooze; import growthcraft.cellar.shared.CellarRegistry; import growthcraft.cellar.shared.fluids.Booze; -import growthcraft.cellar.shared.booze.BoozeEffect; -import growthcraft.cellar.shared.booze.BoozeEntry; -import growthcraft.cellar.shared.booze.BoozeRegistry; -import growthcraft.cellar.shared.booze.BoozeTag; import growthcraft.cellar.shared.definition.BlockBoozeDefinition; import growthcraft.cellar.shared.definition.BoozeDefinition; import growthcraft.cellar.shared.item.ItemBoozeBottle; @@ -20,8 +16,6 @@ import growthcraft.core.shared.definition.ItemTypeDefinition; import growthcraft.core.shared.legacy.FluidContainerRegistry; import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; import net.minecraft.util.ResourceLocation; @@ -29,7 +23,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.UniversalBucket; -import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.registries.IForgeRegistry; public class BoozeRegistryHelper { @@ -96,7 +89,7 @@ public static & IObjectVariant & IStringSerializable> void i final ItemStack bucket = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, boozes[i].getFluid()); int bottleVariantID = values[i].getVariantID(); - final FluidStack fluidStack = boozes[i].asFluidStack(GrowthcraftCoreConfig.bottleCapacity); + final FluidStack fluidStack = boozes[i].asFluidStack(GrowthcraftCoreConfig.BOTTLE_CAPACITY); FluidContainerRegistry.registerFluidContainer(fluidStack, bottle.asStack(1, bottleVariantID), FluidContainerRegistry.EMPTY_BOTTLE); //OFF GameRegistry.addShapelessRecipe(bottle.asStack(3, bottleVariantID), bucket, Items.GLASS_BOTTLE, Items.GLASS_BOTTLE, Items.GLASS_BOTTLE); diff --git a/src/main/java/growthcraft/core/GrowthcraftCore.java b/src/main/java/growthcraft/core/GrowthcraftCore.java index 5aa5b66c..adaedbe3 100644 --- a/src/main/java/growthcraft/core/GrowthcraftCore.java +++ b/src/main/java/growthcraft/core/GrowthcraftCore.java @@ -28,6 +28,8 @@ import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import net.minecraftforge.registries.IForgeRegistry; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "after:rustic;" + @@ -43,6 +45,9 @@ public class GrowthcraftCore { @SidedProxy(serverSide = SERVER_PROXY_CLASS, clientSide = CLIENT_PROXY_CLASS) public static CommonProxy proxy; + public static final GrowthcraftCoreConfig config = new GrowthcraftCoreConfig(); + public static final Logger logger = LogManager.getLogger(Reference.MODID); + @Mod.EventHandler public void construct(FMLConstructionEvent event) { GrowthcraftCoreApis.tabGrowthcraft = new TabGrowthcraft(); @@ -52,7 +57,7 @@ public void construct(FMLConstructionEvent event) { @Mod.EventHandler @SuppressWarnings("deprecation") public void preInit(FMLPreInitializationEvent event) { - GrowthcraftCoreConfig.preInit(); + config.preInit(event, "growthcraft/growthcraft-core.cfg"); Init.preInitBlocks(); Init.preInitItems(); diff --git a/src/main/java/growthcraft/core/common/CommonProxy.java b/src/main/java/growthcraft/core/common/CommonProxy.java index 877ad791..e053cbf0 100644 --- a/src/main/java/growthcraft/core/common/CommonProxy.java +++ b/src/main/java/growthcraft/core/common/CommonProxy.java @@ -1,7 +1,6 @@ package growthcraft.core.common; import growthcraft.core.common.worldgen.BlockSaltGeneration; -import growthcraft.core.shared.compat.theoneprobe.TheOneProbeCompat; import growthcraft.core.shared.compat.theoneprobe.TheOneProbeHandler; import growthcraft.core.shared.config.GrowthcraftCoreConfig; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -14,7 +13,7 @@ public void preInit() { } public void init() { - if (GrowthcraftCoreConfig.blockSaltOreWorldGen) { + if (GrowthcraftCoreConfig.BLOCK_SALT_ORE_WORLD_GEN) { GameRegistry.registerWorldGenerator(new BlockSaltGeneration(), 0); } } diff --git a/src/main/java/growthcraft/core/common/worldgen/BlockSaltGeneration.java b/src/main/java/growthcraft/core/common/worldgen/BlockSaltGeneration.java index a359bfe8..91ef9115 100644 --- a/src/main/java/growthcraft/core/common/worldgen/BlockSaltGeneration.java +++ b/src/main/java/growthcraft/core/common/worldgen/BlockSaltGeneration.java @@ -15,8 +15,8 @@ public class BlockSaltGeneration implements IWorldGenerator { // Needs to be configurable - private int minHieght = GrowthcraftCoreConfig.blockSaltOreMinHeight; - private int maxHieght = GrowthcraftCoreConfig.blockSaltOreMaxHeight; + private int minHieght = GrowthcraftCoreConfig.BLOCK_SALT_ORE_MIN_HEIGHT; + private int maxHieght = GrowthcraftCoreConfig.BLOCK_SALT_ORE_MAX_HEIGHT; private WorldGenerator salt_overworld; @@ -44,7 +44,7 @@ private void runGenerator(WorldGenerator generator, World world, Random rand, in public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.getDimension()) { case 0: // Overworld - this.runGenerator(salt_overworld, world, random, chunkX, chunkZ, GrowthcraftCoreConfig.blockSaltOreChanceToSpawn, minHieght, maxHieght); + this.runGenerator(salt_overworld, world, random, chunkX, chunkZ, GrowthcraftCoreConfig.BLOCK_SALT_ORE_CHANCE_TO_SPAWN, minHieght, maxHieght); break; case 1: // The End break; diff --git a/src/main/java/growthcraft/core/shared/config/GrowthcraftConfiguration.java b/src/main/java/growthcraft/core/shared/config/GrowthcraftConfiguration.java index de3b9b69..8e6fe3ff 100644 --- a/src/main/java/growthcraft/core/shared/config/GrowthcraftConfiguration.java +++ b/src/main/java/growthcraft/core/shared/config/GrowthcraftConfiguration.java @@ -1,48 +1,42 @@ package growthcraft.core.shared.config; +import growthcraft.core.shared.GrowthcraftLogger; +import growthcraft.core.shared.Reference; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -import java.io.File; - import org.apache.logging.log4j.Level; -import growthcraft.core.shared.Reference; -import growthcraft.core.shared.GrowthcraftLogger; +import java.io.File; public class GrowthcraftConfiguration extends Configuration { - // REVISE_TEAM 0: Reused pattern from GrowthcraftBambooConfig, correct? - // REVISE_ME 0: Remove cellar dependency. - // INITIALIZE - private static Configuration configuration; + private Configuration configuration; - // Categories - private static final String CATEGORY_GENERAL = "general"; - private static final String CATEGORY_BOOZE = "Booze/Effects"; + /* Categories */ + private static final String categoryGeneral = "general"; - // Values - public static boolean isDebug = false; - public static String logLevel = "info"; - public static boolean hidePoisonedBooze = true; + /* Default Values */ + private Level logLevel = Level.INFO; -/* public GrowthcraftConfiguration(File configDirectory, String name) { - configuration = new Configuration(new File(configDirectory.getPath(), "growthcraft/" + name + ".cfg")); - } */ + public GrowthcraftConfiguration() { /* Nothing to do */ } - public void preInit(FMLPreInitializationEvent e) { - File directory = e.getModConfigurationDirectory(); - configuration = new Configuration(new File(directory.getPath(), "modtut.cfg")); - readConfig(); + public void preInit(FMLPreInitializationEvent event, String configFilePath) { + File directory = event.getModConfigurationDirectory(); + configuration = new Configuration( + new File(directory.getPath(), configFilePath) + ); + readConfig(configFilePath); } - public static void readConfig() { + protected void readConfig(String configFilePath) { try { configuration.load(); - initDebugConfig(); - initBoozeConfig(); + initGeneralConfig(); } catch (Exception e) { - GrowthcraftLogger.getLogger(Reference.MODID).log(Level.ERROR, "Unable to load configuration files for Growthcraft Bamboo!", e); + GrowthcraftLogger.getLogger(Reference.MODID).log( + Level.ERROR, + String.format("Unable to read configuration file at: %s", configFilePath) + ); } finally { if (configuration.hasChanged()) { configuration.save(); @@ -50,11 +44,39 @@ public static void readConfig() { } } - private static void initDebugConfig() { - logLevel = configuration.getString("logLevel", CATEGORY_GENERAL, logLevel, "Set standard logging levels. (INFO, ERROR, DEBUG)"); + /** + * Initialize the general configuration. By default this will also initialize the debug config + * and set the log level for mod that is using this configuration. + * You should override this method and append your custom configurations. + */ + protected void initGeneralConfig() { + // Always call the initialization of the debug configuration as we need it for logging. + initDebugConfig(); + } + + /** + * Initialize the log level for the module. This function is private as it should not be allowed to the overriden unless the caller decides not call super on initGeneralConfig. + */ + private void initDebugConfig() { + logLevel = Level.getLevel( + configuration.getString( + "logLevel", + categoryGeneral, + logLevel.toString(), + "Set standard logging levels, such as INFO, DEBUG, ERROR" + ) + ); + } + + public Configuration getConfiguration() { + return configuration; } - private static void initBoozeConfig() { - hidePoisonedBooze = configuration.getBoolean("hidePoisoned", CATEGORY_BOOZE, hidePoisonedBooze, "Should purposely poisoned booze have its effect hidden?"); + /** + * Sub-modules should call this to check the verbosity of logging. + * @return + */ + public Level getLogLevel() { + return logLevel; } } diff --git a/src/main/java/growthcraft/core/shared/config/GrowthcraftCoreConfig.java b/src/main/java/growthcraft/core/shared/config/GrowthcraftCoreConfig.java index 720eb37e..3f98a025 100644 --- a/src/main/java/growthcraft/core/shared/config/GrowthcraftCoreConfig.java +++ b/src/main/java/growthcraft/core/shared/config/GrowthcraftCoreConfig.java @@ -1,146 +1,45 @@ package growthcraft.core.shared.config; -import growthcraft.core.shared.Reference; import growthcraft.core.shared.legacy.FluidContainerRegistry; -import net.minecraft.util.text.translation.I18n; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -public class GrowthcraftCoreConfig { - // TODO: Keep either this class or GrowthcraftConfiguration - - // TODO: Need to make a super class so that sub-modules can extend. - - private static Configuration config = null; - - public static final String CATEGORY_NAME_GENERAL = "general"; - public static boolean hidePoisonedBooze = true; - - - public static final String CATEGORY_NAME_LOGGING = "logging"; - public static String loggingLevel; +public class GrowthcraftCoreConfig extends GrowthcraftConfiguration { public static final String CATEGORY_NAME_WORLDGEN = "worldgen"; - public static boolean blockSaltOreWorldGen = true; - public static int blockSaltOreMinHeight = 10; - public static int blockSaltOreMaxHeight = 64; - public static int blockSaltOreChanceToSpawn = 5; - - - public static int bottleCapacity = FluidContainerRegistry.BOTTLE_VOLUME; + public static final boolean BLOCK_SALT_ORE_WORLD_GEN = true; + public static final int BLOCK_SALT_ORE_MIN_HEIGHT = 10; + public static final int BLOCK_SALT_ORE_MAX_HEIGHT = 64; + public static final int BLOCK_SALT_ORE_CHANCE_TO_SPAWN = 5; + private static final String CATEGORY_BOOZE = "Booze/Effects"; + public static boolean hidePoisonedBooze = true; - public static void preInit() { - File configFile = new File(Loader.instance().getConfigDir(), "growthcraft/growthcraft-core.cfg"); - config = new Configuration(configFile); - syncFromFiles(); - } - - public static Configuration getConfig() { - return config; - } - - public static void clientPreInit() { - MinecraftForge.EVENT_BUS.register(new ConfigEventHandler()); - - } + public static final int BOTTLE_CAPACITY = FluidContainerRegistry.BOTTLE_VOLUME; - public static void syncFromFiles() { - syncConfig(true, true); + public GrowthcraftCoreConfig() { + super(); } - public static void syncFromGui() { - syncConfig(false, true); + @Override + protected void initGeneralConfig() { + super.initGeneralConfig(); + initWorldGenCategory(); + initBoozeCategory(); } - public static void syncFromFields() { - syncConfig(false, false); + private void initBoozeCategory() { + hidePoisonedBooze = getConfiguration().getBoolean( + "hidePoisoned", + CATEGORY_BOOZE, + hidePoisonedBooze, + "Should purposely poisoned booze have its effect hidden?" + ); } - private static void syncConfig(boolean loadFromConfigFile, boolean readFieldsFromConfig) { - if (loadFromConfigFile) { - config.load(); - } - - /* Configuration: Logging Settings */ - Property propertyLogLevel = config.get(CATEGORY_NAME_LOGGING, "log_level", "info"); - propertyLogLevel.setLanguageKey("config.logging.log_level"); - propertyLogLevel.setComment(I18n.translateToLocal("config.logging.log_level.comment")); - - List propertyOrderLoggingBlocks = new ArrayList(); - propertyOrderLoggingBlocks.add(propertyLogLevel.getName()); - - config.setCategoryPropertyOrder(CATEGORY_NAME_LOGGING, propertyOrderLoggingBlocks); - - /* Configuration: World Generation */ - Property propertyWorldGEnBlocksaltOre = config.get(CATEGORY_NAME_WORLDGEN, "blockSaltOreWorldGen", true); - propertyWorldGEnBlocksaltOre.setLanguageKey("config.worldgen.worldgenBlockSaltOre"); - propertyWorldGEnBlocksaltOre.setComment(I18n.translateToLocal("config.worldgen.worldgenBlockSaltOre.comment")); - - Property propertyBlockSaltOreMinHeight = config.get(CATEGORY_NAME_WORLDGEN, "blockSaltOreMinHeight", 10); - propertyBlockSaltOreMinHeight.setLanguageKey("config.worldgen.blockSaltOreMinHeight"); - propertyBlockSaltOreMinHeight.setComment(I18n.translateToLocal("config.worldgen.blockSaltOreMinHeight.comment")); - - Property propertyBlockSaltOreMaxHeight = config.get(CATEGORY_NAME_WORLDGEN, "blockSaltOreMaxHeight", 64); - propertyBlockSaltOreMaxHeight.setLanguageKey("config.worldgen.blockSaltOreMaxHeight"); - propertyBlockSaltOreMaxHeight.setComment(I18n.translateToLocal("config.worldgen.blockSaltOreMaxHeight.comment")); - - Property propertyBlockSaltOreChanceToSpawn = config.get(CATEGORY_NAME_WORLDGEN, "blockSaltOreChanceToSpawn", 5); - propertyBlockSaltOreChanceToSpawn.setLanguageKey("config.worldgen.blockSaltOreChanceToSpawn"); - propertyBlockSaltOreChanceToSpawn.setComment(I18n.translateToLocal("config.worldgen.blockSaltOreChanceToSpawn.comment")); - - List propertyOrderWorldGenBlocks = new ArrayList(); - propertyOrderWorldGenBlocks.add(propertyWorldGEnBlocksaltOre.getName()); - propertyOrderWorldGenBlocks.add(propertyBlockSaltOreMinHeight.getName()); - propertyOrderWorldGenBlocks.add(propertyBlockSaltOreMaxHeight.getName()); - propertyOrderWorldGenBlocks.add(propertyBlockSaltOreChanceToSpawn.getName()); - - config.setCategoryPropertyOrder(CATEGORY_NAME_WORLDGEN, propertyOrderWorldGenBlocks); - - /* Configuration: General / Everything Else */ - Property propertyHidePoisonedBooze = config.get(CATEGORY_NAME_GENERAL, "hidePoisonedBooze", true); - propertyHidePoisonedBooze.setLanguageKey("config.general.hidePoisonedBooze"); - propertyHidePoisonedBooze.setComment(I18n.translateToLocal("config.general.hidePoisonedBooze.comment")); - - List propertyOrderGeneralBlocks = new ArrayList(); - propertyOrderGeneralBlocks.add(propertyHidePoisonedBooze.getName()); - - config.setCategoryPropertyOrder(CATEGORY_NAME_GENERAL, propertyOrderGeneralBlocks); - - if (readFieldsFromConfig) { - loggingLevel = propertyLogLevel.getString(); - - blockSaltOreWorldGen = propertyWorldGEnBlocksaltOre.getBoolean(); - blockSaltOreMinHeight = propertyBlockSaltOreMinHeight.getInt(); - blockSaltOreMaxHeight = propertyBlockSaltOreMaxHeight.getInt(); - blockSaltOreChanceToSpawn = propertyBlockSaltOreChanceToSpawn.getInt(); - - hidePoisonedBooze = propertyHidePoisonedBooze.getBoolean(); - } - - propertyLogLevel.set(loggingLevel); - - if (config.hasChanged()) - config.save(); + private void initWorldGenCategory() { } - public static class ConfigEventHandler { - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onEvent(ConfigChangedEvent.OnConfigChangedEvent event) { - if (event.getModID().equals(Reference.MODID)) { - syncFromGui(); - } - } + public boolean getHidePoisonedBooze() { + return hidePoisonedBooze; } - } diff --git a/src/main/java/growthcraft/core/shared/fluids/FluidFactory.java b/src/main/java/growthcraft/core/shared/fluids/FluidFactory.java index 776cdc2a..90119c4c 100644 --- a/src/main/java/growthcraft/core/shared/fluids/FluidFactory.java +++ b/src/main/java/growthcraft/core/shared/fluids/FluidFactory.java @@ -137,12 +137,12 @@ public FluidDetails registerBlocks(IForgeRegistry registry, String modID, public FluidDetails registerItems(IForgeRegistry registry, String modID, String basename) { if (bottle != null) { bottle.registerItem(registry, new ResourceLocation(modID, "bottlefluid_" + basename)); - final FluidStack fluidStack = fluid.asFluidStack(GrowthcraftCoreConfig.bottleCapacity); + final FluidStack fluidStack = fluid.asFluidStack(GrowthcraftCoreConfig.BOTTLE_CAPACITY); FluidContainerRegistry.registerFluidContainer(fluidStack, bottle.asStack(1), new ItemStack(Items.GLASS_BOTTLE, 1)); } if (foodBottle != null) { foodBottle.registerItem(registry, new ResourceLocation(modID, "bottlefluid_" + basename)); - final FluidStack fluidStack = fluid.asFluidStack(GrowthcraftCoreConfig.bottleCapacity); + final FluidStack fluidStack = fluid.asFluidStack(GrowthcraftCoreConfig.BOTTLE_CAPACITY); FluidContainerRegistry.registerFluidContainer(fluidStack, foodBottle.asStack(1), new ItemStack(Items.GLASS_BOTTLE, 1)); } diff --git a/src/main/java/growthcraft/core/shared/fluids/UnitFormatter.java b/src/main/java/growthcraft/core/shared/fluids/UnitFormatter.java index 5aa11710..75b8c1ce 100644 --- a/src/main/java/growthcraft/core/shared/fluids/UnitFormatter.java +++ b/src/main/java/growthcraft/core/shared/fluids/UnitFormatter.java @@ -6,7 +6,7 @@ import com.google.common.base.Joiner; -import growthcraft.core.shared.config.GrowthcraftConfiguration; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.CoreRegistry; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; @@ -54,7 +54,7 @@ public static String fluidModifier(Fluid fluid) { if (tags == null || tags.size() == 0) return null; String str = ""; for (FluidTag tag : tags) { - if (GrowthcraftConfiguration.hidePoisonedBooze && tag.getName().equals("poisoned")) + if (GrowthcraftCore.config.getHidePoisonedBooze() && tag.getName().equals("poisoned")) continue; // REVISE_ME str += ((str.length() == 0) ? "" : ", ") + tag.getLocalizedName(); } diff --git a/src/main/java/growthcraft/grapes/common/Init.java b/src/main/java/growthcraft/grapes/common/Init.java index fe9a94b3..1830f692 100644 --- a/src/main/java/growthcraft/grapes/common/Init.java +++ b/src/main/java/growthcraft/grapes/common/Init.java @@ -9,8 +9,8 @@ import growthcraft.cellar.shared.definition.BoozeDefinition; import growthcraft.cellar.shared.item.ItemBoozeBottle; import growthcraft.cellar.shared.processing.common.Residue; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.client.render.utils.ItemRenderUtils; -import growthcraft.core.shared.config.GrowthcraftCoreConfig; import growthcraft.core.shared.definition.BlockDefinition; import growthcraft.core.shared.definition.ItemDefinition; import growthcraft.core.shared.definition.ItemTypeDefinition; @@ -401,7 +401,7 @@ private static void registerFermentations() { .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.05f), TickUtils.seconds(90)) .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0) - .toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); GrowthcraftCellarApis.boozeBuilderFactory.create(grapeWineBooze[WineTypes.RED_WINE_POISONED.ordinal()].getFluid()) .tags(BoozeTag.WINE, BoozeTag.FERMENTED, BoozeTag.POISONED) // .fermentsFromFallback(fs[WineTypes.RED_JUICE.ordinal()], fermentTime) @@ -423,7 +423,7 @@ private static void registerFermentations() { .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.05f), TickUtils.seconds(90)) .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0) - .toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); GrowthcraftCellarApis.boozeBuilderFactory.create(grapeWineBooze[WineTypes.GREEN_WINE_POISONED.ordinal()].getFluid()) .tags(BoozeTag.WINE, BoozeTag.FERMENTED, BoozeTag.POISONED) // .fermentsFromFallback(fs[WineTypes.GREEN_JUICE.ordinal()], fermentTime) @@ -445,7 +445,7 @@ private static void registerFermentations() { .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.05f), TickUtils.seconds(90)) .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0) - .toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); } //////////// diff --git a/src/main/java/growthcraft/hops/common/Init.java b/src/main/java/growthcraft/hops/common/Init.java index 14435974..d25b3e99 100644 --- a/src/main/java/growthcraft/hops/common/Init.java +++ b/src/main/java/growthcraft/hops/common/Init.java @@ -9,9 +9,9 @@ import growthcraft.cellar.shared.definition.BoozeDefinition; import growthcraft.cellar.shared.item.ItemBoozeBottle; import growthcraft.cellar.shared.processing.common.Residue; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.GrowthcraftCoreApis; import growthcraft.core.shared.client.render.utils.ItemRenderUtils; -import growthcraft.core.shared.config.GrowthcraftCoreConfig; import growthcraft.core.shared.definition.BlockDefinition; import growthcraft.core.shared.definition.ItemDefinition; import growthcraft.core.shared.definition.ItemTypeDefinition; @@ -246,7 +246,7 @@ private static void registerLagerFermentations() { .brewsFromFallback(spoilInputFs[LagerTypes.LAGER_POISONED.ordinal()], TickUtils.minutes(1), null) .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.0419f), TickUtils.seconds(45)) - .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); } private static void registerHopAleFermentations() { @@ -360,7 +360,7 @@ private static void registerHopAleFermentations() { .brewsFromFallback(spoilInputFs[HopAleTypes.ALE_POISONED.ordinal()], TickUtils.minutes(1), null) .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.10f), TickUtils.seconds(45)) - .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); + .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); } private static void registerFermentations() { diff --git a/src/main/java/growthcraft/milk/GrowthcraftMilk.java b/src/main/java/growthcraft/milk/GrowthcraftMilk.java index 18a937ec..8e6751b4 100644 --- a/src/main/java/growthcraft/milk/GrowthcraftMilk.java +++ b/src/main/java/growthcraft/milk/GrowthcraftMilk.java @@ -1,12 +1,13 @@ package growthcraft.milk; import growthcraft.milk.common.handlers.HarvestDropsEventHandler; +import growthcraft.milk.shared.config.GrowthcraftMilkConfig; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import growthcraft.milk.common.CommonProxy; import growthcraft.milk.common.Init; -import growthcraft.milk.common.handlers.EntityDropsHandler; +import growthcraft.milk.common.handlers.EntityDropsEventHandler; import growthcraft.milk.shared.GrowthcraftMilkUserApis; import growthcraft.milk.shared.Reference; import net.minecraft.block.Block; @@ -41,6 +42,7 @@ public class GrowthcraftMilk { @SidedProxy(serverSide = SERVER_PROXY_CLASS, clientSide = CLIENT_PROXY_CLASS) public static CommonProxy proxy; + public static final GrowthcraftMilkConfig config = new GrowthcraftMilkConfig(); public static Logger logger = LogManager.getLogger(Reference.MODID); public static final GrowthcraftMilkUserApis userApis = new GrowthcraftMilkUserApis(); @@ -55,7 +57,10 @@ public class GrowthcraftMilk { @Mod.EventHandler public static void preInit(FMLPreInitializationEvent event) { + config.preInit(event, "growthcraft/growthcraft-milk.cfg"); + MinecraftForge.EVENT_BUS.register(new HarvestDropsEventHandler()); + MinecraftForge.EVENT_BUS.register(new EntityDropsEventHandler()); userApis.setConfigDirectory(event.getModConfigurationDirectory()); @@ -83,7 +88,6 @@ public static void init(FMLInitializationEvent event) { @Mod.EventHandler public static void postInit(FMLPostInitializationEvent event) { - MinecraftForge.EVENT_BUS.register(new EntityDropsHandler()); userApis.postInit(); Init.registerItemOres(); diff --git a/src/main/java/growthcraft/milk/common/Init.java b/src/main/java/growthcraft/milk/common/Init.java index eade53eb..08bfa77f 100644 --- a/src/main/java/growthcraft/milk/common/Init.java +++ b/src/main/java/growthcraft/milk/common/Init.java @@ -397,8 +397,8 @@ private static void preInitCheeseFluids() { public static int roundToBottles(int fluidAmount) { - int numBottles = fluidAmount / GrowthcraftCoreConfig.bottleCapacity; - return numBottles * GrowthcraftCoreConfig.bottleCapacity; + int numBottles = fluidAmount / GrowthcraftCoreConfig.BOTTLE_CAPACITY; + return numBottles * GrowthcraftCoreConfig.BOTTLE_CAPACITY; } public static void registerFluidOres() { @@ -429,7 +429,7 @@ public static void registerFluidOres() { public static void preInitFluids() { final IEffect milkEffect = EffectMilk.create(GrowthcraftCellarPotions.potionTipsy); - if (GrowthcraftMilkConfig.milkEnabled) { + if (GrowthcraftMilkConfig.MILK_ENABLED) { FluidMilk fluidMilk = (FluidMilk) new FluidMilk("fluid_milk"); ItemFoodBottleFluid foodBottleMilk = (ItemFoodBottleFluid) new ItemFoodBottleFluid(fluidMilk, 4, 0.3f, false); foodBottleMilk.setEffect(milkEffect).setAlwaysEdible(); @@ -446,7 +446,7 @@ public static void preInitFluids() { { final EffectList list = new EffectList(); list.add(milkEffect); - if (GrowthcraftMilkConfig.fantasyMilkEffects) { + if (GrowthcraftMilkConfig.FANTASY_MILK_EFFECTS) { // Idea from here: http://www.altmedicine101.com/buttermilk list.add(new EffectExtinguish()); list.add(EffectUtils.createAddPotionEffect(MobEffects.FIRE_RESISTANCE, TickUtils.seconds(15), 0)); @@ -478,7 +478,7 @@ public static void preInitFluids() { { final EffectList list = new EffectList(); list.add(milkEffect); - if (GrowthcraftMilkConfig.fantasyMilkEffects) { + if (GrowthcraftMilkConfig.FANTASY_MILK_EFFECTS) { list.add(EffectUtils.createAddPotionEffect(MobEffects.SPEED, TickUtils.seconds(15), 0)); } foodBottleSkimMilk.setEffect(list).setAlwaysEdible(); @@ -492,7 +492,7 @@ public static void preInitFluids() { ItemFoodBottleFluid foodBottleWhey = new ItemFoodBottleFluid(fluidWhey, 1, 0.1f, false); { final EffectList list = new EffectList(); - if (GrowthcraftMilkConfig.fantasyMilkEffects) { + if (GrowthcraftMilkConfig.FANTASY_MILK_EFFECTS) { list.add(EffectUtils.createAddPotionEffect(MobEffects.STRENGTH, TickUtils.seconds(10), 0)); list.add(EffectUtils.createAddPotionEffect(MobEffects.RESISTANCE, TickUtils.seconds(10), 0)); } @@ -515,38 +515,38 @@ public static void preInitFluids() { // Set the fluid color and density for each of the fluid sub-types kumisBooze[KumisTypes.KUMIS_FERMENTED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisFermentedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_FERMENTED_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_POTENT.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisPotentColor) + .setColor(GrowthcraftMilkConfig.KUMIS_POTENT_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_EXTENDED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisExtendedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_EXTENDED_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_HYPEREXTENDED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisHyperExtendedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_HYPER_EXTENDED_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_POTENT_EXTENDED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisPotentExtendedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_POTENT_EXTENDED_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_POTENT_HYPEREXTENDED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisPotentHyperExtendedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_POTENT_HYPER_EXTENDED_COLOR) .setDensity(1120); kumisBooze[KumisTypes.KUMIS_POISONED.ordinal()] .getFluid() - .setColor(GrowthcraftMilkConfig.kumisPoisonedColor) + .setColor(GrowthcraftMilkConfig.KUMIS_POISONED_COLOR) .setDensity(1120); preInitCheeseFluids(); } public static void initFluids() { - int restCapRounded = roundToBottles(FluidContainerRegistry.BUCKET_VOLUME - 2 * GrowthcraftCoreConfig.bottleCapacity); + int restCapRounded = roundToBottles(FluidContainerRegistry.BUCKET_VOLUME - 2 * GrowthcraftCoreConfig.BOTTLE_CAPACITY); final List milks = Compat.getMilkFluids(); for (Fluid f : milks) { @@ -554,7 +554,7 @@ public static void initFluids() { MilkRegistry.instance().pancheon().addRecipe( new FluidStack(f, 1000), - GrowthcraftMilkFluids.cream.asFluidStack(2 * GrowthcraftCoreConfig.bottleCapacity), GrowthcraftMilkFluids.skimMilk.asFluidStack(restCapRounded), + GrowthcraftMilkFluids.cream.asFluidStack(2 * GrowthcraftCoreConfig.BOTTLE_CAPACITY), GrowthcraftMilkFluids.skimMilk.asFluidStack(restCapRounded), TickUtils.minutes(1)); } } diff --git a/src/main/java/growthcraft/milk/common/block/BlockCheesePress.java b/src/main/java/growthcraft/milk/common/block/BlockCheesePress.java index 2de9bc57..236acc86 100644 --- a/src/main/java/growthcraft/milk/common/block/BlockCheesePress.java +++ b/src/main/java/growthcraft/milk/common/block/BlockCheesePress.java @@ -88,7 +88,7 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, ItemStack held = playerIn.getHeldItem(hand); if (super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ)) return true; - if (GrowthcraftMilkConfig.cheesePressHandOperated && held.isEmpty()) { + if (GrowthcraftMilkConfig.CHEESE_PRESS_HAND_OPERATED && held.isEmpty()) { if (!playerIn.isSneaking()) { final TileEntityCheesePress cheesePress = getTileEntity(worldIn, pos); if (cheesePress != null) { @@ -119,7 +119,7 @@ private void updatePressState(World world, BlockPos pos) { public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { super.neighborChanged(state, worldIn, pos, blockIn, fromPos); if (!worldIn.isRemote) { - if (GrowthcraftMilkConfig.cheesePressRedstoneOperated) { + if (GrowthcraftMilkConfig.CHEESE_PRESS_REDSTONE_OPERATED) { this.updatePressState(worldIn, pos); } } diff --git a/src/main/java/growthcraft/milk/common/handlers/EntityDropsEventHandler.java b/src/main/java/growthcraft/milk/common/handlers/EntityDropsEventHandler.java new file mode 100644 index 00000000..37bb9395 --- /dev/null +++ b/src/main/java/growthcraft/milk/common/handlers/EntityDropsEventHandler.java @@ -0,0 +1,35 @@ +package growthcraft.milk.common.handlers; + +import growthcraft.milk.GrowthcraftMilk; +import growthcraft.milk.shared.init.GrowthcraftMilkItems; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Random; + +public class EntityDropsEventHandler { + Random random = new Random(); + + @SubscribeEvent + public void onEntityDrops(LivingDropsEvent event) { + if (event.getEntityLiving() instanceof EntityCow) { + EntityAgeable eventEntity = (EntityAgeable) event.getEntity(); + int randomDrop = random.nextInt(100); + + if (GrowthcraftMilk.config.getBabyCowsOnlyDropStomach() && eventEntity.getGrowingAge() > 0) { + return; + } + + if (randomDrop <= GrowthcraftMilk.config.getStomachDropChance()) { + ItemStack itemStackStomach = GrowthcraftMilkItems.stomach.asStack(); + EntityItem entityItem = new EntityItem(eventEntity.world, eventEntity.posX, eventEntity.posY, eventEntity.posZ, itemStackStomach); + event.getDrops().add(entityItem); + } + } + } + +} diff --git a/src/main/java/growthcraft/milk/common/handlers/EntityDropsHandler.java b/src/main/java/growthcraft/milk/common/handlers/EntityDropsHandler.java deleted file mode 100644 index 6fa845a8..00000000 --- a/src/main/java/growthcraft/milk/common/handlers/EntityDropsHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -package growthcraft.milk.common.handlers; - -import growthcraft.milk.shared.init.GrowthcraftMilkItems; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.passive.EntityCow; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class EntityDropsHandler { - - @SubscribeEvent - public void onEnityDrops(LivingDropsEvent event) { - if (event.getEntityLiving() instanceof EntityCow) { - Entity eventEntity = event.getEntity(); - ItemStack itemStackStomach = GrowthcraftMilkItems.stomach.asStack(); - EntityItem entityItem = new EntityItem(eventEntity.world, eventEntity.posX, eventEntity.posY, eventEntity.posZ, itemStackStomach); - event.getDrops().add(entityItem); - } - } -} diff --git a/src/main/java/growthcraft/milk/common/handlers/HarvestDropsEventHandler.java b/src/main/java/growthcraft/milk/common/handlers/HarvestDropsEventHandler.java index 7daaacc5..b9d451a7 100644 --- a/src/main/java/growthcraft/milk/common/handlers/HarvestDropsEventHandler.java +++ b/src/main/java/growthcraft/milk/common/handlers/HarvestDropsEventHandler.java @@ -1,5 +1,6 @@ package growthcraft.milk.common.handlers; +import growthcraft.milk.GrowthcraftMilk; import growthcraft.milk.shared.init.GrowthcraftMilkItems; import net.minecraft.block.Block; import net.minecraft.block.BlockTallGrass; @@ -10,6 +11,7 @@ import java.util.Random; public class HarvestDropsEventHandler { + Random random = new Random(); @SubscribeEvent public void onHarvestDrops(HarvestDropsEvent event) { @@ -20,9 +22,7 @@ public void onHarvestDrops(HarvestDropsEvent event) { } private void doAdditionalDrop(HarvestDropsEvent event ) { - Random random = new Random(); - - if ( random.nextInt(100) <= 2 ) { + if ( random.nextInt(100) <= GrowthcraftMilk.config.getThistleDropChance()) { ItemStack thistleStack = new ItemStack(GrowthcraftMilkItems.thistleSeed.getItem()); event.getDrops().add(thistleStack); } diff --git a/src/main/java/growthcraft/milk/common/tileentity/TileEntityCheeseVat.java b/src/main/java/growthcraft/milk/common/tileentity/TileEntityCheeseVat.java index 3e337ad2..9c49d679 100644 --- a/src/main/java/growthcraft/milk/common/tileentity/TileEntityCheeseVat.java +++ b/src/main/java/growthcraft/milk/common/tileentity/TileEntityCheeseVat.java @@ -167,13 +167,13 @@ public void onInventoryChanged(IInventory inv, int index) { protected FluidTank[] createTanks() { return new FluidTank[]{ // milk - new FluidTank(GrowthcraftMilkConfig.cheeseVatPrimaryTankCapacity), + new FluidTank(GrowthcraftMilkConfig.CHEESE_VAT_PRIMARY_TANK_CAPACITY), // rennet - new FluidTank(GrowthcraftMilkConfig.cheeseVatRennetTankCapacity), + new FluidTank(GrowthcraftMilkConfig.CHEESE_VAT_RENNET_TANK_CAPACITY), // waste - new FluidTank(GrowthcraftMilkConfig.cheeseVatWasteTankCapacity), + new FluidTank(GrowthcraftMilkConfig.CHEESE_VAT_WASTE_TANK_CAPACITY), // recipe fluid - new FluidTank(GrowthcraftMilkConfig.cheeseVatRecipeTankCapacity) + new FluidTank(GrowthcraftMilkConfig.CHEESE_VAT_RECIPE_TANK_CAPACITY) }; } @@ -240,7 +240,7 @@ private boolean activateCurdTransition(boolean checkOnly) { decrStackSize(slot, 1); primaryFluidSlot.set(GrowthcraftFluidUtils.exchangeFluid(milkStack, GrowthcraftMilkFluids.curds.getFluid())); rennetFluidSlot.clear(); - wasteFluidSlot.fill(GrowthcraftMilkFluids.whey.asFluidStack(GrowthcraftMilkConfig.cheeseVatMilkToCurdsWheyAmount), true); + wasteFluidSlot.fill(GrowthcraftMilkFluids.whey.asFluidStack(GrowthcraftMilkConfig.CHEESE_VAT_MILK_TO_CURDS_WHEY_AMOUNT), true); GrowthcraftMilk.MILK_BUS.post(new EventCheeseVatMadeCurds(this)); } return true; @@ -252,7 +252,7 @@ private boolean activateWheyTransition(boolean checkOnly) { if (!checkOnly) { final Fluid fluid = SimpleCheeseTypes.RICOTTA.getFluids().getFluid(); // GrowthcraftMilkFluids.cheeses.get(EnumCheeseType.RICOTTA).getFluid(); primaryFluidSlot.set(GrowthcraftFluidUtils.exchangeFluid(primaryFluidSlot.get(), fluid)); - wasteFluidSlot.fill(GrowthcraftMilkFluids.whey.asFluidStack(GrowthcraftMilkConfig.cheeseVatWheyToRicottaWheyAmount), true); + wasteFluidSlot.fill(GrowthcraftMilkFluids.whey.asFluidStack(GrowthcraftMilkConfig.CHEESE_VAT_WHEY_TO_RICOTTA_WHEY_AMOUNT), true); GrowthcraftMilk.MILK_BUS.post(new EventCheeseVatMadeCheeseFluid(this)); } return true; @@ -326,7 +326,7 @@ private void commitRecipe() { final FluidStack stack = primaryFluidSlot.get(); if (FluidTest.hasTags(stack, MilkFluidTags.MILK_CURDS)) { if (commitMilkCurdRecipe(true)) { - setupProgress(GrowthcraftMilkConfig.cheeseVatCheeseTime); + setupProgress(GrowthcraftMilkConfig.CHEESE_VAT_CHEESE_TIME); setVatState(CheeseVatState.PREPARING_CHEESE); } } @@ -438,7 +438,7 @@ private boolean doSwordActivation(EntityPlayer _player, ItemStack _stack) { if (FluidTest.hasTags(milkStack, MilkFluidTags.MILK)) { GrowthcraftMilk.logger.debug("Activating Curd Transition."); if (activateCurdTransition(true)) { - setupProgress(GrowthcraftMilkConfig.cheeseVatCurdTime); + setupProgress(GrowthcraftMilkConfig.CHEESE_VAT_CURD_TIME); setVatState(CheeseVatState.PREPARING_CURDS); playSuccessfulSwordActivationFX(); return true; @@ -446,7 +446,7 @@ private boolean doSwordActivation(EntityPlayer _player, ItemStack _stack) { } else if (FluidTest.hasTags(milkStack, MilkFluidTags.WHEY)) { GrowthcraftMilk.logger.debug("Activating Whey Transition."); if (activateWheyTransition(true)) { - setupProgress(GrowthcraftMilkConfig.cheeseVatWheyTime); + setupProgress(GrowthcraftMilkConfig.CHEESE_VAT_WHEY_TIME); setVatState(CheeseVatState.PREPARING_RICOTTA); playSuccessfulSwordActivationFX(); return true; diff --git a/src/main/java/growthcraft/milk/common/tileentity/struct/Cheese.java b/src/main/java/growthcraft/milk/common/tileentity/struct/Cheese.java index 3f7db341..a61779b5 100644 --- a/src/main/java/growthcraft/milk/common/tileentity/struct/Cheese.java +++ b/src/main/java/growthcraft/milk/common/tileentity/struct/Cheese.java @@ -2,17 +2,14 @@ import growthcraft.core.shared.io.stream.IStreamable; import growthcraft.milk.GrowthcraftMilk; -import growthcraft.milk.common.item.ItemBlockCheeseBlock; import growthcraft.milk.shared.MilkRegistry; import growthcraft.milk.shared.cheese.CheeseIO; import growthcraft.milk.shared.cheese.CheeseUtils; import growthcraft.milk.shared.config.GrowthcraftMilkConfig; import growthcraft.milk.shared.definition.EnumCheeseStage; -import growthcraft.milk.shared.definition.ICheeseBlockStackFactory; import growthcraft.milk.shared.definition.ICheeseType; import growthcraft.milk.shared.init.GrowthcraftMilkItems.WaxedCheeseTypes; import io.netty.buffer.ByteBuf; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.MathHelper; @@ -20,12 +17,12 @@ public class Cheese implements IStreamable { public boolean needClientUpdate = true; - private int ageMax = GrowthcraftMilkConfig.cheeseMaxAge; + private int ageMax = GrowthcraftMilkConfig.CHEESE_MAX_AGE; private int age; private int topSlicesMax = 4; // GrowthcraftMilkConfig.cheeseMaxSlices; private int topSlices = 4; // GrowthcraftMilkConfig.cheeseMaxSlices; private boolean isDoubleStacked = false; - private final int cheesePerSlice = GrowthcraftMilkConfig.cheeseItemPerBlockSlice; + private static final int CHEESE_PER_SLICE = GrowthcraftMilkConfig.CHEESE_ITEM_PER_BLOCK_SLICE; private ICheeseType cheese = WaxedCheeseTypes.CHEDDAR; private EnumCheeseStage cheeseStage = EnumCheeseStage.UNWAXED; // EnumCheeseType.CHEDDAR.stages.get(0); @@ -102,7 +99,7 @@ public boolean isUnwaxed() { public ItemStack yankSlices(int count, boolean doYank) { final int yankedCount = MathHelper.clamp(count, 0, getSlices()); - final int quantity = yankedCount * cheesePerSlice; + final int quantity = yankedCount * CHEESE_PER_SLICE; if (quantity > 0) { if (doYank) { if (this.topSlices <= yankedCount) { @@ -224,31 +221,30 @@ public void readFromNBT(NBTTagCompound nbt) { @Override public boolean readFromStream(ByteBuf stream) { - ICheeseType newCheese = CheeseIO.loadFromStream(stream); // Is not null! - EnumCheeseStage newCheeseStage = EnumCheeseStage.loadFromStream(stream); // Is not null! - int newAge = stream.readInt(); - int newTopSlices = stream.readInt(); - int newTopSlicesMax = stream.readInt(); - boolean newIsDoubleStacked = stream.readBoolean(); - - if (!this.cheese.equals(newCheese) || - !this.cheeseStage.equals(newCheeseStage) || - this.age != newAge || - this.topSlices != newTopSlices || - this.topSlicesMax != newTopSlicesMax || - this.isDoubleStacked != newIsDoubleStacked ) { - - this.cheese = newCheese; - this.cheeseStage = newCheeseStage; - this.age = newAge; - this.topSlices = newTopSlices; - this.topSlicesMax = newTopSlicesMax; - this.isDoubleStacked = newIsDoubleStacked; - - return true; - } - else - return false; + ICheeseType newCheese = CheeseIO.loadFromStream(stream); // Is not null! + EnumCheeseStage newCheeseStage = EnumCheeseStage.loadFromStream(stream); // Is not null! + int newAge = stream.readInt(); + int newTopSlices = stream.readInt(); + int newTopSlicesMax = stream.readInt(); + boolean newIsDoubleStacked = stream.readBoolean(); + + if (!this.cheese.equals(newCheese) || + !this.cheeseStage.equals(newCheeseStage) || + this.age != newAge || + this.topSlices != newTopSlices || + this.topSlicesMax != newTopSlicesMax || + this.isDoubleStacked != newIsDoubleStacked) { + + this.cheese = newCheese; + this.cheeseStage = newCheeseStage; + this.age = newAge; + this.topSlices = newTopSlices; + this.topSlicesMax = newTopSlicesMax; + this.isDoubleStacked = newIsDoubleStacked; + + return true; + } else + return false; } @Override @@ -263,15 +259,13 @@ public boolean writeToStream(ByteBuf stream) { } public boolean update() { - if (!isAged()) { - if (canAge()) { - if (this.age < this.ageMax) { - this.age += 1; - } else { - setStage(EnumCheeseStage.AGED); - } - return true; + if (!isAged() && canAge()) { + if (this.age < this.ageMax) { + this.age += 1; + } else { + setStage(EnumCheeseStage.AGED); } + return true; } return false; } diff --git a/src/main/java/growthcraft/milk/shared/config/GrowthcraftMilkConfig.java b/src/main/java/growthcraft/milk/shared/config/GrowthcraftMilkConfig.java index 2b2a488e..4b6897ca 100644 --- a/src/main/java/growthcraft/milk/shared/config/GrowthcraftMilkConfig.java +++ b/src/main/java/growthcraft/milk/shared/config/GrowthcraftMilkConfig.java @@ -1,34 +1,84 @@ package growthcraft.milk.shared.config; +import growthcraft.core.shared.config.GrowthcraftConfiguration; import growthcraft.core.shared.legacy.FluidContainerRegistry; +import net.minecraftforge.common.config.Configuration; -public class GrowthcraftMilkConfig { - private GrowthcraftMilkConfig() { - } +public class GrowthcraftMilkConfig extends GrowthcraftConfiguration { - public static boolean milkEnabled = true; - public static boolean fantasyMilkEffects = true; - public static int cheeseMaxAge = 1200; - public static int cheeseItemPerBlockSlice = 4; - public static int cheeseVatPrimaryTankCapacity = 5000; - public static int cheeseVatRennetTankCapacity = FluidContainerRegistry.BOTTLE_VOLUME; - public static int cheeseVatWasteTankCapacity = 1000; - public static int cheeseVatRecipeTankCapacity = 1000; - public static int cheeseVatMilkToCurdsWheyAmount = 1000; - public static int cheeseVatWheyToRicottaWheyAmount = 1000; - public static int cheeseVatCheeseTime = 2400; - public static int cheeseVatCurdTime = 2400; - public static int cheeseVatWheyTime = 2400; - public static boolean cheesePressHandOperated = true; - public static boolean cheesePressRedstoneOperated = true; + public static final boolean MILK_ENABLED = true; + public static final boolean FANTASY_MILK_EFFECTS = true; + public static final int CHEESE_MAX_AGE = 1200; + public static final int CHEESE_ITEM_PER_BLOCK_SLICE = 4; + public static final int CHEESE_VAT_PRIMARY_TANK_CAPACITY = 5000; + public static final int CHEESE_VAT_RENNET_TANK_CAPACITY = FluidContainerRegistry.BOTTLE_VOLUME; + public static final int CHEESE_VAT_WASTE_TANK_CAPACITY = 1000; + public static final int CHEESE_VAT_RECIPE_TANK_CAPACITY = 1000; + public static final int CHEESE_VAT_MILK_TO_CURDS_WHEY_AMOUNT = 1000; + public static final int CHEESE_VAT_WHEY_TO_RICOTTA_WHEY_AMOUNT = 1000; + public static final int CHEESE_VAT_CHEESE_TIME = 2400; + public static final int CHEESE_VAT_CURD_TIME = 2400; + public static final int CHEESE_VAT_WHEY_TIME = 2400; + public static final boolean CHEESE_PRESS_HAND_OPERATED = true; + public static final boolean CHEESE_PRESS_REDSTONE_OPERATED = true; /* Kumis Colors */ - public static int kumisFermentedColor = 0xF9F9F9; - public static int kumisPotentColor = 0xF9F9F9; - public static int kumisExtendedColor = 0xF9F9F9; - public static int kumisHyperExtendedColor = 0xF9F9F9; - public static int kumisPotentExtendedColor = 0xF9F9F9; - public static int kumisPotentHyperExtendedColor = 0xF9F9F9; - public static int kumisPoisonedColor = 0xF9F9F9; + public static final int KUMIS_FERMENTED_COLOR = 0xF9F9F9; + public static final int KUMIS_POTENT_COLOR = 0xF9F9F9; + public static final int KUMIS_EXTENDED_COLOR = 0xF9F9F9; + public static final int KUMIS_HYPER_EXTENDED_COLOR = 0xF9F9F9; + public static final int KUMIS_POTENT_EXTENDED_COLOR = 0xF9F9F9; + public static final int KUMIS_POTENT_HYPER_EXTENDED_COLOR = 0xF9F9F9; + public static final int KUMIS_POISONED_COLOR = 0xF9F9F9; + + private int thistleDropChance = 2; + + private int stomachDropChance = 50; + private boolean babyCowDropStomachOnly = true; + + public GrowthcraftMilkConfig() { + super(); + } + + @Override + protected void initGeneralConfig() { + super.initGeneralConfig(); + + thistleDropChance = getConfiguration().getInt( + "thistleDropChance", + Configuration.CATEGORY_GENERAL, + thistleDropChance, + 0, 100, + "Percentage that thistle will drop when harvesting tall grass." + ); + + stomachDropChance = getConfiguration().getInt( + "enableDropStomach", + Configuration.CATEGORY_GENERAL, + stomachDropChance, + -1, 100, + "Percentage that cow stomach will drop when a cow is killed. Set to -1 to disable. " + ); + + babyCowDropStomachOnly = getConfiguration().getBoolean( + "babyCowDropStomachOnly", + Configuration.CATEGORY_GENERAL, + babyCowDropStomachOnly, + "Set to true to only drop stomach from baby cows." + ); + + } + + public int getThistleDropChance() { + return thistleDropChance; + } + + public int getStomachDropChance() { + return stomachDropChance; + } + + public boolean getBabyCowsOnlyDropStomach() { + return babyCowDropStomachOnly; + } } diff --git a/src/main/java/growthcraft/rice/common/Init.java b/src/main/java/growthcraft/rice/common/Init.java index ae0e0b1e..7613dd85 100644 --- a/src/main/java/growthcraft/rice/common/Init.java +++ b/src/main/java/growthcraft/rice/common/Init.java @@ -10,8 +10,8 @@ import growthcraft.cellar.shared.item.ItemBoozeBottle; import growthcraft.cellar.shared.processing.common.Residue; import growthcraft.cellar.shared.utils.BoozeHelper; +import growthcraft.core.GrowthcraftCore; import growthcraft.core.shared.client.render.utils.ItemRenderUtils; -import growthcraft.core.shared.config.GrowthcraftCoreConfig; import growthcraft.core.shared.definition.BlockDefinition; import growthcraft.core.shared.definition.ItemDefinition; import growthcraft.core.shared.definition.ItemTypeDefinition; @@ -338,8 +338,7 @@ private static void registerFermentations() { .brewsFromFallback(spoilInputFs[SakeTypes.SAKE_POISONED.ordinal()], GrowthcraftRiceConfig.brewTime, null) .getEffect() .setTipsy(BoozeUtils.alcoholToTipsy(0.10f), TickUtils.seconds(90)) - .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCoreConfig.hidePoisonedBooze); - + .createPotionEntry(MobEffects.POISON, TickUtils.seconds(90), 0).toggleDescription(!GrowthcraftCore.config.getHidePoisonedBooze()); }