mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
This is gonna work now. Promise.
God damn it.
This commit is contained in:
parent
eae2d1d288
commit
8834815c25
4 changed files with 17 additions and 18 deletions
|
@ -36,7 +36,7 @@ public class CraftEvent{
|
|||
NBTTagCompound compound = PersistentServerData.getDataFromPlayer(event.player);
|
||||
if(compound != null && !compound.getBoolean("BookGottenAlready")){
|
||||
compound.setBoolean("BookGottenAlready", true);
|
||||
WorldData.makeDirty(false);
|
||||
WorldData.makeDirty();
|
||||
|
||||
EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemLexicon));
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
|
|
|
@ -26,11 +26,11 @@ public class WorldLoadingEvents{
|
|||
|
||||
@SubscribeEvent
|
||||
public void onUnload(WorldEvent.Unload event){
|
||||
WorldData.makeDirty(true);
|
||||
WorldData.makeDirty();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSave(WorldEvent.Save event){
|
||||
WorldData.makeDirty(false);
|
||||
WorldData.makeDirty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class LaserRelayConnectionHandler{
|
|||
}
|
||||
//System.out.println("Removing a Relay from the Network!");
|
||||
}
|
||||
WorldData.makeDirty(false);
|
||||
WorldData.makeDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ public class LaserRelayConnectionHandler{
|
|||
else if(secondNetwork != null){
|
||||
secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||
}
|
||||
WorldData.makeDirty(false);
|
||||
WorldData.makeDirty();
|
||||
//System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
|
||||
//System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
|
||||
//System.out.println(this.networks);
|
||||
|
@ -156,7 +156,7 @@ public class LaserRelayConnectionHandler{
|
|||
firstNetwork.connections.add(secondPair);
|
||||
}
|
||||
this.networks.remove(secondNetwork);
|
||||
WorldData.makeDirty(false);
|
||||
WorldData.makeDirty();
|
||||
//System.out.println("Merged Two Networks!");
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,13 @@ public class WorldData extends WorldSavedData{
|
|||
public static final String DATA_TAG = ModUtil.MOD_ID+"WorldData";
|
||||
public static WorldData instance;
|
||||
|
||||
public boolean shouldClearAfterSave;
|
||||
|
||||
public WorldData(String tag){
|
||||
super(tag);
|
||||
}
|
||||
|
||||
public static void makeDirty(boolean shouldClearAfterSave){
|
||||
public static void makeDirty(){
|
||||
if(instance != null){
|
||||
instance.markDirty();
|
||||
instance.shouldClearAfterSave = shouldClearAfterSave;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +37,7 @@ public class WorldData extends WorldSavedData{
|
|||
if(server != null){
|
||||
World world = server.getEntityWorld();
|
||||
if(!world.isRemote){
|
||||
clearOldData();
|
||||
ModUtil.LOGGER.info("Loading WorldData!");
|
||||
|
||||
WorldData savedData = (WorldData)world.loadItemData(WorldData.class, WorldData.DATA_TAG);
|
||||
|
@ -60,6 +58,15 @@ public class WorldData extends WorldSavedData{
|
|||
}
|
||||
}
|
||||
|
||||
public static void clearOldData(){
|
||||
if(!LaserRelayConnectionHandler.getInstance().networks.isEmpty()){
|
||||
ModUtil.LOGGER.info("Clearing leftover Laser Relay Connection Data from other worlds!");
|
||||
}
|
||||
if(!PersistentServerData.playerSaveData.isEmpty()){
|
||||
ModUtil.LOGGER.info("Clearing leftover Persistent Server Data from other worlds!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
//Laser World Data
|
||||
|
@ -93,13 +100,5 @@ public class WorldData extends WorldSavedData{
|
|||
playerList.appendTag(theSave.toNBT());
|
||||
}
|
||||
compound.setTag("PlayerData", playerList);
|
||||
|
||||
if(this.shouldClearAfterSave){
|
||||
ModUtil.LOGGER.info("Clearing WorldData after saving! (Probably because the world is getting unloaded)");
|
||||
this.shouldClearAfterSave = false;
|
||||
|
||||
PersistentServerData.playerSaveData.clear();
|
||||
LaserRelayConnectionHandler.getInstance().networks.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue