From d6f5063c425464e86018a7fb9f6121d17fe30311 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Thu, 2 Apr 2015 14:46:57 +0200 Subject: [PATCH] begin work on ingame config --- .../buildcraft/blueprints/Coal Plant.bpt | Bin 4438 -> 0 bytes .../buildcraft/blueprints/Robot Pillar.bpt | Bin 1347 -> 0 bytes .../assets/buildcraft/lang/en_US.lang | 40 ++++++ buildcraft_resources/changelog/7.0.1 | 17 +++ buildcraft_resources/mcmod.info | 17 +++ common/buildcraft/BuildCraftBuilders.java | 90 ++++++------ common/buildcraft/BuildCraftCore.java | 117 ++++++++------- common/buildcraft/BuildCraftEnergy.java | 65 +++++++-- common/buildcraft/BuildCraftFactory.java | 136 +++++++++--------- common/buildcraft/BuildCraftRobotics.java | 4 - common/buildcraft/BuildCraftSilicon.java | 9 +- common/buildcraft/BuildCraftTransport.java | 72 ++++++---- .../core/blueprints/SchematicRegistry.java | 8 +- .../core/config/BCConfigElement.java | 59 ++++++++ .../{ => config}/BuildCraftConfiguration.java | 4 +- .../buildcraft/core/config/ConfigManager.java | 110 ++++++++++++++ .../buildcraft/core/lib/utils/BlockMiner.java | 2 +- .../buildcraft/core/lib/utils/BlockUtils.java | 2 +- common/buildcraft/core/proxy/CoreProxy.java | 8 -- .../core/recipes/AssemblyRecipeManager.java | 4 - .../core/recipes/RefineryRecipeManager.java | 9 -- common/buildcraft/factory/TileQuarry.java | 2 +- .../transport/PipeTransportItems.java | 2 +- .../buildcraft/transport/TravelingItem.java | 2 +- 24 files changed, 534 insertions(+), 245 deletions(-) delete mode 100755 buildcraft_resources/assets/buildcraft/blueprints/Coal Plant.bpt delete mode 100755 buildcraft_resources/assets/buildcraft/blueprints/Robot Pillar.bpt create mode 100644 buildcraft_resources/changelog/7.0.1 create mode 100644 common/buildcraft/core/config/BCConfigElement.java rename common/buildcraft/core/{ => config}/BuildCraftConfiguration.java (87%) create mode 100644 common/buildcraft/core/config/ConfigManager.java diff --git a/buildcraft_resources/assets/buildcraft/blueprints/Coal Plant.bpt b/buildcraft_resources/assets/buildcraft/blueprints/Coal Plant.bpt deleted file mode 100755 index f782a51ae2b41c2f23571722d05379f7f66c2fff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4438 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 diff --git a/buildcraft_resources/assets/buildcraft/blueprints/Robot Pillar.bpt b/buildcraft_resources/assets/buildcraft/blueprints/Robot Pillar.bpt deleted file mode 100755 index a1a0dcb0d5e49f479d4cc23f822bff00c13127a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1347 zcmV-J1-$wniwFP!000000PR~#bK5o$Ug}AyPSQiKX_Ag-`Z%z*9ADf^9LsUl)^^73 zG_TQgAQELcrbw0q9Xr$i()QB!U%CrYk|~LzMDbx)CJ&N80E@+9@$E+})dVO*)zLoC zw*XKVpk|wlFe(i0zTtNpAj+n}sKJ~jfba^IxEfHhf5YA&l%S+3041okNuQ_`Z$Wj> zbPXn;F7=*n%4Z#g_bEfeD;-isfcIE>(2753DRfZ3t{hg^gfb&4>eVN#jCXZY)nrc< z-la0TO9N^Sx1-}tS%j)L5%{>T8C15(FKoxsiE-u#@Da0#;aJ2*^Wu!fK2BC4-h{aY zD(upt{%rg~h53d<9Yn9RXR$JTVpGLora?P~<+4*vq3@n{ec>Th8(x(F&G(v3Pbqu1 z)y0N2OS7miJ5bf?hRfKTExt7=exoadHr$$Qh(blr04;+uX=F#qv1O^}YP#YVeQTOF zlMbjsZB2fOnm1w1(p^<0J)KWpg!`l7o=zMGz7CbpVYL5($V8#*{@2T4uauS-#uVG? zqQBA$uVPxo%}^Cpu7s!P0sdO&A0s8F+_njI-T(&@V9m2Dp95d=vGV3b*<0p@f@PU$ zrooq1fcwKGJ9Zha87kZ$UNsl@=vvnu?l}?{CYfGK2|G5RNiQs%1GaYt^KCL)Q&np7 z{*MFwhvP^Z_YH{;a!$we+v1)vm}7bOs4b$E@xHAQ9qR4Q?&0xK8)tBD%*lKY6+T>D zUHuvAfZGEn7B2DY1%6*()4wM%iEq4fYCFDN7D1>HCW$FvQe_I0suAMyu8Rp(W1C?+ zlg$vYR{@NZz_<|tjNi-z#uKw=GQI)P_1A-ik;zARvz-)gs&nw>VGu94Dw1k4^Jm9b zXdc>p9*R~z+~BDAD=z5lAMT&*{?LZGaVMd9$AU+e(l^tVz9bxvDb-3}DG%(wUjpn? zptqGMx>_peY6_?vj;QfaIlN((bTubd_%ta>SLUGflPFfG+LX>k>U??OA4!1drk*G! z2Z5)%kQZP$xvxO<`4_uAGn~rhpGZw)n6xYZI2nhjgB07I%&5a5S}yD;kb+ zcqA#O`bZMt+-W?LT{qv~Ks=gD>TfQv%mkgkvH+dsiFA3Kkr#pO zjs&)YMSTnk2f33D@@?TDg@Z&nNT+a+!a<@Osh-r&af?I5%u_o# zW;Qa;1m>0&PnM?oG9pdoot~zZsLC_hljw{!&16q;P+A20iC`b!HKyZy{DaaW&gU8D zSK+*LW#as*yulE49y$@!a-ue^q|~OADYf}3g4*~e@d>z1Tr>|}5h<{#z$*&_0ECAA|+sN0Mvsx4_r8&-qgC@tWU%94_?^mlME2j(QT`cMh{%nYp;_%^t3`=UpRF4?{)qZm)1lF3^l4 z(Wu#@nazAMJ!<$Qw4ojFODBb F000rnlo|j4 diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index c643d567..6f40f6f2 100644 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -56,6 +56,46 @@ color.red=Red color.white=White color.yellow=Yellow +config.general=General +config.general.pipes=Pipes +config.blueprints=Blueprints +config.power=Power Usage +config.display=Display +config.worldgen=World Generation +config.network=Networking +config.buildcraft=BuildCraft Configuration + +config.blueprints.clientDatabaseDirectory=Client directory +config.blueprints.excludedMods=Excluded mods +config.blueprints.excludedBlocks=Excluded blocks + +config.display.colorBlindMode=Colorblind mode +config.display.hideFluidValues=Hide fluid numbers +config.display.hidePowerValues=Hide power numbers + +config.general.pumpsConsumeWater=Pumps consume water +config.general.updateCheck=Check for updates +config.general.itemLifespan=Item lifespan (seconds) +config.general.canEnginesExplode=Engines explode +config.general.oilCanBurn=Burning oil +config.general.oilIsDense=Dense oil +config.general.quarry=Quarry Options +config.general.quarry.oneTimeUse=One-time use +config.general.quarry.doChunkLoading=Automatic chunk loading +config.general.miningDepth=Maximum relative mining depth +config.general.pumpDimensionControl=Pump dimension control + +config.network.longUpdateFactor=Client synchronization factor (ticks) +config.network.updateFactor=Packet sending factor (ticks) + +config.power.miningUsageMultiplier=Mining usage multiplier +config.power.chipsetCostMultiplier=Chipset cost multiplier + +config.worldgen.enable=Enable +config.worldgen.oilWellGenerationRate=Oil well generation rate +config.worldgen.spawnOilSprings=Spawn oil springs + + direction.north=North direction.west=West direction.east=East diff --git a/buildcraft_resources/changelog/7.0.1 b/buildcraft_resources/changelog/7.0.1 new file mode 100644 index 00000000..ee6232a1 --- /dev/null +++ b/buildcraft_resources/changelog/7.0.1 @@ -0,0 +1,17 @@ +Eveyrthing from BuildCraft 6.4.6, and: + +Additions: +* Modularization is actually released this time, after some bugfixes. +* Facade recipes are now available without Silicon (asie) +* Laser beams now need heat-up time to become blue (asie) +* Comparator suppport for BuildCraft tanks (asie) + +Improvements: +* [#2599] Stripes pipes don't move forward when using a non-item pipe (asie) +* [#2567] Emzuli Pipes support lists now (asie) +* Robot particle frequency is affected by Minecraft graphics settings (asie) + +Bugfixes: +* [#2603} Assembly Table crashes without Robotics (asie) +* [#2602] NPE when comparing two StatementSlots (asie) +* Fixes to Fancy pipe connection rendering (asie) diff --git a/buildcraft_resources/mcmod.info b/buildcraft_resources/mcmod.info index 0adac685..08a4b3af 100644 --- a/buildcraft_resources/mcmod.info +++ b/buildcraft_resources/mcmod.info @@ -100,5 +100,22 @@ "dependencies": [ "mod_MinecraftForge" ] +}, +{ + "modid": "BuildCraft|Robotics", + "name": "BC Robotics", + "version": "$version", + "mcversion": "$mcversion", + "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)", + "credits": "Created by SpaceToad", + "logoFile": "assets/buildcraft/logo.png", + "url": "http://www.mod-buildcraft.com/", + "updateUrl": "", + "authorList": [ "SpaceToad", "BuildCraft Team" ], + "parent": "BuildCraft|Core", + "screenshots": [], + "dependencies": [ + "mod_MinecraftForge" + ] } ] diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 888c1f12..af8baa39 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -25,6 +25,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import net.minecraft.stats.Achievement; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; @@ -39,7 +41,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; import buildcraft.api.blueprints.BlueprintDeployer; import buildcraft.api.blueprints.BuilderAPI; @@ -137,6 +138,7 @@ import buildcraft.core.builders.schematics.SchematicRotateMeta; import buildcraft.core.builders.schematics.SchematicStandalone; import buildcraft.core.builders.schematics.SchematicTileCreative; import buildcraft.core.builders.schematics.SchematicWallSide; +import buildcraft.core.config.ConfigManager; import buildcraft.core.proxy.CoreProxy; @Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE) @@ -168,53 +170,66 @@ public class BuildCraftBuilders extends BuildCraftMod { public static boolean debugPrintSchematicList = false; public static boolean dropBrokenBlocks = false; - private String blueprintServerDir; - private String blueprintLibraryOutput; - private String[] blueprintLibraryInput; + private String blueprintServerDir, blueprintClientDir; @Mod.EventHandler public void loadConfiguration(FMLPreInitializationEvent evt) { - blueprintServerDir = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, - "blueprints.serverDir", + BuildCraftCore.mainConfigManager.register("blueprints.serverDatabaseDirectory", "\"$MINECRAFT" + File.separator + "config" + File.separator + "buildcraft" + File.separator - + "blueprints" + File.separator + "server\"").getString(); + + "blueprints" + File.separator + "server\"", + "Location for the server blueprint database (used by all blueprint items).", ConfigManager.RestartRequirement.WORLD); + BuildCraftCore.mainConfigManager.register("blueprints.clientDatabaseDirectory", + "\"$MINECRAFT" + File.separator + "blueprints\"", + "Location for the client blueprint database (used by the Electronic Library).", ConfigManager.RestartRequirement.NONE); - blueprintLibraryOutput = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, - "blueprints.libraryOutput", "\"$MINECRAFT" + File.separator + "blueprints\"").getString(); + BuildCraftCore.mainConfigManager.register("general.markerRange", 64, "Set the maximum marker range.", ConfigManager.RestartRequirement.NONE); - blueprintLibraryInput = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, - "blueprints.libraryInput", new String [] - { - // expected location - "\"$MINECRAFT" + File.separator + "blueprints\"", - // legacy beta BuildCraft - "\"$MINECRAFT" + File.separator + "config" + File.separator + "buildcraft" + File.separator - + "blueprints" + File.separator + "client\"", - // inferred user download location - "\"" + getDownloadsDir() + "\"" - } - ).getStringList().clone(); + BuildCraftCore.mainConfigManager.get("blueprints.serverDatabaseDirectory").setShowInGui(false); + BuildCraftCore.mainConfigManager.get("general.markerRange").setMinValue(8).setMaxValue(64); - blueprintServerDir = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintServerDir)); - blueprintLibraryOutput = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintLibraryOutput)); + serverDB = new BlueprintServerDatabase(); + clientDB = new LibraryDatabase(); - for (int i = 0; i < blueprintLibraryInput.length; ++i) { - blueprintLibraryInput[i] = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintLibraryInput[i])); - } + reloadConfig(ConfigManager.RestartRequirement.GAME); + // TODO //Property dropBlock = BuildCraftCore.mainConfiguration.get("general", "builder.dropBrokenBlocks", false, "set to true to force the builder to drop broken blocks"); //dropBrokenBlocks = dropBlock.getBoolean(false); - Property markerRange = BuildCraftCore.mainConfiguration.get("general", "marker.range", 64, "Set the default marker range. Setting it too high might cause lag and general weirdness, so watch out!"); - markerRange.setMinValue(8); - markerRange.setMaxValue(64); - DefaultProps.MARKER_RANGE = markerRange.getInt(); - - Property printSchematicList = BuildCraftCore.mainConfiguration.get("debug", "blueprints.printSchematicList", false); + Property printSchematicList = BuildCraftCore.mainConfiguration.get("debug", "printBlueprintSchematicList", false); debugPrintSchematicList = printSchematicList.getBoolean(); + } - if (BuildCraftCore.mainConfiguration.hasChanged()) { - BuildCraftCore.mainConfiguration.save(); + public void reloadConfig(ConfigManager.RestartRequirement restartType) { + if (restartType == ConfigManager.RestartRequirement.GAME) { + + reloadConfig(ConfigManager.RestartRequirement.WORLD); + } else if (restartType == ConfigManager.RestartRequirement.WORLD) { + blueprintServerDir = BuildCraftCore.mainConfigManager.get("blueprints.serverDatabaseDirectory").getString(); + blueprintServerDir = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintServerDir)); + serverDB.init(new String[] {blueprintServerDir}, blueprintServerDir); + + reloadConfig(ConfigManager.RestartRequirement.NONE); + } else { + blueprintClientDir = BuildCraftCore.mainConfigManager.get("blueprints.clientDatabaseDirectory").getString(); + blueprintClientDir = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintClientDir)); + clientDB.init(new String[] { + blueprintClientDir, + getDownloadsDir() + }, blueprintClientDir); + + DefaultProps.MARKER_RANGE = BuildCraftCore.mainConfigManager.get("general.markerRange").getInt(); + + if (BuildCraftCore.mainConfiguration.hasChanged()) { + BuildCraftCore.mainConfiguration.save(); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.PostConfigChangedEvent event) { + if ("BuildCraft|Core".equals(event.modID)) { + reloadConfig(event.isWorldRunning ? ConfigManager.RestartRequirement.NONE : ConfigManager.RestartRequirement.WORLD); } } @@ -267,12 +282,6 @@ public class BuildCraftBuilders extends BuildCraftMod { public void postInit(FMLPostInitializationEvent evt) { HeuristicBlockDetection.start(); - serverDB = new BlueprintServerDatabase(); - clientDB = new LibraryDatabase(); - - serverDB.init(new String[] {blueprintServerDir}, blueprintServerDir); - clientDB.init(blueprintLibraryInput, blueprintLibraryOutput); - if (debugPrintSchematicList) { try { PrintWriter writer = new PrintWriter("SchematicDebug.txt", "UTF-8"); @@ -526,6 +535,7 @@ public class BuildCraftBuilders extends BuildCraftMod { } MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); // Create filler registry try { diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index bc98eafe..52f023d2 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -12,7 +12,6 @@ import java.io.File; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.util.HashSet; import java.util.UUID; import com.mojang.authlib.GameProfile; import org.lwjgl.input.Mouse; @@ -28,6 +27,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.util.IIcon; +import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -43,7 +43,6 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.oredict.OreDictionary; @@ -53,7 +52,6 @@ import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.EnumColor; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IWorldProperty; -import buildcraft.api.core.JavaTools; import buildcraft.api.recipes.BuildcraftRecipeRegistry; import buildcraft.api.statements.IActionExternal; import buildcraft.api.statements.IActionInternal; @@ -68,7 +66,7 @@ import buildcraft.core.BCCreativeTab; import buildcraft.core.BlockBuildTool; import buildcraft.core.BlockEngine; import buildcraft.core.BlockSpring; -import buildcraft.core.BuildCraftConfiguration; +import buildcraft.core.config.BuildCraftConfiguration; import buildcraft.core.CommandBuildCraft; import buildcraft.core.CompatHooks; import buildcraft.core.CoreGuiHandler; @@ -88,6 +86,7 @@ import buildcraft.core.TickHandlerCore; import buildcraft.core.TileEngineWood; import buildcraft.core.Version; import buildcraft.core.blueprints.SchematicRegistry; +import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.engines.ItemEngine; import buildcraft.core.lib.engines.TileEngineBase; import buildcraft.core.lib.network.ChannelHandler; @@ -123,7 +122,7 @@ import buildcraft.core.statements.TriggerInventoryLevel; import buildcraft.core.statements.TriggerMachine; import buildcraft.core.statements.TriggerRedstoneInput; -@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.10,1.8)", dependencies = "required-after:Forge@[10.13.2.1236,)") +@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.10,1.8)", dependencies = "required-after:Forge@[10.13.2.1236,)", guiFactory = "buildcraft.core.config.ConfigManager") public class BuildCraftCore extends BuildCraftMod { @Mod.Instance("BuildCraft|Core") public static BuildCraftCore instance; @@ -145,6 +144,7 @@ public class BuildCraftCore extends BuildCraftMod { public static int updateFactor = 10; public static long longUpdateFactor = 40; public static BuildCraftConfiguration mainConfiguration; + public static ConfigManager mainConfigManager; public static BlockEngine engineBlock; public static Block springBlock; @@ -210,8 +210,6 @@ public class BuildCraftCore extends BuildCraftMod { public static Achievement wrenchAchievement; public static Achievement engineRedstoneAchievement; - public static HashSet recipesBlacklist = new HashSet(); - public static float diffX, diffY, diffZ; public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("buildcraft.core".getBytes()), "[BuildCraft]"); @@ -235,40 +233,31 @@ public class BuildCraftCore extends BuildCraftMod { BuilderAPI.schematicRegistry = SchematicRegistry.INSTANCE; - mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf")); + mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.cfg")); + mainConfigManager = new ConfigManager(mainConfiguration); try { mainConfiguration.load(); - Property updateCheck = BuildCraftCore.mainConfiguration.get("general", "update.check", true); - updateCheck.comment = "set to true for version check on startup"; - if (updateCheck.getBoolean(true)) { - Version.check(); - } + mainConfigManager.getCat("debug").setShowInGui(false); + mainConfigManager.getCat("vars").setShowInGui(false); - Property hideRFNumbers = BuildCraftCore.mainConfiguration.get("general", "hidePowerNumbers", false); - hideRFNumbers.comment = "set to true to not display any RF or RF/t numbers."; - hidePowerNumbers = hideRFNumbers.getBoolean(false); - - Property hideMBNumbers = BuildCraftCore.mainConfiguration.get("general", "hideFluidNumbers", false); - hideMBNumbers.comment = "set to true to not display any mB or mB/t numbers."; - hideFluidNumbers = hideMBNumbers.getBoolean(false); + mainConfigManager.register("general.updateCheck", true, "Should I check the BuildCraft version on startup?", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("display.hidePowerValues", false, "Should all power values (RF, RF/t) be hidden?", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("display.hideFluidValues", false, "Should all fluid values (mB, mB/t) be hidden?", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("general.itemLifespan", 60, "How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)", ConfigManager.RestartRequirement.NONE) + .setMinValue(5); + mainConfigManager.register("network.updateFactor", 10, "How often, in ticks, should network update packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME) + .setMinValue(1); + mainConfigManager.register("network.longUpdateFactor", 40, "How often, in ticks, should full network sync packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME) + .setMinValue(1); + mainConfigManager.register("general.canEnginesExplode", false, "Should engines explode upon overheat?", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("worldgen.enable", true, "Should BuildCraft generate anything in the world?", ConfigManager.RestartRequirement.GAME); + mainConfigManager.register("general.pumpsConsumeWater", false, "Should pumps consume water? Enabling this might cause performance issues!", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("power.miningUsageMultiplier", 1.0D, "What should the multiplier of all mining-related power usage be?", ConfigManager.RestartRequirement.NONE); + mainConfigManager.register("display.colorBlindMode", false, "Should I enable colorblind mode?", ConfigManager.RestartRequirement.GAME); + mainConfigManager.register("worldgen.generateWaterSprings", true, "Should BuildCraft generate water springs?", ConfigManager.RestartRequirement.GAME); - Property lifespan = BuildCraftCore.mainConfiguration.get("general", "itemLifespan", itemLifespan); - lifespan.comment = "the lifespan in ticks of items dropped on the ground by pipes and machines, vanilla = 6000, default = 1200"; - itemLifespan = lifespan.getInt(itemLifespan); - if (itemLifespan < 100) { - itemLifespan = 100; - } - - Property factor = BuildCraftCore.mainConfiguration.get("general", "network.updateFactor", 10); - factor.comment = "increasing this number will decrease network update frequency, useful for overloaded servers"; - updateFactor = factor.getInt(10); - - Property longFactor = BuildCraftCore.mainConfiguration.get("general", "network.stateRefreshPeriod", 40); - longFactor.comment = "delay between full client sync packets, increasing it saves bandwidth, decreasing makes for better client syncronization."; - longUpdateFactor = longFactor.getInt(40); - - canEnginesExplode = BuildCraftCore.mainConfiguration.get("general", "enginesExplode", false, "Do engines explode upon overheat?").getBoolean(false); + reloadConfig(ConfigManager.RestartRequirement.GAME); wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem"); CoreProxy.proxy.registerItem(wrenchItem); @@ -282,22 +271,12 @@ public class BuildCraftCore extends BuildCraftMod { debuggerItem = (ItemDebugger) ((new ItemDebugger())).setUnlocalizedName("debugger"); CoreProxy.proxy.registerItem(debuggerItem); - Property modifyWorldProp = BuildCraftCore.mainConfiguration.get("general", "modifyWorld", true); - modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)"; - modifyWorld = modifyWorldProp.getBoolean(true); - if (BuildCraftCore.modifyWorld) { - BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfiguration.get("worldgen", "waterSpring", true).getBoolean(true); + BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfigManager.get("worldgen.generateWaterSprings").getBoolean(); springBlock = new BlockSpring().setBlockName("eternalSpring"); CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class); } - Property consumeWater = BuildCraftCore.mainConfiguration.get("general", "consumeWater", consumeWaterSources); - consumeWaterSources = consumeWater.getBoolean(consumeWaterSources); - consumeWater.comment = "set to true if the Pump should consume water"; - - miningMultiplier = BuildCraftCore.mainConfiguration.getFloat("general", "mining.cost.multipler", 1F, 1F, 10F, "cost multiplier for mining operations, range (1.0 - 10.0)\nhigh values may render engines incapable of powering machines directly"); - woodenGearItem = (new ItemGear()).setUnlocalizedName("woodenGearItem"); CoreProxy.proxy.registerItem(woodenGearItem); OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem)); @@ -330,12 +309,10 @@ public class BuildCraftCore extends BuildCraftMod { engineBlock.registerTile((Class) CompatHooks.INSTANCE.getTile(TileEngineWood.class), "tile.engineWood"); CoreProxy.proxy.registerTileEntity(TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood"); + FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler()); } finally { - if (mainConfiguration.hasChanged()) { - mainConfiguration.save(); - } } } @@ -372,11 +349,6 @@ public class BuildCraftCore extends BuildCraftMod { MinecraftForge.EVENT_BUS.register(new SpringPopulate()); } - for (String l : BuildCraftCore.mainConfiguration.get("general", - "recipesBlacklist", new String[0]).getStringList()) { - recipesBlacklist.add(JavaTools.stripSurroundingQuotes(l.trim())); - } - if (mainConfiguration.hasChanged()) { mainConfiguration.save(); } @@ -454,7 +426,42 @@ public class BuildCraftCore extends BuildCraftMod { BuildCraftCore.stripesLaserTexture = event.map.registerIcon("buildcraftcore:laserBox/blockStripesLaser"); BuildCraftCore.transparentTexture = event.map.registerIcon("buildcraftcore:misc/transparent"); } + } + public void reloadConfig(ConfigManager.RestartRequirement restartType) { + if (restartType == ConfigManager.RestartRequirement.GAME) { + modifyWorld = mainConfigManager.get("worldgen.enable").getBoolean(); + updateFactor = mainConfigManager.get("network.updateFactor").getInt(); + longUpdateFactor = mainConfigManager.get("network.longUpdateFactor").getInt(); + colorBlindMode = mainConfigManager.get("display.colorBlindMode").getBoolean(); + + reloadConfig(ConfigManager.RestartRequirement.WORLD); + } else if (restartType == ConfigManager.RestartRequirement.WORLD) { + + reloadConfig(ConfigManager.RestartRequirement.NONE); + } else { + hideFluidNumbers = mainConfigManager.get("display.hideFluidValues").getBoolean(); + hidePowerNumbers = mainConfigManager.get("display.hidePowerValues").getBoolean(); + itemLifespan = mainConfigManager.get("general.itemLifespan").getInt(); + canEnginesExplode = mainConfigManager.get("general.canEnginesExplode").getBoolean(); + consumeWaterSources = mainConfigManager.get("general.pumpsConsumeWater").getBoolean(); + miningMultiplier = (float) mainConfigManager.get("power.miningUsageMultiplier").getDouble(); + + if (mainConfigManager.get("general.updateCheck").getBoolean(true)) { + Version.check(); + } + + if (mainConfiguration.hasChanged()) { + mainConfiguration.save(); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + if ("BuildCraft|Core".equals(event.modID)) { + reloadConfig(event.isWorldRunning ? ConfigManager.RestartRequirement.NONE : ConfigManager.RestartRequirement.WORLD); + } } public void loadRecipes() { diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 05fd149a..1263c99a 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -19,6 +19,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.world.biome.BiomeGenBase; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; @@ -50,6 +52,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.lib.block.BlockBuildCraftFluid; +import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.engines.TileEngineBase; import buildcraft.core.lib.engines.TileEngineBase.EnergyStage; import buildcraft.core.lib.network.ChannelHandler; @@ -109,37 +112,36 @@ public class BuildCraftEnergy extends BuildCraftMod { private static Fluid buildcraftFluidFuel; private static Fluid buildcraftFluidRedPlasma; - @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { BuildcraftFuelRegistry.fuel = FuelManager.INSTANCE; BuildcraftFuelRegistry.coolant = CoolantManager.INSTANCE; - int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT); - int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); - canOilBurn = BuildCraftCore.mainConfiguration.get("general", "burnOil", true, "Can oil burn?").getBoolean(true); - isOilDense = BuildCraftCore.mainConfiguration.get("general", "denseOil", true, "Should it be hard to swim in oil?").getBoolean(true); - oilWellScalar = BuildCraftCore.mainConfiguration.get("general", "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); + int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT); + int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); + + BuildCraftCore.mainConfigManager.register("worldgen.spawnOilSprings", true, "Should I spawn oil springs?", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("worldgen.oilWellGenerationRate", 1.0D, "How high should be the probability of an oil well generating?", ConfigManager.RestartRequirement.NONE); setBiomeList( OilPopulate.INSTANCE.surfaceDepositBiomes, BuildCraftCore.mainConfiguration - .get("general", "oil.increasedBiomeIDs", + .get("worldgen.biomes", "increasedOilIDs", new String[] {BiomeDictionary.Type.SANDY.toString(), BiomeGenBase.taiga.biomeName}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that should have increased oil generation rates.")); setBiomeList( OilPopulate.INSTANCE.excessiveBiomes, BuildCraftCore.mainConfiguration - .get("general", - "oil.excessiveBiomeIDs", + .get("worldgen.biomes", + "excessiveOilIDs", new String[] {}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that should have GREATLY increased oil generation rates.")); setBiomeList(OilPopulate.INSTANCE.excludedBiomes, BuildCraftCore.mainConfiguration - .get("general", "oil.excludeBiomeIDs", - new String[] {BiomeGenBase.sky.biomeName, BiomeGenBase.hell.biomeName}, + .get("worldgen.biomes", "excludeOilIDs", + new String[]{BiomeGenBase.sky.biomeName, BiomeGenBase.hell.biomeName}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that are excluded from generating oil.")); double fuelLavaMultiplier = BuildCraftCore.mainConfiguration.get("general", "fuel.lava.combustion", 1.0F, "adjust energy value of Lava in Combustion Engines").getDouble(1.0F); @@ -156,7 +158,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (BiomeGenBase.getBiomeGenArray()[oilDesertBiomeId] != null) { oilDesertBiomeId = findUnusedBiomeID("oilDesert"); // save changes to config file - BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId); + BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId); BuildCraftCore.mainConfiguration.save(); } biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertBiomeId); @@ -166,7 +168,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (BiomeGenBase.getBiomeGenArray()[oilOceanBiomeId] != null) { oilOceanBiomeId = findUnusedBiomeID("oilOcean"); // save changes to config file - BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId); + BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId); BuildCraftCore.mainConfiguration.save(); } biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId); @@ -198,16 +200,21 @@ public class BuildCraftEnergy extends BuildCraftMod { fluidRedPlasma = FluidRegistry.getFluid("redplasma"); if (fluidOil.getBlock() == null) { - blockOil = new BlockBuildCraftFluid(fluidOil, Material.water, MapColor.blackColor).setFlammable(canOilBurn).setFlammability(0).setDense(isOilDense); + blockOil = new BlockBuildCraftFluid(fluidOil, Material.water, MapColor.blackColor).setFlammability(0); blockOil.setBlockName("blockOil").setLightOpacity(8); CoreProxy.proxy.registerBlock(blockOil); fluidOil.setBlock(blockOil); + + BuildCraftCore.mainConfigManager.register("general.oilCanBurn", true, "Should oil burn when lit on fire?", ConfigManager.RestartRequirement.NONE); + BuildCraftCore.mainConfigManager.register("general.oilIsDense", true, "Should oil be dense and drag entities down?", ConfigManager.RestartRequirement.NONE); } else { blockOil = fluidOil.getBlock(); } + reloadConfig(ConfigManager.RestartRequirement.GAME); + if (blockOil != null) { - spawnOilSprings = BuildCraftCore.mainConfiguration.get("worldgen", "oilSprings", true).getBoolean(true); + spawnOilSprings = BuildCraftCore.mainConfigManager.get("worldgen.spawnOilSprings").getBoolean(true); BlockSpring.EnumSpring.OIL.canGen = spawnOilSprings; BlockSpring.EnumSpring.OIL.liquidBlock = blockOil; } @@ -281,9 +288,37 @@ public class BuildCraftEnergy extends BuildCraftMod { InterModComms.registerHandler(new IMCHandlerEnergy()); + FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); } + public void reloadConfig(ConfigManager.RestartRequirement restartType) { + if (restartType == ConfigManager.RestartRequirement.GAME) { + reloadConfig(ConfigManager.RestartRequirement.WORLD); + } else if (restartType == ConfigManager.RestartRequirement.WORLD) { + reloadConfig(ConfigManager.RestartRequirement.NONE); + } else { + oilWellScalar = BuildCraftCore.mainConfigManager.get("worldgen.oilWellGenerationRate").getDouble(); + + if (blockOil instanceof BlockBuildCraftFluid) { + canOilBurn = BuildCraftCore.mainConfigManager.get("general.oilCanBurn").getBoolean(); + isOilDense = BuildCraftCore.mainConfigManager.get("general.oilIsDense").getBoolean(); + ((BlockBuildCraftFluid) blockOil).setFlammable(canOilBurn).setDense(isOilDense); + } + + if (BuildCraftCore.mainConfiguration.hasChanged()) { + BuildCraftCore.mainConfiguration.save(); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.PostConfigChangedEvent event) { + if ("BuildCraft|Core".equals(event.modID)) { + reloadConfig(event.isWorldRunning ? ConfigManager.RestartRequirement.NONE : ConfigManager.RestartRequirement.WORLD); + } + } + private void setBiomeList(Set list, Property configuration) { for (String id : configuration.getStringList()) { String strippedId = JavaTools.stripSurroundingQuotes(id.trim()); diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index eef0c85e..7e1a6d84 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -17,6 +17,8 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.world.World; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; @@ -30,7 +32,6 @@ import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.blueprints.SchematicTile; import buildcraft.core.CompatHooks; @@ -38,9 +39,9 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.builders.schematics.SchematicIgnoreMeta; +import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.network.ChannelHandler; import buildcraft.core.lib.network.PacketHandler; -import buildcraft.core.lib.utils.ConfigUtils; import buildcraft.core.proxy.CoreProxy; import buildcraft.factory.BlockAutoWorkbench; import buildcraft.factory.BlockFloodGate; @@ -92,18 +93,14 @@ public class BuildCraftFactory extends BuildCraftMod { public static Achievement refineAndRedefineAchievement; public static boolean quarryLoadsChunks = true; - public static boolean allowMining = true; public static boolean quarryOneTimeUse = false; - public static float miningMultiplier = 1; public static int miningDepth = 256; public static PumpDimensionList pumpDimensionList; @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { FactoryProxy.proxy.initializeNEIIntegration(); - if (quarryLoadsChunks) { - ForgeChunkManager.setForcedChunkLoadingCallback(instance, new QuarryChunkloadCallback()); - } + ForgeChunkManager.setForcedChunkLoadingCallback(instance, new QuarryChunkloadCallback()); } public class QuarryChunkloadCallback implements ForgeChunkManager.OrderedLoadingCallback { @@ -181,24 +178,17 @@ public class BuildCraftFactory extends BuildCraftMod { channels = NetworkRegistry.INSTANCE.newChannel (DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new ChannelHandler(), new PacketHandler()); - ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, "general"); - - allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines"); - quarryOneTimeUse = genCat.get("quarry.one.time.use", false, "Quarry cannot be picked back up after placement"); - miningDepth = genCat.get("mining.depth", 2, 256, 256, "how far below the machine can mining machines dig, range (2 - 256), default 256"); - quarryLoadsChunks = genCat.get("quarry.loads.chunks", true, "Quarry loads chunks required for mining"); - - Property pumpList = BuildCraftCore.mainConfiguration.get("general", "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST); - pumpList.comment = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n" + String plc = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n" + "Eg. \"-/-1/Lava\" will disable lava in the nether. \"-/*/Lava\" will disable lava in any dimension. \"+/0/*\" will enable any fluid in the overworld.\n" + "Entries are comma seperated, banned fluids have precedence over allowed ones." + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/lava\") is there to show the format."; - pumpDimensionList = new PumpDimensionList(pumpList.getString()); - if (BuildCraftCore.mainConfiguration.hasChanged()) { - BuildCraftCore.mainConfiguration.save(); - } + BuildCraftCore.mainConfigManager.register("general.quarry.oneTimeUse", false, "Should the quarry only be usable once after placing?", ConfigManager.RestartRequirement.NONE); + BuildCraftCore.mainConfigManager.register("general.miningDepth", 256, "Should the quarry only be usable once after placing?", ConfigManager.RestartRequirement.NONE); + BuildCraftCore.mainConfigManager.register("general.quarry.doChunkLoading", true, "Should the quarry only be usable once after placing?", ConfigManager.RestartRequirement.NONE); + BuildCraftCore.mainConfigManager.get("general.miningDepth").setMinValue(2).setMaxValue(256); + BuildCraftCore.mainConfigManager.register("general.pumpDimensionControl", DefaultProps.PUMP_DIMENSION_LIST, plc, ConfigManager.RestartRequirement.NONE); miningWellBlock = (BlockMiningWell) CompatHooks.INSTANCE.getBlock(BlockMiningWell.class); CoreProxy.proxy.registerBlock(miningWellBlock.setBlockName("miningWellBlock")); @@ -230,62 +220,48 @@ public class BuildCraftFactory extends BuildCraftMod { hopperBlock = (BlockHopper) CompatHooks.INSTANCE.getBlock(BlockHopper.class); CoreProxy.proxy.registerBlock(hopperBlock.setBlockName("blockHopper")); - FactoryProxy.proxy.initializeEntityRenders(); - if (BuildCraftCore.mainConfiguration.hasChanged()) { - BuildCraftCore.mainConfiguration.save(); - } + FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); } public static void loadRecipes() { - if (allowMining) { - if (miningWellBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(miningWellBlock, 1), - "ipi", - "igi", - "iPi", - 'p', "dustRedstone", - 'i', "ingotIron", - 'g', "gearIron", - 'P', Items.iron_pickaxe); - } - - if (quarryBlock != null) { - CoreProxy.proxy.addCraftingRecipe( - new ItemStack(quarryBlock), - "ipi", - "gig", - "dDd", - 'i', "gearIron", - 'p', "dustRedstone", - 'g', "gearGold", - 'd', "gearDiamond", - 'D', Items.diamond_pickaxe); - } - - if (pumpBlock != null && miningWellBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(pumpBlock), - "T", - "W", - 'T', tankBlock != null ? tankBlock : "blockGlass", - 'W', miningWellBlock); - } + if (miningWellBlock != null) { + CoreProxy.proxy.addCraftingRecipe(new ItemStack(miningWellBlock, 1), + "ipi", + "igi", + "iPi", + 'p', "dustRedstone", + 'i', "ingotIron", + 'g', "gearIron", + 'P', Items.iron_pickaxe); } - if (!allowMining || miningWellBlock == null) { - if (pumpBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(pumpBlock), - "iri", - "iTi", - "gpg", - 'r', "dustRedstone", - 'i', "ingotIron", - 'T', tankBlock != null ? tankBlock : "blockGlass", - 'g', "gearIron", - 'p', BuildCraftTransport.pipeFluidsGold); - } + if (quarryBlock != null) { + CoreProxy.proxy.addCraftingRecipe( + new ItemStack(quarryBlock), + "ipi", + "gig", + "dDd", + 'i', "gearIron", + 'p', "dustRedstone", + 'g', "gearGold", + 'd', "gearDiamond", + 'D', Items.diamond_pickaxe); + } + + if (pumpBlock != null) { + CoreProxy.proxy.addCraftingRecipe( + new ItemStack(pumpBlock), + "ipi", + "igi", + "TBT", + 'p', "dustRedstone", + 'i', "ingotIron", + 'T', tankBlock, + 'g', "gearIron", + 'B', Items.bucket); } if (autoWorkbenchBlock != null) { @@ -343,6 +319,30 @@ public class BuildCraftFactory extends BuildCraftMod { } } + public void reloadConfig(ConfigManager.RestartRequirement restartType) { + if (restartType == ConfigManager.RestartRequirement.GAME) { + reloadConfig(ConfigManager.RestartRequirement.WORLD); + } else if (restartType == ConfigManager.RestartRequirement.WORLD) { + reloadConfig(ConfigManager.RestartRequirement.NONE); + } else { + quarryOneTimeUse = BuildCraftCore.mainConfigManager.get("general.quarry.oneTimeUse").getBoolean(); + quarryLoadsChunks = BuildCraftCore.mainConfigManager.get("general.quarry.doChunkLoading").getBoolean(); + miningDepth = BuildCraftCore.mainConfigManager.get("general.miningDepth").getInt(); + pumpDimensionList = new PumpDimensionList(BuildCraftCore.mainConfigManager.get("general.pumpDimensionControl").getString()); + + if (BuildCraftCore.mainConfiguration.hasChanged()) { + BuildCraftCore.mainConfiguration.save(); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + if ("BuildCraft|Core".equals(event.modID)) { + reloadConfig(event.isWorldRunning ? ConfigManager.RestartRequirement.NONE : ConfigManager.RestartRequirement.WORLD); + } + } + @Mod.EventHandler public void processIMCRequests(FMLInterModComms.IMCEvent event) { InterModComms.processIMC(event); diff --git a/common/buildcraft/BuildCraftRobotics.java b/common/buildcraft/BuildCraftRobotics.java index ebaab463..1d7cd4ae 100644 --- a/common/buildcraft/BuildCraftRobotics.java +++ b/common/buildcraft/BuildCraftRobotics.java @@ -191,8 +191,6 @@ public class BuildCraftRobotics extends BuildCraftMod { public static Achievement timeForSomeLogicAchievement; public static Achievement tinglyLaserAchievement; - public static float chipsetCostMultiplier = 1.0F; - public static List blacklistedRobots; public static MapManager manager; @@ -202,8 +200,6 @@ public class BuildCraftRobotics extends BuildCraftMod { public void preInit(FMLPreInitializationEvent evt) { new BCCreativeTab("boards"); - chipsetCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("chipset.costMultiplier", "general", 1.0F, 0.001F, 1000.0F, "The multiplier for chipset recipe cost."); - blacklistedRobots = new ArrayList(); blacklistedRobots.addAll(Arrays.asList(BuildCraftCore.mainConfiguration.get("general", "boards.blacklist", new String[]{}).getStringList())); diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 463fda8e..4519d349 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -30,6 +30,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.builders.schematics.SchematicRotateMeta; +import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.items.ItemBuildCraft; import buildcraft.core.lib.network.ChannelHandler; import buildcraft.core.proxy.CoreProxy; @@ -66,9 +67,13 @@ public class BuildCraftSilicon extends BuildCraftMod { @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { - chipsetCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("chipset.costMultiplier", "general", 1.0F, 0.001F, 1000.0F, "The multiplier for chipset recipe cost."); - + BuildCraftCore.mainConfigManager.register("power.chipsetCostMultiplier", 1.0D, "The cost multiplier for Chipsets", ConfigManager.RestartRequirement.GAME); BuildCraftCore.mainConfiguration.save(); + chipsetCostMultiplier = (float) BuildCraftCore.mainConfigManager.get("power.chipsetCostMultiplier").getDouble(); + + if (BuildCraftCore.mainConfiguration.hasChanged()) { + BuildCraftCore.mainConfiguration.save(); + } laserBlock = (BlockLaser) CompatHooks.INSTANCE.getBlock(BlockLaser.class); laserBlock.setBlockName("laserBlock"); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 9e44a548..e0709286 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -21,6 +21,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; import net.minecraft.world.WorldServer; +import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; @@ -65,6 +66,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.PowerMode; import buildcraft.core.Version; +import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.items.ItemBuildCraft; import buildcraft.core.lib.network.ChannelHandler; import buildcraft.core.lib.utils.ColorUtils; @@ -243,7 +245,6 @@ public class BuildCraftTransport extends BuildCraftMod { public static Item pipePowerEmerald; public static Item pipePowerSandstone; - public static int groupItemsTrigger; public static String[] facadeBlacklist; public static ITriggerInternal triggerLightSensorBright, triggerLightSensorDark; @@ -292,30 +293,13 @@ public class BuildCraftTransport extends BuildCraftMod { } try { - Property durability = BuildCraftCore.mainConfiguration.get("general", "pipes.durability", DefaultProps.PIPES_DURABILITY); - durability.comment = "How long a pipe will take to break"; - pipeDurability = (float) durability.getDouble(DefaultProps.PIPES_DURABILITY); - - Property baseFlowRate = BuildCraftCore.mainConfiguration.get("general", "pipes.fluids.baseFlowRate", DefaultProps.PIPES_FLUIDS_BASE_FLOW_RATE); - pipeFluidsBaseFlowRate = baseFlowRate.getInt(); - - Property printFacadeList = BuildCraftCore.mainConfiguration.get("debug", "facades.printFacadeList", false); - debugPrintFacadeList = printFacadeList.getBoolean(); - - Property enableAdditionalWaterproofingRecipe = BuildCraftCore.mainConfiguration.get("general", "pipes.fluids.enableAdditionalWaterproofingRecipe", true); - enableAdditionalWaterproofingRecipe.comment = "Enable the slimeball based pipe waterproofing recipe"; - additionalWaterproofingRecipe = enableAdditionalWaterproofingRecipe.getBoolean(); - - gateCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("gate.recipeCostMultiplier", "general", 1.0F, 0.001F, 1000.0F, "The multiplier for gate recipe cost."); - - filteredBufferBlock = new BlockFilteredBuffer(); - CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock")); - - Property groupItemsTriggerProp = BuildCraftCore.mainConfiguration.get("general", "pipes.groupItemsTrigger", 32); - groupItemsTriggerProp.comment = "when reaching this amount of objects in a pipes, items will be automatically grouped"; - groupItemsTrigger = groupItemsTriggerProp.getInt(); - - Property facadeBlacklistProp = BuildCraftCore.mainConfiguration.get("general", "facade.blacklist", new String[] { + BuildCraftCore.mainConfigManager.register("general.pipes.hardness", DefaultProps.PIPES_DURABILITY, "How hard to break should a pipe be?", ConfigManager.RestartRequirement.NONE); + BuildCraftCore.mainConfigManager.register("general.pipes.baseFluidRate", DefaultProps.PIPES_FLUIDS_BASE_FLOW_RATE, "What should the base flow rate of a fluid pipe be?", ConfigManager.RestartRequirement.GAME) + .setMinValue(1).setMaxValue(40); + BuildCraftCore.mainConfigManager.register("debug.printFacadeList", false, "Print a list of all registered facades.", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("general.pipes.slimeballWaterproofRecipe", false, "Should I enable an alternate Waterproof recipe, based on slimeballs?", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("power.gateCostMultiplier", 1.0D, "What should be the multiplier of all gate power costs?", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("general.pipes.facadeBlacklist", new String[] { Block.blockRegistry.getNameForObject(Blocks.bedrock), Block.blockRegistry.getNameForObject(Blocks.command_block), Block.blockRegistry.getNameForObject(Blocks.end_portal_frame), @@ -340,13 +324,13 @@ public class BuildCraftTransport extends BuildCraftMod { JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)), JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)), JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)), - }); + }, "What block types should be blacklisted from being a facade?", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("general.pipes.facadeBlacklistAsWhitelist", false, "Should the blacklist be treated as a whitelist instead?", ConfigManager.RestartRequirement.GAME); - facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes."; - facadeBlacklist = facadeBlacklistProp.getStringList(); + reloadConfig(ConfigManager.RestartRequirement.GAME); - Property facadeAsWhitelist = BuildCraftCore.mainConfiguration.get("general", "facade.treatBlacklistAsWhitelist", false); - facadeTreatBlacklistAsWhitelist = facadeAsWhitelist.getBoolean(); + filteredBufferBlock = new BlockFilteredBuffer(); + CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock")); pipeWaterproof = new ItemBuildCraft(); @@ -571,6 +555,34 @@ public class BuildCraftTransport extends BuildCraftMod { } } + public void reloadConfig(ConfigManager.RestartRequirement restartType) { + if (restartType == ConfigManager.RestartRequirement.GAME) { + facadeTreatBlacklistAsWhitelist = BuildCraftCore.mainConfigManager.get("general.pipes.facadeBlacklistAsWhitelist").getBoolean(); + facadeBlacklist = BuildCraftCore.mainConfigManager.get("general.pipes.facadeBlacklist").getStringList(); + gateCostMultiplier = (float) BuildCraftCore.mainConfigManager.get("power.gateCostMultiplier").getDouble(); + additionalWaterproofingRecipe = BuildCraftCore.mainConfigManager.get("general.pipes.slimeballWaterproofRecipe").getBoolean(); + debugPrintFacadeList = BuildCraftCore.mainConfigManager.get("debug.printFacadeList").getBoolean(); + pipeFluidsBaseFlowRate = BuildCraftCore.mainConfigManager.get("general.pipes.baseFluidRate").getInt(); + + reloadConfig(ConfigManager.RestartRequirement.WORLD); + } else if (restartType == ConfigManager.RestartRequirement.WORLD) { + reloadConfig(ConfigManager.RestartRequirement.NONE); + } else { + pipeDurability = (float) BuildCraftCore.mainConfigManager.get("general.pipes.hardness").getDouble(); + + if (BuildCraftCore.mainConfiguration.hasChanged()) { + BuildCraftCore.mainConfiguration.save(); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + if ("BuildCraft|Core".equals(event.modID)) { + reloadConfig(event.isWorldRunning ? ConfigManager.RestartRequirement.NONE : ConfigManager.RestartRequirement.WORLD); + } + } + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Pre event) { diff --git a/common/buildcraft/core/blueprints/SchematicRegistry.java b/common/buildcraft/core/blueprints/SchematicRegistry.java index a4909819..1dd6572f 100644 --- a/common/buildcraft/core/blueprints/SchematicRegistry.java +++ b/common/buildcraft/core/blueprints/SchematicRegistry.java @@ -182,10 +182,10 @@ public final class SchematicRegistry implements ISchematicRegistry { } public void readConfiguration(Configuration conf) { - Property excludedMods = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedMods", new String[0], - "mods that should be excluded from the builder."); - Property excludedBlocks = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedBlocks", new String[0], - "blocks that should be excluded from the builder."); + Property excludedMods = conf.get("blueprints", "excludedMods", new String[0], + "mods that should be excluded from the builder.").setLanguageKey("config.blueprints.excludedMods").setRequiresMcRestart(true); + Property excludedBlocks = conf.get("blueprints", "excludedBlocks", new String[0], + "blocks that should be excluded from the builder.").setLanguageKey("config.blueprints.excludedBlocks").setRequiresMcRestart(true); for (String id : excludedMods.getStringList()) { String strippedId = JavaTools.stripSurroundingQuotes(id.trim()); diff --git a/common/buildcraft/core/config/BCConfigElement.java b/common/buildcraft/core/config/BCConfigElement.java new file mode 100644 index 00000000..0b6889b4 --- /dev/null +++ b/common/buildcraft/core/config/BCConfigElement.java @@ -0,0 +1,59 @@ +package buildcraft.core.config; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import cpw.mods.fml.client.config.IConfigElement; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Property; + +public class BCConfigElement extends ConfigElement { + private ConfigCategory cat; + private boolean isProp; + + public BCConfigElement(ConfigCategory ctgy) { + super(ctgy); + cat = ctgy; + isProp = false; + } + + public BCConfigElement(Property prop) { + super(prop); + isProp = true; + } + + @Override + public List getChildElements() + { + if (!isProp) { + List elements = new ArrayList(); + Iterator ccI = cat.getChildren().iterator(); + Iterator pI = cat.getOrderedValues().iterator(); + + while (ccI.hasNext()) { + ConfigCategory child = ccI.next(); + if (!child.parent.getQualifiedName().equals(cat.getQualifiedName())) { + continue; + } + + ConfigElement temp = new BCConfigElement(child); + if (temp.showInGui()) { + elements.add(temp); + } + } + + while (pI.hasNext()) + { + ConfigElement temp = getTypedElement(pI.next()); + if (temp.showInGui()) { + elements.add(temp); + } + } + + return elements; + } else { + return null; + } + } +} diff --git a/common/buildcraft/core/BuildCraftConfiguration.java b/common/buildcraft/core/config/BuildCraftConfiguration.java similarity index 87% rename from common/buildcraft/core/BuildCraftConfiguration.java rename to common/buildcraft/core/config/BuildCraftConfiguration.java index bab6722c..2f78903a 100644 --- a/common/buildcraft/core/BuildCraftConfiguration.java +++ b/common/buildcraft/core/config/BuildCraftConfiguration.java @@ -6,11 +6,12 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.core.config; import java.io.File; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import buildcraft.core.Version; public class BuildCraftConfiguration extends Configuration { @@ -21,6 +22,7 @@ public class BuildCraftConfiguration extends Configuration { @Override public void save() { Property versionProp = get(CATEGORY_GENERAL, "version", Version.VERSION); + versionProp.setShowInGui(false); versionProp.set(Version.VERSION); super.save(); } diff --git a/common/buildcraft/core/config/ConfigManager.java b/common/buildcraft/core/config/ConfigManager.java new file mode 100644 index 00000000..c38e2635 --- /dev/null +++ b/common/buildcraft/core/config/ConfigManager.java @@ -0,0 +1,110 @@ +package buildcraft.core.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import cpw.mods.fml.client.IModGuiFactory; +import cpw.mods.fml.client.config.GuiConfig; +import cpw.mods.fml.client.config.IConfigElement; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +public class ConfigManager implements IModGuiFactory { + public static Configuration config; + + public static class GuiConfigManager extends GuiConfig { + public GuiConfigManager(GuiScreen parentScreen) { + super(parentScreen, new ArrayList(), "BuildCraft|Core", "config", false, false, I18n.format("config.buildcraft")); + + for (String s : config.getCategoryNames()) { + configElements.add(new BCConfigElement(config.getCategory(s))); + } + } + } + + public enum RestartRequirement { + NONE, WORLD, GAME; + } + + public ConfigManager() { + + } + + public ConfigManager(Configuration c) { + this.config = c; + } + + public ConfigCategory getCat(String name) { + return config.getCategory(name); + } + + public Property get(String iName) { + String prefix = iName.substring(0, iName.lastIndexOf(".")); + ConfigCategory c = config.getCategory(prefix); + return c.get(iName.substring(iName.lastIndexOf(".") + 1)); + } + + private Property create(String s, Object o) { + Property p = null; + if (o instanceof Integer) { + p = new Property(s, o.toString(), Property.Type.INTEGER); + } else if (o instanceof String) { + p = new Property(s, (String) o, Property.Type.STRING); + } else if (o instanceof Double) { + p = new Property(s, o.toString(), Property.Type.DOUBLE); + } else if (o instanceof Boolean) { + p = new Property(s, o.toString(), Property.Type.BOOLEAN); + } else if (o instanceof String[]) { + p = new Property(s, (String[]) o, Property.Type.STRING); + } else { + return null; + } + return p; + } + + public Property register(String name, Object property, String comment, RestartRequirement restartRequirement) { + String prefix = name.substring(0, name.lastIndexOf(".")); + String suffix = name.substring(name.lastIndexOf(".") + 1); + + ConfigCategory c = config.getCategory(prefix); + ConfigCategory parent = c; + while (parent != null) { + parent.setLanguageKey("config." + parent.getQualifiedName()); + parent = parent.parent; + } + + Property p = create(suffix, property); + c.put(suffix, p); + p.comment = comment; + RestartRequirement r = restartRequirement; + p.setLanguageKey("config." + name); + p.setRequiresWorldRestart(r == RestartRequirement.WORLD); + p.setRequiresMcRestart(r == RestartRequirement.GAME); + return p; + } + + @Override + public void initialize(Minecraft minecraftInstance) { + + } + + @Override + public Class mainConfigGuiClass() { + return GuiConfigManager.class; + } + + @Override + public Set runtimeGuiCategories() { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } +} diff --git a/common/buildcraft/core/lib/utils/BlockMiner.java b/common/buildcraft/core/lib/utils/BlockMiner.java index 51f3c550..2ef459f8 100644 --- a/common/buildcraft/core/lib/utils/BlockMiner.java +++ b/common/buildcraft/core/lib/utils/BlockMiner.java @@ -55,7 +55,7 @@ public class BlockMiner { EntityItem entityitem = new EntityItem(owner.getWorldObj(), owner.xCoord + f, owner.yCoord + f1 + 0.5F, owner.zCoord + f2, stack); - entityitem.lifespan = BuildCraftCore.itemLifespan; + entityitem.lifespan = BuildCraftCore.itemLifespan * 20; entityitem.delayBeforeCanPickup = 10; float f3 = 0.05F; diff --git a/common/buildcraft/core/lib/utils/BlockUtils.java b/common/buildcraft/core/lib/utils/BlockUtils.java index 075667ff..1b920bfd 100644 --- a/common/buildcraft/core/lib/utils/BlockUtils.java +++ b/common/buildcraft/core/lib/utils/BlockUtils.java @@ -70,7 +70,7 @@ public final class BlockUtils { } public static boolean breakBlock(WorldServer world, int x, int y, int z) { - return breakBlock(world, x, y, z, BuildCraftCore.itemLifespan); + return breakBlock(world, x, y, z, BuildCraftCore.itemLifespan * 20); } public static boolean breakBlock(WorldServer world, int x, int y, int z, int forcedLifespan) { diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index b2980742..17e60263 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -103,20 +103,12 @@ public class CoreProxy implements ICoreProxy { public void addCraftingRecipe(ItemStack result, Object... recipe) { String name = Item.itemRegistry.getNameForObject(result.getItem()); - if (BuildCraftCore.recipesBlacklist.contains(name)) { - return; - } - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(result, recipe)); } public void addShapelessRecipe(ItemStack result, Object... recipe) { String name = Item.itemRegistry.getNameForObject(result.getItem()); - if (BuildCraftCore.recipesBlacklist.contains(name)) { - return; - } - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe)); } diff --git a/common/buildcraft/core/recipes/AssemblyRecipeManager.java b/common/buildcraft/core/recipes/AssemblyRecipeManager.java index 68b29508..ef9ce49c 100644 --- a/common/buildcraft/core/recipes/AssemblyRecipeManager.java +++ b/common/buildcraft/core/recipes/AssemblyRecipeManager.java @@ -26,10 +26,6 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { public void addRecipe(String id, int energyCost, ItemStack output, Object... input) { String name = Item.itemRegistry.getNameForObject(output.getItem()); - if (BuildCraftCore.recipesBlacklist.contains(name)) { - return; - } - addRecipe(id, new FlexibleRecipe(id, output, energyCost, 0, input)); } diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index 45d4a0f6..00decf08 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -32,11 +32,6 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { public void addRecipe(String id, FluidStack ingredient, FluidStack result, int energy, int delay) { String name = result.getFluid().getName(); - if (BuildCraftCore.recipesBlacklist.contains(name)) { - return; - } - - FlexibleRecipe recipe = new FlexibleRecipe(id, result, energy, delay, ingredient); recipes.put(id, recipe); validFluids1.add(ingredient); @@ -48,10 +43,6 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { int delay) { String name = result.getFluid().getName(); - if (BuildCraftCore.recipesBlacklist.contains(name)) { - return; - } - if (ingredient1 == null || ingredient2 == null || result == null) { BCLog.logger.warn("Rejected refinery recipe " + id + " due to a null FluidStack!"); } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index e7d3ec88..c0c70fa8 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -98,7 +98,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI public TileQuarry () { box.kind = Kind.STRIPES; - this.setBattery(new RFBattery((int) (2 * 64 * BuilderAPI.BREAK_ENERGY * BuildCraftFactory.miningMultiplier), (int) (1000 * BuildCraftFactory.miningMultiplier), 0)); + this.setBattery(new RFBattery((int) (2 * 64 * BuilderAPI.BREAK_ENERGY * BuildCraftCore.miningMultiplier), (int) (1000 * BuildCraftCore.miningMultiplier), 0)); } public void createUtilsIfNeeded() { diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index cbd295d6..824acc37 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -119,7 +119,7 @@ public class PipeTransportItems extends PipeTransport implements IDebuggable { int itemStackCount = getNumberOfStacks(); - if (itemStackCount > BuildCraftTransport.groupItemsTrigger) { + if (itemStackCount >= (MAX_PIPE_STACKS / 2)) { groupEntities(); itemStackCount = getNumberOfStacks(); } diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java index 91770598..75815cb5 100644 --- a/common/buildcraft/transport/TravelingItem.java +++ b/common/buildcraft/transport/TravelingItem.java @@ -210,7 +210,7 @@ public class TravelingItem { motion.moveForwards(0.1 + getSpeed() * 2F); EntityItem entity = new EntityItem(container.getWorldObj(), xCoord, yCoord, zCoord, getItemStack()); - entity.lifespan = BuildCraftCore.itemLifespan; + entity.lifespan = BuildCraftCore.itemLifespan * 20; entity.delayBeforeCanPickup = 10; float f3 = 0.00F + container.getWorldObj().rand.nextFloat() * 0.04F - 0.02F;