From 5009214fe4d80ed1be9619009e1f826d947f2453 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 8 Jan 2018 18:01:15 -0800 Subject: [PATCH] Fix crash due to loading order issue when a config file is first created --- AdditionalPipesBC_Server.launch | 14 +++++- build.gradle | 2 +- .../additionalpipes/APConfiguration.java | 14 +++--- .../additionalpipes/APPipeDefintions.java | 3 +- .../additionalpipes/AdditionalPipes.java | 43 ++++++++----------- .../MultiPlayerProxyClient.java | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/AdditionalPipesBC_Server.launch b/AdditionalPipesBC_Server.launch index af1c2fc..e403c8e 100644 --- a/AdditionalPipesBC_Server.launch +++ b/AdditionalPipesBC_Server.launch @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/build.gradle b/build.gradle index b36ba28..67871d1 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "6.0.0.1" +version = "6.0.0.2" group= "com.buildcraft.additionalpipes" archivesBaseName = "additionalpipes" diff --git a/src/main/java/buildcraft/additionalpipes/APConfiguration.java b/src/main/java/buildcraft/additionalpipes/APConfiguration.java index 4abce36..deace9b 100644 --- a/src/main/java/buildcraft/additionalpipes/APConfiguration.java +++ b/src/main/java/buildcraft/additionalpipes/APConfiguration.java @@ -16,7 +16,7 @@ public class APConfiguration public static boolean enableDebugLog; - public static boolean enableChunkloader; + public static boolean enableChunkloaderRecipe; // keybinding public static int laserKeyCode; // config option (& in options menu) @@ -33,12 +33,8 @@ public class APConfiguration public static boolean filterRightclicks = false; - public static void loadConfigs(boolean init, File configFile) + public static void loadConfigs(File configFile) { - if((!configFile.exists() && !init) || (configFile.exists() && init)) - { - return; - } Configuration config = new Configuration(configFile); try { @@ -80,9 +76,9 @@ else if(powerTransmittanceCfg < 0.0) gpPullRateProperty.setComment("How many ticks the Gravity Feed Pipe needs to extract an item"); gravityFeedPipeTicksPerPull = gpPullRateProperty.getInt(); - Property enableChunkloaderProperty = config.get(Configuration.CATEGORY_GENERAL, "enableChunkloader", true); - enableChunkloaderProperty.setComment("Whether or not the chunkloader is added as a block"); - enableChunkloader = enableChunkloaderProperty.getBoolean(); + Property enableChunkloaderProperty = config.get(Configuration.CATEGORY_GENERAL, "enableChunkloaderRecipe", true); + enableChunkloaderProperty.setComment("Whether or not the chunkloader will have a crafting recipe. Set to false to make it a creative-only item."); + enableChunkloaderRecipe = enableChunkloaderProperty.getBoolean(); } catch(Exception e) { diff --git a/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java b/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java index 4a0a366..70a3f5b 100644 --- a/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java +++ b/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java @@ -15,6 +15,7 @@ import buildcraft.additionalpipes.pipes.PipeBehaviorTeleportPower; import buildcraft.additionalpipes.pipes.PipeBehaviorWaterPump; import buildcraft.additionalpipes.utils.PipeCreator; +import buildcraft.api.mj.MjAPI; import buildcraft.api.recipes.AssemblyRecipeBasic; import buildcraft.api.recipes.IngredientStack; import buildcraft.api.transport.pipe.PipeApi; @@ -126,7 +127,7 @@ public static void createPipes() IngredientStack.of(new ItemStack(BCSiliconItems.redstoneChipset, 1, 4)), IngredientStack.of(new ItemStack(BCTransportItems.pipeItemDiamond)), IngredientStack.of(new ItemStack(BCSiliconItems.redstoneChipset, 1, 3))); - AssemblyRecipeRegistry.register(new AssemblyRecipeBasic("teleportPipe", 10000, tpRecipeIngredients, new ItemStack(itemsTeleportPipeItem, 8))); + AssemblyRecipeRegistry.register(new AssemblyRecipeBasic("teleportPipe", 10000 * MjAPI.MJ, tpRecipeIngredients, new ItemStack(itemsTeleportPipeItem, 8))); liquidsTeleportPipeDef = new PipeDefinitionBuilder().flowFluid().idTexPrefix("pipe_fluids_teleport").logic(PipeBehaviorTeleportFluids::new, PipeBehaviorTeleportFluids::new).define(); liquidsTeleportPipeItem = PipeCreator.createPipeItemAndRecipe(1, liquidsTeleportPipeDef, true, new Object[] {BCTransportItems.waterproof, itemsTeleportPipeItem}); diff --git a/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java b/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java index 14bb070..2a4f0d2 100644 --- a/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java +++ b/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java @@ -47,7 +47,7 @@ public class AdditionalPipes { public static final String MODID = "additionalpipes"; public static final String NAME = "Additional Pipes"; - public static final String VERSION = "6.0.0.1"; + public static final String VERSION = "6.0.0.2"; @Instance(MODID) public static AdditionalPipes instance; @@ -83,7 +83,7 @@ public void preInit(FMLPreInitializationEvent event) PacketHandler.init(); configFile = event.getSuggestedConfigurationFile(); - APConfiguration.loadConfigs(false, configFile); + APConfiguration.loadConfigs(configFile); MinecraftForge.EVENT_BUS.register(this); //create BuildCraft creative tab @@ -99,7 +99,7 @@ public void preInit(FMLPreInitializationEvent event) StatementManager.registerTriggerProvider(new GateProvider()); // create blocks - if(APConfiguration.enableChunkloader) + if(APConfiguration.enableChunkloaderRecipe) { blockTeleportTether = new BlockTeleportTether(); blockTeleportTether.setRegistryName("teleport_tether"); @@ -112,13 +112,7 @@ public void registerBlocks(RegistryEvent.Register event) { Log.info("Registering blocks"); - if(APConfiguration.enableChunkloader) - { - event.getRegistry().register(blockTeleportTether); - - Log.debug("Chunkloader enabled!"); - } - + event.getRegistry().register(blockTeleportTether); } @SubscribeEvent @@ -141,9 +135,11 @@ public void registerRecipes(RegistryEvent.Register event) deaggravatorRecipe.setRegistryName("dog_deaggravator"); event.getRegistry().register(deaggravatorRecipe); - if(APConfiguration.enableChunkloader) + if(APConfiguration.enableChunkloaderRecipe) { - ShapedOreRecipe chunkloaderRecipe = new ShapedOreRecipe(new ResourceLocation(MODID, "recipes/teleport_tether"), blockTeleportTether, "iii", "iLi", "ici", 'i', "ingotIron", 'L', "gemLapis", 'c', BCSiliconItems.redstoneChipset); + Log.debug("Chunkloader recipe enabled!"); + + ShapedOreRecipe chunkloaderRecipe = new ShapedOreRecipe(new ResourceLocation(MODID, "recipes/teleport_tether"), blockTeleportTether, "iii", "iLi", "ici", 'i', "ingotIron", 'L', "gemLapis", 'c', new ItemStack(BCSiliconItems.redstoneChipset, 1, 3)); chunkloaderRecipe.setRegistryName("teleport_tether"); event.getRegistry().register(chunkloaderRecipe); } @@ -164,20 +160,15 @@ public void init(FMLInitializationEvent event) NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); - if(APConfiguration.enableChunkloader) - { - Log.info("Registering chunk load handler"); - ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkLoadingHandler()); - //chunkLoadViewer = new ChunkLoadViewDataProxy(APConfiguration.chunkSightRange); - //MinecraftForge.EVENT_BUS.register(chunkLoadViewer); - - GameRegistry.registerTileEntity(TileTeleportTether.class, "teleport_tether"); - - // the lasers key function depends on the chunk loading code, so it can only be enabled if the chunk loader is - proxy.registerKeyHandler(); - - } - APConfiguration.loadConfigs(true, configFile); + Log.info("Registering chunk load handler"); + ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkLoadingHandler()); + //chunkLoadViewer = new ChunkLoadViewDataProxy(APConfiguration.chunkSightRange); + //MinecraftForge.EVENT_BUS.register(chunkLoadViewer); + + GameRegistry.registerTileEntity(TileTeleportTether.class, "teleport_tether"); + + // the lasers key function depends on the chunk loading code, so it can only be enabled if the chunk loader is + proxy.registerKeyHandler(); //set creative tab icon diff --git a/src/main/java/buildcraft/additionalpipes/MultiPlayerProxyClient.java b/src/main/java/buildcraft/additionalpipes/MultiPlayerProxyClient.java index 03db92f..57cb2bb 100644 --- a/src/main/java/buildcraft/additionalpipes/MultiPlayerProxyClient.java +++ b/src/main/java/buildcraft/additionalpipes/MultiPlayerProxyClient.java @@ -31,7 +31,7 @@ public void registerRendering() { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - if(APConfiguration.enableChunkloader) + if(APConfiguration.enableChunkloaderRecipe) { renderItem.getItemModelMesher().register(Item.getItemFromBlock(AdditionalPipes.instance.blockTeleportTether), 0, new ModelResourceLocation(AdditionalPipes.instance.blockTeleportTether.getRegistryName(), "inventory"));