aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-07-05 22:14:08 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-07-05 22:14:08 +1000
commit9ea82fb053fbe3c434b7a54754ee4bbc35f39aa6 (patch)
treef65d43cb60e30dc98e5f4c72a82dc96adb2946fc /src/Java/miscutil
parentd70832f1e04396e7c506dca506aa98783f380bab (diff)
downloadGT5-Unofficial-9ea82fb053fbe3c434b7a54754ee4bbc35f39aa6.tar.gz
GT5-Unofficial-9ea82fb053fbe3c434b7a54754ee4bbc35f39aa6.tar.bz2
GT5-Unofficial-9ea82fb053fbe3c434b7a54754ee4bbc35f39aa6.zip
% Fixed the Large Centrifuge (Sort of)
= It now requires a turbine rotor of any size/metal in it. (It doesn't take damage) + Separate GUI/Container classes for the Industrial Centrifuge.
Diffstat (limited to 'src/Java/miscutil')
-rw-r--r--src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java36
-rw-r--r--src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java7
-rw-r--r--src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java97
-rw-r--r--src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_MultiMachine.java1
-rw-r--r--src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java114
5 files changed, 217 insertions, 38 deletions
diff --git a/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java b/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java
new file mode 100644
index 0000000000..b41d7db67d
--- /dev/null
+++ b/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java
@@ -0,0 +1,36 @@
+package miscutil.core.xmod.gregtech.api.gui;
+
+import gregtech.api.gui.GT_ContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * The Container I use for all my Basic Machines
+ */
+public class CONTAINER_IndustrialCentrifuge extends GT_ContainerMetaTile_Machine {
+ public CONTAINER_IndustrialCentrifuge(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ public CONTAINER_IndustrialCentrifuge(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) {
+ super(aInventoryPlayer, aTileEntity, bindInventory);
+ }
+
+ @Override
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ addSlotToContainer(new Slot(mTileEntity, 1, 154, 42));
+ }
+
+ @Override
+ public int getSlotCount() {
+ return 1;
+ }
+
+ @Override
+ public int getShiftClickSlotCount() {
+ return 1;
+ }
+}
diff --git a/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
index 92fbb37af5..29d734c22c 100644
--- a/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
+++ b/src/Java/miscutil/core/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
@@ -17,6 +17,7 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine {
public CONTAINER_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) {
super(aInventoryPlayer, aTileEntity, bindInventory);
}
+}
/*@Override
public void addSlots(InventoryPlayer aInventoryPlayer) {
@@ -30,6 +31,6 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine {
@Override
public int getShiftClickSlotCount() {
- return 1;
- }*/
-}
+ return 0;
+ }
+}*/
diff --git a/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java b/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java
new file mode 100644
index 0000000000..91e03a628a
--- /dev/null
+++ b/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java
@@ -0,0 +1,97 @@
+package miscutil.core.xmod.gregtech.api.gui;
+
+
+import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+import java.util.List;
+
+import miscutil.core.lib.CORE;
+import miscutil.core.util.Utils;
+import net.minecraft.entity.player.InventoryPlayer;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * The GUI-Container I use for all my Basic Machines
+ * <p/>
+ * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class
+ */
+public class GUI_IndustrialCentrifuge extends GT_GUIContainerMetaTile_Machine {
+
+ String mName = "";
+ private Object tempStack;
+ private List itemSlots;
+ private short counter = 0;
+
+ public GUI_IndustrialCentrifuge(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) {
+ super(new CONTAINER_IndustrialCentrifuge(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile));
+ mName = aName;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ fontRendererObj.drawString(mName, 10, 8, 16448255);
+
+ if (mContainer != null) {
+ try {
+ counter++;
+ if (tempStack == null || counter > 200){
+ if (itemSlots == null){
+ itemSlots = ((CONTAINER_IndustrialCentrifuge) mContainer).inventorySlots;
+ }
+ if (itemSlots != null){
+ if (itemSlots.get(0) == null){
+ fontRendererObj.drawString("No Item in item slot.", 10, 48, 16448255);
+ }
+ else {
+ tempStack = itemSlots.get(0);
+ counter = 0;
+ }
+ }
+
+
+ }
+ if (tempStack != null){
+ fontRendererObj.drawString("Item in item slot.", 10, 48, 16448255);
+ }
+
+ }
+ catch (Throwable e){
+ Utils.LOG_INFO("NULL");
+ }
+
+ fontRendererObj.drawString("Debug Counter: "+counter, 10, 56, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 1) != 0)
+ fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 2) != 0)
+ fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 4) != 0)
+ fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 8) != 0)
+ fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 32) != 0)
+ fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255);
+ if ((((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode & 64) != 0)
+ fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255);
+
+ if (((CONTAINER_IndustrialCentrifuge) mContainer).mDisplayErrorCode == 0) {
+ if (((CONTAINER_IndustrialCentrifuge) mContainer).mActive == 0) {
+ fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255);
+ fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255);
+ fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255);
+ } else {
+ fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_MultiMachine.java b/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_MultiMachine.java
index 2fc2242a60..7501af3fce 100644
--- a/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_MultiMachine.java
+++ b/src/Java/miscutil/core/xmod/gregtech/api/gui/GUI_MultiMachine.java
@@ -1,5 +1,6 @@
package miscutil.core.xmod.gregtech.api.gui;
+
import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import miscutil.core.lib.CORE;
diff --git a/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java b/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java
index a6d197563a..aaccff4693 100644
--- a/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java
+++ b/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java
@@ -1,6 +1,5 @@
package miscutil.core.xmod.gregtech.common.tileentities.machines.multi;
-import static miscutil.core.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
@@ -13,23 +12,24 @@ import gregtech.api.util.GT_Utility;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import miscutil.core.block.ModBlocks;
import miscutil.core.util.Utils;
-import miscutil.core.xmod.gregtech.api.gui.GUI_MultiMachine;
+import miscutil.core.xmod.gregtech.api.gui.GUI_IndustrialCentrifuge;
import miscutil.core.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import miscutil.core.xmod.gregtech.api.objects.GregtechRenderedTexture;
-import miscutil.core.xmod.gregtech.api.util.GregtechRecipe;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
+import org.apache.commons.lang3.ArrayUtils;
+
public class GregtechMetaTileEntityIndustrialCentrifuge
extends GregtechMeta_MultiBlockBase {
private static boolean controller;
- private int mLevel = 2;
public GregtechMetaTileEntityIndustrialCentrifuge(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -71,12 +71,12 @@ extends GregtechMeta_MultiBlockBase {
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GregtechRenderedTexture(Textures.BlockIcons.LARGETURBINE_ACTIVE5) : new GregtechRenderedTexture(Textures.BlockIcons.LARGETURBINE5) : Textures.BlockIcons.CASING_BLOCKS[1]};
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GregtechRenderedTexture(Textures.BlockIcons.LARGETURBINE_ACTIVE5) : new GregtechRenderedTexture(Textures.BlockIcons.LARGETURBINE5) : Textures.BlockIcons.CASING_BLOCKS[57]};
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png");
+ return new GUI_IndustrialCentrifuge(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png");
}
@Override
@@ -84,11 +84,6 @@ extends GregtechMeta_MultiBlockBase {
return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes;
}
- /*@Override
- public boolean isCorrectMachinePart(ItemStack aStack) {
- return true;
- }*/
-
@Override
public boolean isFacingValid(byte aFacing) {
return aFacing > 1;
@@ -97,10 +92,12 @@ extends GregtechMeta_MultiBlockBase {
ArrayList<ItemStack> tInputList = getStoredInputs();
GT_Recipe mLastRecipe;
-
@Override
public boolean checkRecipe(ItemStack aStack) {
- ArrayList<ItemStack> tInputList = getStoredInputs();
+ long tVoltage = getMaxInputVoltage();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+
+ GT_Recipe.GT_Recipe_Map map = getRecipeMap();
for (int i = 0; i < tInputList.size() - 1; i++) {
for (int j = i + 1; j < tInputList.size(); j++) {
if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) {
@@ -129,11 +126,27 @@ extends GregtechMeta_MultiBlockBase {
}
}
FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1);
- if (tInputList.size() > 0) {
- long tVoltage = getMaxInputVoltage();
- byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
- GT_Recipe tRecipe = GregtechRecipe.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
- if ((tRecipe != null) && (this.mLevel >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) {
+ if (tInputList.size() > 0 || tFluids.length > 0) {
+ GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
+ if (tRecipe != null) {
+ if (tRecipe.mFluidInputs != null) {
+
+ }
+ mLastRecipe = tRecipe;
+ this.mEUt = 0;
+ this.mOutputItems = null;
+ this.mOutputFluids = null;
+ int machines = Math.min(16, mInventory[1].stackSize);
+ int i = 0;
+ for (; i < machines; i++) {
+ if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) {
+ if (i == 0) {
+ return false;
+ }
+ break;
+ }
+ }
+ this.mMaxProgresstime = tRecipe.mDuration;
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
if (tRecipe.mEUt <= 16) {
@@ -144,15 +157,56 @@ extends GregtechMeta_MultiBlockBase {
this.mMaxProgresstime = tRecipe.mDuration;
while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
this.mEUt *= 4;
- this.mMaxProgresstime /= 2;
+ this.mMaxProgresstime /= 4;
}
}
+ this.mEUt *= i;
if (this.mEUt > 0) {
this.mEUt = (-this.mEUt);
}
+ ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length];
+ for (int h = 0; h < tRecipe.mOutputs.length; h++) {
+ tOut[h] = tRecipe.getOutput(h).copy();
+ tOut[h].stackSize = 0;
+ }
+ FluidStack tFOut = null;
+ if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy();
+ for (int f = 0; f < tOut.length; f++) {
+ if (tRecipe.mOutputs[f] != null && tOut[f] != null) {
+ for (int g = 0; g < i; g++) {
+ if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f))
+ tOut[f].stackSize += tRecipe.mOutputs[f].stackSize;
+ }
+ }
+ }
+ if (tFOut != null) {
+ int tSize = tFOut.amount;
+ tFOut.amount = tSize * i;
+ }
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)};
- this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
+ List<ItemStack> overStacks = new ArrayList<ItemStack>();
+ for (int f = 0; f < tOut.length; f++) {
+ if (tOut[f].getMaxStackSize() < tOut[f].stackSize) {
+ while (tOut[f].getMaxStackSize() < tOut[f].stackSize) {
+ ItemStack tmp = tOut[f].copy();
+ tmp.stackSize = tmp.getMaxStackSize();
+ tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize();
+ overStacks.add(tmp);
+ }
+ }
+ }
+ if (overStacks.size() > 0) {
+ ItemStack[] tmp = new ItemStack[overStacks.size()];
+ tmp = overStacks.toArray(tmp);
+ tOut = ArrayUtils.addAll(tOut, tmp);
+ }
+ List<ItemStack> tSList = new ArrayList<ItemStack>();
+ for (ItemStack tS : tOut) {
+ if (tS.stackSize > 0) tSList.add(tS);
+ }
+ tOut = tSList.toArray(new ItemStack[tSList.size()]);
+ this.mOutputItems = tOut;
+ this.mOutputFluids = new FluidStack[]{tFOut};
updateSlots();
return true;
}
@@ -192,13 +246,13 @@ extends GregtechMeta_MultiBlockBase {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
//Utils.LOG_INFO("X:"+tTileEntity.getXCoord()+" Y:"+tTileEntity.getYCoord()+" Z:"+tTileEntity.getZCoord());
- if ((!addMaintenanceToMachineList(tTileEntity, GTID+0)) && (!addInputToMachineList(tTileEntity, GTID+0)) && (!addOutputToMachineList(tTileEntity, GTID+0)) && (!addEnergyInputToMachineList(tTileEntity, GTID+0))) {
+ if ((!addMaintenanceToMachineList(tTileEntity, 57)) && (!addInputToMachineList(tTileEntity, 57)) && (!addOutputToMachineList(tTileEntity, 57)) && (!addEnergyInputToMachineList(tTileEntity, 57))) {
//Maintenance Hatch
if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) {
if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() && tTileEntity.getZCoord() == (aBaseMetaTileEntity.getZCoord()+2)) {
if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) {
- //Utils.LOG_INFO("MAINT HATCH IN CORRECT PLACE");
+ Utils.LOG_INFO("MAINT HATCH IN CORRECT PLACE");
this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity());
((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex();
} else {
@@ -206,7 +260,7 @@ extends GregtechMeta_MultiBlockBase {
}
}
else {
- //Utils.LOG_INFO("MAINT HATCH IN WRONG PLACE");
+ Utils.LOG_INFO("MAINT HATCH IN WRONG PLACE");
}
}
@@ -244,14 +298,9 @@ extends GregtechMeta_MultiBlockBase {
return 0;
}
- /*@Override
- public int getDamageToComponent(ItemStack aStack) {
- return 0;
- }*/
-
@Override
public int getAmountOfOutputs() {
- return 2;
+ return 1;
}
@Override
@@ -329,9 +378,4 @@ extends GregtechMeta_MultiBlockBase {
return false;
}
-
- /*@Override
- public boolean isCorrectMachinePart(ItemStack aStack) {
- return true;
- }*/
} \ No newline at end of file