fixed possible NPE

This commit is contained in:
2016-12-22 15:54:45 +01:00
parent 36c425e143
commit 7adec10002

View File

@@ -1,5 +1,6 @@
package com.sosnitzka.taiga.world; package com.sosnitzka.taiga.world;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -53,8 +54,8 @@ public class MeteorWorldSaveData extends WorldSavedData {
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("posData")) { if (nbt.hasKey("posData") && !nbt.getString("posData").isEmpty()) {
posList = new Gson().fromJson(nbt.getString("posData"), posList.getClass()); posList = new Gson().fromJson(nbt.getString("posData"), new TypeToken<List<BlockPos>>(){}.getType());
} }
} }