aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKiloJoel <kilojoel@gmail.com>2021-01-09 08:26:20 +0000
committerGitHub <noreply@github.com>2021-01-09 09:26:20 +0100
commit262f82fb854237f43932ea6fc21ee081c733ea39 (patch)
tree1a75cf06762e1d5d3a9e36d8d57d30ba6379969a /src/main/java
parent3546ec3bbabb88f4499d3833152e73ba6ad76df1 (diff)
downloadGT5-Unofficial-262f82fb854237f43932ea6fc21ee081c733ea39.tar.gz
GT5-Unofficial-262f82fb854237f43932ea6fc21ee081c733ea39.tar.bz2
GT5-Unofficial-262f82fb854237f43932ea6fc21ee081c733ea39.zip
Fixed lag reduction on file saving (#48)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java21
1 files changed, 15 insertions, 6 deletions
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 0beb5e0af8..dd388bc233 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
@@ -233,23 +233,32 @@ public class AnomalyHandler implements IChunkMetaDataHandler {
ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ);
NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair);
NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player);
+ boolean saveRequired = false;
if(player.capabilities.isCreativeMode){
- playerTag.setDouble(SPACE_CANCER, 0);
+ if (playerTag.getDouble(SPACE_CANCER) != 0) {
+ playerTag.setDouble(SPACE_CANCER, 0);
+ saveRequired = true;
+ }
}else {
if (compound != null) {
int badness = (int) Math.min(COUNT_DIV, compound.getDouble(INTENSITY) / PER_PARTICLE);
if (badness > 0) {
playerTag.setDouble(SPACE_CANCER, Math.min(2, playerTag.getDouble(SPACE_CANCER) + 9.765625E-4f * badness));
player.attackEntityFrom(MainLoader.subspace,Math.max(1,badness/8f));
+ saveRequired = true;
}
} else if (playerTag.getDouble(SPACE_CANCER) > 0 && !player.isDead) {
- if (playerTag.getDouble(SPACE_CANCER) == 0 || player.ticksExisted % 10 != 0)
- return;
- playerTag.setDouble(SPACE_CANCER, Math.max(0, playerTag.getDouble(SPACE_CANCER) - 7.6293945E-5f));
+ if (player.ticksExisted % 10 == 0) {
+ playerTag.setDouble(SPACE_CANCER, Math.max(0, playerTag.getDouble(SPACE_CANCER) - 7.6293945E-5f));
+ saveRequired = true;
+ }
}
}
- TecTech.playerPersistence.saveData(player);
- NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), (EntityPlayerMP) player);
+
+ if (saveRequired) {
+ TecTech.playerPersistence.saveData(player);
+ NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), (EntityPlayerMP) player);
+ }
}
}