mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Hopefully fixed Laser Relay Connections sometimes breaking when quitting a world or server
This commit is contained in:
parent
2ab300a9a5
commit
ea9aee28db
2 changed files with 15 additions and 5 deletions
|
@ -47,6 +47,7 @@ import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
import ellpeck.actuallyadditions.util.playerdata.PersistentServerData;
|
import ellpeck.actuallyadditions.util.playerdata.PersistentServerData;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
// So that BuildCraft Oil always gets used
|
// 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")
|
@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(InitItems.itemBucketCanolaOil, new DispenserHandlerEmptyBucket());
|
||||||
Util.registerDispenserHandler(Items.bucket, new DispenserHandlerFillBucket());
|
Util.registerDispenserHandler(Items.bucket, new DispenserHandlerFillBucket());
|
||||||
Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize());
|
Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize());
|
||||||
|
}
|
||||||
|
|
||||||
WorldData.init(event.getServer());
|
@EventHandler
|
||||||
|
public void serverStarted(FMLServerStartedEvent event){
|
||||||
|
WorldData.init(MinecraftServer.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -37,16 +37,22 @@ public class WorldData extends WorldSavedData{
|
||||||
if(server != null){
|
if(server != null){
|
||||||
World world = server.getEntityWorld();
|
World world = server.getEntityWorld();
|
||||||
if(!world.isRemote){
|
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
|
//Generate new SavedData
|
||||||
if(savedData == null){
|
if(savedData == null){
|
||||||
|
ModUtil.LOGGER.info("No WorldData found, creating...");
|
||||||
|
|
||||||
savedData = new WorldData(WorldData.DATA_TAG);
|
savedData = new WorldData(WorldData.DATA_TAG);
|
||||||
world.setItemData(WorldData.DATA_TAG, savedData);
|
world.setItemData(WorldData.DATA_TAG, savedData);
|
||||||
}
|
}
|
||||||
//Set the current SavedData to the retreived one
|
else{
|
||||||
if(savedData instanceof WorldData){
|
ModUtil.LOGGER.info("WorldData sucessfully received!");
|
||||||
WorldData.instance = (WorldData)savedData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set the current SavedData to the retreived one
|
||||||
|
WorldData.instance = savedData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue