diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/EntityLivingEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/EntityLivingEvents.java index db81ba522..66fd441e1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/EntityLivingEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/EntityLivingEvents.java @@ -87,7 +87,7 @@ public class EntityLivingEvents{ data.setTag("Deaths", deaths); //player.addChatComponentMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".deathRecorded")); - WorldData.get(((EntityPlayer)event.getEntityLiving()).worldObj).markDirty(); + WorldData.markDirty(event.getEntityLiving().getEntityWorld()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java index 6bdc36f6f..0822aad4d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java @@ -52,7 +52,7 @@ public class PlayerObtainEvents{ NBTTagCompound compound = PlayerServerData.getDataFromPlayer(event.player); if(compound != null && !compound.getBoolean("BookGottenAlready")){ compound.setBoolean("BookGottenAlready", true); - WorldData.get(event.player.worldObj).markDirty(); + WorldData.markDirty(event.player.worldObj); EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemBooklet)); entityItem.setPickupDelay(0); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/WorldLoadingEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/WorldLoadingEvents.java index 1d6ad85ed..5597a1ada 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/WorldLoadingEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/WorldLoadingEvents.java @@ -20,14 +20,14 @@ public class WorldLoadingEvents{ @SubscribeEvent public void onLoad(WorldEvent.Load event){ if(!event.getWorld().isRemote){ - WorldData.get(event.getWorld()); + WorldData.loadOrGet(event.getWorld()); } } @SubscribeEvent public void onUnload(WorldEvent.Unload event){ if(!event.getWorld().isRemote){ - WorldData.get(event.getWorld()).markDirty(); + WorldData.markDirty(event.getWorld()); FakePlayerUtil.unloadFakePlayer(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java index 5deee458f..561ee2048 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java @@ -60,7 +60,7 @@ public class ItemLaserWrench extends ItemBase{ ((TileEntityLaserRelay)world.getTileEntity(savedPos)).sendUpdate(); ((TileEntityLaserRelay)world.getTileEntity(pos)).sendUpdate(); - WorldData.get(world).markDirty(); + WorldData.markDirty(world); player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".laser.connected.desc")); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/WorldData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/WorldData.java index b9b016a55..8304ef5f2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/WorldData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/WorldData.java @@ -25,7 +25,7 @@ public class WorldData extends WorldSavedData{ super(tag); } - public static WorldData get(World world){ + public static WorldData loadOrGet(World world){ if(world.getMapStorage() != null){ WorldData data = (WorldData)world.getMapStorage().getOrLoadData(WorldData.class, DATA_TAG); if(data == null){ @@ -41,6 +41,13 @@ public class WorldData extends WorldSavedData{ } } + public static void markDirty(World world){ + WorldData data = loadOrGet(world); + if(data != null){ + data.markDirty(); + } + } + @Override public void readFromNBT(NBTTagCompound compound){ //Laser World Data diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index b741e0f57..b6f13a4ed 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -100,7 +100,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ public void invalidate(){ super.invalidate(); LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos); - WorldData.get(this.worldObj).markDirty(); + WorldData.markDirty(this.worldObj); } }