aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2019-07-13 20:46:56 +0200
committerTec <daniel112092@gmail.com>2019-07-13 20:46:56 +0200
commit4224247331125631d9d89a5d38740c2273579bc7 (patch)
tree21d06aa067a347eda8f1a3b086de64499496c48d
parent99708323b391b108d035ba483da82f4aa2211b1c (diff)
downloadGT5-Unofficial-4224247331125631d9d89a5d38740c2273579bc7.tar.gz
GT5-Unofficial-4224247331125631d9d89a5d38740c2273579bc7.tar.bz2
GT5-Unofficial-4224247331125631d9d89a5d38740c2273579bc7.zip
Fix chunk data invalid cleanup
-rw-r--r--src/main/java/com/github/technus/tectech/TecTech.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java5
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java13
3 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java
index 337f493801..84dbc204d5 100644
--- a/src/main/java/com/github/technus/tectech/TecTech.java
+++ b/src/main/java/com/github/technus/tectech/TecTech.java
@@ -4,6 +4,7 @@ import com.github.technus.tectech.loader.MainLoader;
import com.github.technus.tectech.loader.TecTechConfig;
import com.github.technus.tectech.mechanics.ConvertFloat;
import com.github.technus.tectech.mechanics.ConvertInteger;
+import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler;
import com.github.technus.tectech.mechanics.chunkData.ChunkDataHandler;
import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM;
import com.github.technus.tectech.mechanics.elementalMatter.core.commands.ListEM;
@@ -36,6 +37,7 @@ public class TecTech {
public static TecTechConfig configTecTech;
public static ChunkDataHandler chunkDataHandler=new ChunkDataHandler();
+ public static AnomalyHandler anomalyHandler=new AnomalyHandler();
/**
* For Loader.isModLoaded checks during the runtime
@@ -85,6 +87,8 @@ public class TecTech {
@Mod.EventHandler
public void PostLoad(FMLPostInitializationEvent PostEvent) {
MainLoader.postLoad();
+
+ chunkDataHandler.registerChunkMetaDataHandler(anomalyHandler);
}
@Mod.EventHandler
diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
index f0669431a9..7d58d6b6ae 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.HashMap;
public class AnomalyHandler implements ChunkMetaDataHandler {
+ private static final String INTENSITY="intensity";
@Override
public String getTagName() {
@@ -16,8 +17,8 @@ public class AnomalyHandler implements ChunkMetaDataHandler {
@Override
public void mergeData(NBTTagCompound target, NBTTagCompound loadedData) {
- target.setInteger("intensity",
- target.getInteger("intensity")+loadedData.getInteger("intensity"));
+ int intensity=target.getInteger(INTENSITY)+loadedData.getInteger(INTENSITY);
+ target.setInteger(INTENSITY,intensity);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java
index 50a92d6178..8dc60248ef 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java
@@ -31,15 +31,12 @@ public class ChunkDataHandler {
if(loadedTag.hasNoTags()){
return;
}
-
int dimId=event.world.provider.dimensionId;
HashMap<ChunkCoordIntPair, NBTChunk> dimensionMemory=
dimensionWiseChunkData.computeIfAbsent(dimId, this::createDimensionData);
-
ChunkCoordIntPair chunkCoordIntPair=event.getChunk().getChunkCoordIntPair();
- NBTChunk chunkMemory =dimensionMemory.get(chunkCoordIntPair);
Set<String> loadedKeys=loadedTag.func_150296_c();
-
+ NBTChunk chunkMemory =dimensionMemory.get(chunkCoordIntPair);
if(chunkMemory==null) {
chunkMemory=new NBTChunk(loadedTag,true);
dimensionMemory.put(chunkCoordIntPair,chunkMemory);
@@ -78,7 +75,7 @@ public class ChunkDataHandler {
public void onServerStarting() {
dimensionWiseChunkData.clear();
- dimensionWiseMetaChunkData.clear();
+ dimensionWiseMetaChunkData.forEach((k,v)->v.clear());
}
public void registerChunkMetaDataHandler(ChunkMetaDataHandler handler){
@@ -123,7 +120,7 @@ public class ChunkDataHandler {
return map;
}
- public static class ChunkHashMap implements Map<ChunkCoordIntPair,NBTTagCompound>{
+ public static final class ChunkHashMap implements Map<ChunkCoordIntPair,NBTTagCompound>{
private final HashMap<ChunkCoordIntPair,NBTChunk> storage;
private final HashMap<ChunkCoordIntPair,NBTTagCompound> storageMeta=new HashMap<>(1024);
private final String meta;
@@ -180,7 +177,7 @@ public class ChunkDataHandler {
@Override
public void clear() {
- entrySet().forEach(this::remove);
+ storageMeta.entrySet().forEach(this::remove);
}
@Override
@@ -214,7 +211,7 @@ public class ChunkDataHandler {
}
}
- private static class NBTChunk {
+ private static final class NBTChunk {
private final NBTTagCompound data;
private boolean isLoaded;