aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/minecraft')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java
index 8ecdab4bbc..d4f217bbfd 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java
@@ -6,12 +6,26 @@ import java.lang.reflect.Method;
import gregtech.GT_Mod;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
import gregtech.common.GT_Proxy;
-
+import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.chunk.Chunk;
public class PollutionUtils {
+ private static boolean mIsPollutionEnabled = true;
+
+ static {
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) {
+ mIsPollutionEnabled = mPollution();
+ }
+ else {
+ mIsPollutionEnabled = false;
+ }
+ }
+
public static boolean mPollution() {
try {
GT_Proxy GT_Pollution = GT_Mod.gregtechproxy;
@@ -21,11 +35,13 @@ public class PollutionUtils {
return mPollution.getBoolean(GT_Pollution);
}
}
- } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {}
+ } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
+ }
return false;
}
public static boolean addPollution(IGregTechTileEntity te, int pollutionValue) {
+ if (mIsPollutionEnabled)
try {
Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution");
if (GT_Pollution != null) {
@@ -36,11 +52,13 @@ public class PollutionUtils {
}
}
} catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {}
+ | IllegalArgumentException | InvocationTargetException e) {
+ }
return false;
}
public static int getPollution(IGregTechTileEntity te) {
+ if (mIsPollutionEnabled)
try {
Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution");
if (GT_Pollution != null) {
@@ -50,8 +68,39 @@ public class PollutionUtils {
}
}
} catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {}
+ | IllegalArgumentException | InvocationTargetException e) {
+ }
return 0;
}
+ public static boolean addPollution(Object aTileOfSomeSort, int pollutionValue) {
+ if (mIsPollutionEnabled)
+ try {
+ Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution");
+ if (GT_Pollution != null) {
+ Method addPollution = GT_Pollution.getMethod("addPollution", Chunk.class, int.class);
+ if (addPollution != null) {
+ IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort;
+ if (j != null) {
+ Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord());
+ addPollution.invoke(null, c, pollutionValue);
+ return true;
+ } else {
+ TileEntity t = (TileEntity) aTileOfSomeSort;
+ if (t != null) {
+ Chunk c = t.getWorldObj().getChunkFromBlockCoords(t.xCoord, t.zCoord);
+ addPollution.invoke(null, c, pollutionValue);
+ return true;
+ }
+ }
+
+ }
+ }
+ } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ }
+ return false;
+
+ }
+
}