aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2021-12-20 18:00:48 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2021-12-20 18:00:48 +0000
commit849ae606a186ff5c1b7e9411bd2ed3589dcb06b5 (patch)
treedf198135cf96228dc00d9f76b0e0c5982788b1e0 /src/main/java/gtPlusPlus/xmod/gregtech
parent615dd5ae99d6703efef551fd34e2092b1b8a4496 (diff)
downloadGT5-Unofficial-849ae606a186ff5c1b7e9411bd2ed3589dcb06b5.tar.gz
GT5-Unofficial-849ae606a186ff5c1b7e9411bd2ed3589dcb06b5.tar.bz2
GT5-Unofficial-849ae606a186ff5c1b7e9411bd2ed3589dcb06b5.zip
Add RemoteIO and EnderIO support to Reservoir Hatch.
Changed Extreme Airtake from 5k/4t to 8k/4t. Clean up some reflection. Cleaned up GT_MetaTileEntity_Hatch_FluidGenerator.java.
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java4
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java26
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java58
3 files changed, 69 insertions, 19 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java
index 5ebb2da8d4..d70afcb433 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java
@@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity
String[] aTooltip = new String[3];
aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!";
aTooltip[1] = "Draws in Air from the surrounding environment";
- aTooltip[2] = "Creates 5000L of Air every 4 ticks";
+ aTooltip[2] = "Creates 8000L of Air every 4 ticks";
return aTooltip;
}
@@ -40,7 +40,7 @@ public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity
@Override
public int getAmountOfFluidToGenerate() {
- return 5000;
+ return 8000;
}
@Override
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java
index 7579c8ec5a..d4b8b3a064 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java
@@ -178,31 +178,29 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile
return true;
}
- public boolean isAirInHatch() {
- if (this.mFluid != null) {
- if (getFluidToGenerate() == this.mFluid.getFluid()) {
- return true;
- }
- }
- return false;
- }
-
public abstract boolean doesHatchMeetConditionsToGenerate();
public boolean addFluidToHatch(long aTick) {
if (!doesHatchMeetConditionsToGenerate()) {
return false;
- }
- boolean didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0;
- if (didFill) {
- this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud");
+ }
+ boolean didFill = false;
+ if (canTankBeFilled()) {
+ didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0;
+ if (didFill) {
+ this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud");
+ }
}
return didFill;
}
@Override
public boolean canTankBeFilled() {
- if (this.mFluid == null || (this.mFluid != null && (this.mFluid.amount <= this.getCapacity()))) {
+ //Logger.INFO("Total Space: "+this.getCapacity());
+ //Logger.INFO("Current capacity: "+this.getFluidAmount());
+ //Logger.INFO("To add: "+this.getAmountOfFluidToGenerate());
+ //Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount()));
+ if (this.mFluid == null || (this.mFluid != null && (this.getCapacity() - this.getFluidAmount() >= this.getAmountOfFluidToGenerate()))) {
return true;
}
return false;
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java
index 5cd57e9e92..a2aa4d266c 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java
@@ -1,20 +1,32 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
-import gregtech.api.enums.Textures;
-import gregtech.api.interfaces.IIconContainer;
+import java.lang.reflect.Field;
+
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.IFluidHandler;
public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_FluidGenerator {
+ private static Class sClass_EIO;
+ private static Class sClass_RIO;
+ private static Field sField_EIO;
+ private static Field sField_RIO;
+ private static Block sBlock_EIO;
+ private static Block sBlock_RIO;
+
public GT_MetaTileEntity_Hatch_Reservoir(final int aID, final String aName, final String aNameRegional, final int aTier) {
super(aID, aName, aNameRegional, aTier);
}
@@ -56,11 +68,51 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F
public int getCapacity() {
return 128000;
}
+
+ private static void setCrossModData() {
+ if (LoadedMods.EnderIO && sClass_EIO == null) {
+ sClass_EIO = ReflectionUtils.getClass("crazypants.enderio.EnderIO");
+ sField_EIO = ReflectionUtils.getField(sClass_EIO, "blockReservoir");
+ sBlock_EIO = ReflectionUtils.getFieldValue(sField_EIO, null);
+ }
+ if (LoadedMods.RemoteIO && sClass_RIO == null) {
+ sClass_RIO = ReflectionUtils.getClass("remoteio.common.lib.ModBlocks");
+ sField_RIO = ReflectionUtils.getField(sClass_RIO, "machine");
+ sBlock_RIO = ReflectionUtils.getFieldValue(sField_RIO, null);
+ }
+ }
+
+ public static boolean isTileValid(TileEntity aTile) {
+ if (aTile != null) {
+ if (aTile instanceof IFluidHandler) {
+ IFluidHandler aFluidHandler = (IFluidHandler) aTile;
+ return aFluidHandler.canDrain(ForgeDirection.UNKNOWN, FluidRegistry.WATER);
+ }
+ }
+ return false;
+ }
@Override
public boolean doesHatchMeetConditionsToGenerate() {
Block aWater = this.getBaseMetaTileEntity().getBlockAtSide(this.getBaseMetaTileEntity().getFrontFacing());
- return aWater == Blocks.water || aWater == Blocks.flowing_water;
+ if (aWater != null && aWater != Blocks.air) {
+ if (!this.canTankBeFilled()) {
+ return false;
+ }
+ setCrossModData();
+ if (LoadedMods.EnderIO) {
+ if (aWater == sBlock_EIO) {
+ return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing()));
+ }
+ }
+ if (LoadedMods.RemoteIO) {
+ if (aWater == sBlock_RIO && this.getBaseMetaTileEntity().getMetaIDAtSide(this.getBaseMetaTileEntity().getFrontFacing()) == 0) {
+ return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing()));
+ }
+ }
+ return aWater == Blocks.water || aWater == Blocks.flowing_water;
+ }
+ return false;
}
@Override