Hopefully fixed Laser Relay Connections sometimes breaking when quitting a world or server

This commit is contained in:
Ellpeck 2015-11-11 22:03:25 +01:00
parent 2ab300a9a5
commit ea9aee28db
2 changed files with 15 additions and 5 deletions

View file

@ -47,6 +47,7 @@ import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util;
import ellpeck.actuallyadditions.util.playerdata.PersistentServerData;
import net.minecraft.init.Items;
import net.minecraft.server.MinecraftServer;
// So that BuildCraft Oil always gets used
@Mod(modid = ModUtil.MOD_ID, name = ModUtil.NAME, version = ModUtil.VERSION, dependencies = "after:BuildCraft|Energy", canBeDeactivated = false, guiFactory = "ellpeck.actuallyadditions.config.GuiFactory")
@ -119,8 +120,11 @@ public class ActuallyAdditions{
Util.registerDispenserHandler(InitItems.itemBucketCanolaOil, new DispenserHandlerEmptyBucket());
Util.registerDispenserHandler(Items.bucket, new DispenserHandlerFillBucket());
Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize());
}
WorldData.init(event.getServer());
@EventHandler
public void serverStarted(FMLServerStartedEvent event){
WorldData.init(MinecraftServer.getServer());
}
@EventHandler

View file

@ -37,16 +37,22 @@ public class WorldData extends WorldSavedData{
if(server != null){
World world = server.getEntityWorld();
if(!world.isRemote){
WorldSavedData savedData = world.loadItemData(WorldData.class, WorldData.DATA_TAG);
ModUtil.LOGGER.info("Loading WorldData!");
WorldData savedData = (WorldData)world.loadItemData(WorldData.class, WorldData.DATA_TAG);
//Generate new SavedData
if(savedData == null){
ModUtil.LOGGER.info("No WorldData found, creating...");
savedData = new WorldData(WorldData.DATA_TAG);
world.setItemData(WorldData.DATA_TAG, savedData);
}
//Set the current SavedData to the retreived one
if(savedData instanceof WorldData){
WorldData.instance = (WorldData)savedData;
else{
ModUtil.LOGGER.info("WorldData sucessfully received!");
}
//Set the current SavedData to the retreived one
WorldData.instance = savedData;
}
}
}