aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorNotAPenguin <michiel.vandeginste@gmail.com>2024-04-18 21:59:21 +0200
committerGitHub <noreply@github.com>2024-04-18 21:59:21 +0200
commit42f6697183238ca52679e7193b0aa905769f36e7 (patch)
tree8185dd99e97608bd7e887d2c5fefe82460cec1c9 /src/main/java/gregtech/api/metatileentity
parentd17dbf4026f8c59444d42d3afc95243cb4d23822 (diff)
downloadGT5-Unofficial-42f6697183238ca52679e7193b0aa905769f36e7.tar.gz
GT5-Unofficial-42f6697183238ca52679e7193b0aa905769f36e7.tar.bz2
GT5-Unofficial-42f6697183238ca52679e7193b0aa905769f36e7.zip
Swap around order of if-tests in machine explosion check to slightly speed up MTE updates (#2580)
Re-order some logic in machine rain explosion check
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 61728d9267..bf6358c884 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -438,44 +438,13 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity
if (GregTech_API.sMachineRainExplosions) {
if (mMetaTileEntity.willExplodeInRain()) {
if (getRandomNumber(1000) == 0 && isRainPossible()) {
- if (isRainExposed()) {
- if (worldObj.isRaining()) {
- if (getRandomNumber(10) == 0) {
- try {
- GT_Mod.achievements.issueAchievement(
- this.getWorldObj()
- .getPlayerEntityByName(mOwnerName),
- "badweather");
- } catch (Exception ignored) {}
- GT_Log.exp.println(
- "Machine at: " + this.getXCoord()
- + " | "
- + this.getYCoord()
- + " | "
- + this.getZCoord()
- + " DIMID: "
- + this.worldObj.provider.dimensionId
- + " explosion due to rain!");
- doEnergyExplosion();
- } else {
- GT_Log.exp.println(
- "Machine at: " + this.getXCoord()
- + " | "
- + this.getYCoord()
- + " | "
- + this.getZCoord()
- + " DIMID: "
- + this.worldObj.provider.dimensionId
- + " set to Fire due to rain!");
- setOnFire();
- }
- }
- if (!hasValidMetaTileEntity()) {
- mRunningThroughTick = false;
- return;
- }
- if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering()
- && getRandomNumber(3) == 0) {
+ // Short-circuit so raincheck happens before isRainExposed,
+ // saves sme TPS since rain exposed check can be slow
+ // This logic can be compressed further by only checking for
+ // isRainExposed once IF we can guarantee it never thunders without
+ // raining, but I don't know if this is true or not.
+ if (worldObj.isRaining() && isRainExposed()) {
+ if (getRandomNumber(10) == 0) {
try {
GT_Mod.achievements.issueAchievement(
this.getWorldObj()
@@ -490,10 +459,45 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity
+ this.getZCoord()
+ " DIMID: "
+ this.worldObj.provider.dimensionId
- + " explosion due to Thunderstorm!");
+ + " explosion due to rain!");
doEnergyExplosion();
+ } else {
+ GT_Log.exp.println(
+ "Machine at: " + this.getXCoord()
+ + " | "
+ + this.getYCoord()
+ + " | "
+ + this.getZCoord()
+ + " DIMID: "
+ + this.worldObj.provider.dimensionId
+ + " set to Fire due to rain!");
+ setOnFire();
}
}
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering()
+ && getRandomNumber(3) == 0
+ && isRainExposed()) {
+ try {
+ GT_Mod.achievements.issueAchievement(
+ this.getWorldObj()
+ .getPlayerEntityByName(mOwnerName),
+ "badweather");
+ } catch (Exception ignored) {}
+ GT_Log.exp.println(
+ "Machine at: " + this.getXCoord()
+ + " | "
+ + this.getYCoord()
+ + " | "
+ + this.getZCoord()
+ + " DIMID: "
+ + this.worldObj.provider.dimensionId
+ + " explosion due to Thunderstorm!");
+ doEnergyExplosion();
+ }
}
}
}