aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-05-12 13:58:15 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-05-12 13:58:15 +1000
commit3615baf8ffb7a2efc44d4770da97ce1337f7801e (patch)
tree575092ab534082fbcd24027e369bc35d0eb3409b /src/Java/gtPlusPlus/xmod/gregtech/api
parent7933f8ad431fcf404cbd233c0c9f4b8364bef3d4 (diff)
downloadGT5-Unofficial-3615baf8ffb7a2efc44d4770da97ce1337f7801e.tar.gz
GT5-Unofficial-3615baf8ffb7a2efc44d4770da97ce1337f7801e.tar.bz2
GT5-Unofficial-3615baf8ffb7a2efc44d4770da97ce1337f7801e.zip
+ Properly implemented Air Filter requirements & a new GUI for Advanced Mufflers.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java66
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java11
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java40
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java108
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java1
5 files changed, 194 insertions, 32 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java
new file mode 100644
index 0000000000..30d0c3dcd6
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java
@@ -0,0 +1,66 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+import java.util.List;
+
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import gregtech.api.gui.GT_ContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv;
+
+
+public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine {
+
+ public long maxEU = 0;
+ public long storedEU = 0;
+
+ public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) {
+ super(aInventoryPlayer, aTileEntity, bindInventory);
+ }
+
+ @Override
+ public void addSlots(final InventoryPlayer aInventoryPlayer) {
+ this.addSlotToContainer(new Slot(this.mTileEntity, 1, 80, 17));
+ }
+
+ @Override
+ public int getSlotCount() {
+ return 1;
+ }
+
+ @Override
+ public int getShiftClickSlotCount() {
+ return 1;
+ }
+
+ @Override
+ public void updateProgressBar(final int id, final int value) {
+ super.updateProgressBar(id, value);
+ switch (id) {
+ case 100:
+ this.maxEU = value;
+ return;
+ case 101:
+ this.storedEU = value;
+ break;
+ default:
+ break;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for(final ICrafting crafting : (List<ICrafting>)this.crafters) {
+ crafting.sendProgressBarUpdate(this, 100, (int) ((GT_MetaTileEntity_Hatch_Muffler_Adv) this.mTileEntity.getMetaTileEntity()).maxEUStore());
+ crafting.sendProgressBarUpdate(this, 101, (int) ((GT_MetaTileEntity_Hatch_Muffler_Adv) this.mTileEntity.getMetaTileEntity()).getEUVar());
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java
index 503b36e157..dcab57c380 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java
@@ -4,21 +4,16 @@ import java.util.Iterator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.inventory.ICrafting;
-import net.minecraft.inventory.Slot;
-import net.minecraft.item.ItemStack;
-
import gregtech.api.gui.GT_ContainerMetaTile_Machine;
import gregtech.api.gui.GT_Slot_Output;
import gregtech.api.gui.GT_Slot_Render;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-
import gtPlusPlus.core.slots.SlotLockedInput;
-import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest;
import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.item.ItemStack;
public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine {
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java
new file mode 100644
index 0000000000..7aed0e60e1
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java
@@ -0,0 +1,40 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+
+import net.minecraft.entity.player.InventoryPlayer;
+
+import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+import gtPlusPlus.core.lib.CORE;
+
+public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine {
+
+ String mName = "";
+ long maxPower = 0;
+ long storedPower = 0;
+
+ public GUI_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) {
+ super(new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile));
+ this.mName = aName;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(final int par1, final int par2) {
+ this.fontRendererObj.drawString(this.mName, 64, 6, 16448255);
+ if (this.mContainer != null) {
+ this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU;
+ this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU;
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) {
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
+ this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU;
+ this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU;
+ final int x = (this.width - this.xSize) / 2;
+ final int y = (this.height - this.ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
+ }
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java
index 2832941bdd..0479914115 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java
@@ -1,11 +1,17 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Config;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.item.general.ItemAirFilter;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
+import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced;
+import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced;
import gtPlusPlus.xmod.gregtech.common.StaticFields59;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,11 +19,11 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler {
+ protected int SLOT_FILTER = 0;
+
@Override
public void onConfigLoad(GT_Config aConfig) {
super.onConfigLoad(aConfig);
@@ -49,16 +55,15 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch
}
public String[] getDescription() {
- if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
-
- String[] mDescArray = StaticFields59.getDescriptionArray(this);
-
- String[] desc = new String[mDescArray.length + 4];
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
+ String[] mDescArray = StaticFields59.getDescriptionArray(this);
+ String[] desc = new String[mDescArray.length + 5];
System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length);
desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!";
- desc[mDescArray.length + 1] = "Requires extra Air on the exhaust face";
- desc[mDescArray.length + 2] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%";
- desc[mDescArray.length + 3] = "Recovers " + (105 - this.calculatePollutionReduction(100))
+ desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face";
+ desc[mDescArray.length + 2] = "Requires Air Filters";
+ desc[mDescArray.length + 3] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%";
+ desc[mDescArray.length + 4] = "Recovers " + (105 - this.calculatePollutionReduction(100))
+ "% of CO2/CO/SO2";
return desc;
}
@@ -88,24 +93,33 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch
EntityPlayer aPlayer) {
if (aBaseMetaTileEntity.isClientSide())
return true;
- //aBaseMetaTileEntity.openGUI(aPlayer);
+ aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
- @Override
- public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory,
- IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
+
+
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity);
}
- @Override
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory,
- IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "machine_Charger.png");
+ }
+
+ private boolean airCheck() {
+ if (
+ this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) &&
+ this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) &&
+ this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2)
+ ) {
+ return true;
+ }
+ return false;
}
public boolean polluteEnvironment() {
- if (this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1)) {
+ if (airCheck()) {
int aEmission = this.calculatePollutionReduction(10000);
PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission);
//Logger.INFO("Outputting "+aEmission+"gbl");
@@ -117,15 +131,25 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch
}
public int calculatePollutionReduction(int aPollution) {
- return (int) ((double) aPollution * Math.pow(0.64D, (double) (this.mTier - 1)));
+ double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1));
+ int aVal2 = (int) aVal1;
+ if (!hasValidFilter()) {
+ aVal2 = 0;
+ }
+ return aVal2;
}
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return true;
+ if (aIndex == this.SLOT_FILTER) {
+ if (isAirFilter(aStack)) {
+ return true;
+ }
+ }
+ return false;
}
public boolean hasValidFilter() {
- return false;
+ return isAirFilter(this.mInventory[this.SLOT_FILTER]);
}
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
@@ -139,8 +163,46 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch
if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) {
this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName);
}
+ }
+
+ public boolean isAirFilter(ItemStack filter){
+ if (filter == null) {
+ return false;
+ }
+ if (filter.getItem() instanceof ItemAirFilter){
+ return true;
+ }
+ return false;
+ }
+
+ public boolean damageAirFilter(){
+ ItemStack filter = this.mInventory[this.SLOT_FILTER];
+ if (filter == null) {
+ return false;
+ }
+ if (isAirFilter(filter)){
+ long currentUse = ItemAirFilter.getFilterDamage(filter);
+ //Remove broken Filter
+ if (filter.getItemDamage() == 0 && currentUse >= 50-1){
+ this.mInventory[this.SLOT_FILTER] = null;
+ return false;
+ }
+ else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){
+ this.mInventory[this.SLOT_FILTER] = null;
+ return false;
+ }
+ else {
+ //Do Damage
+ ItemAirFilter.setFilterDamage(filter, currentUse+1);
+ Logger.WARNING("Filter Damage: "+currentUse);
+ return true;
+ }
+ }
+ return false;
}
+
+
public void pollutionParticles(World aWorld, String name) {
float ran1 = CORE.RANDOM.nextFloat();
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java
index bed80d8d13..b395bbbabe 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java
@@ -8,7 +8,6 @@ import gregtech.api.enums.Textures.BlockIcons;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.data.AutoMap;