Skip to content

Commit

Permalink
Fix crash due to loading order issue when a config file is first created
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Jan 9, 2018
1 parent 4ba3f7f commit 5009214
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
14 changes: 13 additions & 1 deletion AdditionalPipesBC_Server.launch
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"><stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="GradleStartServer"/><stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AdditionalPipesBC"/><stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="C:\Users\jamie\workspace\AdditionalPipesBC\minecraft"/><stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value=" -DFORGE_FORCE_FRAME_RECALC=true"/></launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/AdditionalPipesBC"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="GradleStartServer"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AdditionalPipesBC"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DFORGE_FORCE_FRAME_RECALC=true"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:AdditionalPipesBC/minecraft-server}"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
14 changes: 5 additions & 9 deletions src/main/java/buildcraft/additionalpipes/APConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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});
Expand Down
43 changes: 17 additions & 26 deletions src/main/java/buildcraft/additionalpipes/AdditionalPipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -112,13 +112,7 @@ public void registerBlocks(RegistryEvent.Register<Block> event)
{
Log.info("Registering blocks");

if(APConfiguration.enableChunkloader)
{
event.getRegistry().register(blockTeleportTether);

Log.debug("Chunkloader enabled!");
}

event.getRegistry().register(blockTeleportTether);
}

@SubscribeEvent
Expand All @@ -141,9 +135,11 @@ public void registerRecipes(RegistryEvent.Register<IRecipe> 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);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 5009214

Please sign in to comment.