aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/api
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-14 20:22:34 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-14 20:22:34 +0000
commitf6599e799922840f2e5c94d2c0b638357e75e5cd (patch)
tree7627ab7fd0267cc26a8e36e74bf92f9493f933e8 /src/main/java/gtPlusPlus/xmod/gregtech/api
parent87b3fdb080ad0409d9593e09f4206e5d70c78756 (diff)
downloadGT5-Unofficial-f6599e799922840f2e5c94d2c0b638357e75e5cd.tar.gz
GT5-Unofficial-f6599e799922840f2e5c94d2c0b638357e75e5cd.tar.bz2
GT5-Unofficial-f6599e799922840f2e5c94d2c0b638357e75e5cd.zip
Fix Computer Cube GUI.
Fix Glod's shitty implementation of perfect OC which broke some multis.
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java76
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java29
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java40
3 files changed, 87 insertions, 58 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java
index 477bcef092..80202695e7 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java
@@ -9,11 +9,12 @@ import gregtech.api.gui.GT_Slot_Holo;
import gregtech.api.gui.GT_Slot_Output;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.GT_ModHandler;
import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -23,7 +24,9 @@ import net.minecraft.item.ItemStack;
public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
- public int mEUOut;
+ public long mEUOut;
+ public int mEUOut1;
+ public int mEUOut2;
public int mHeat;
@@ -33,7 +36,9 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
public int mExplosionStrength;
- public int mEU;
+ public long mEU;
+ public int mEU1;
+ public int mEU2;
public int mProgress;
@@ -41,6 +46,10 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) {
super(aInventoryPlayer, aTileEntity);
+ Logger.INFO("1 Container Mode: "+aID);
+ Logger.INFO("2 Container Mode: "+getMode());
+ mID = getMode();
+ Logger.INFO("3 Container Mode: "+getMode());
// addSlotsComputer(aInventoryPlayer);
detectAndSendChanges();
}
@@ -56,7 +65,7 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
public void addSlotsComputer(InventoryPlayer aInventoryPlayer) {
int y;
mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode;
- Logger.INFO("Mode: " + mID);
+ Logger.INFO(""+(Utils.isClient() ? "Client" : "Server")+" Mode: " + mID);
addSlotToContainer(new GT_Slot_Holo((IInventory) this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1));
switch (this.mID) {
case 1 :
@@ -142,24 +151,24 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
}
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
- Logger.INFO("Clicked slot " + aSlotIndex);
+ //Logger.INFO("Clicked slot " + aSlotIndex);
if (aSlotIndex < 0) {
- Logger.INFO("");
+ //Logger.INFO("");
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) {
- Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode);
+ //Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode);
return null;
}
Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex);
if (tSlot == null) {
- Logger.INFO("Null Slot?");
+ //Logger.INFO("Null Slot?");
}
else {
ItemStack tStack = tSlot.getStack();
- Logger.INFO("Good Slot!");
+ //Logger.INFO("Good Slot!");
if (aSlotIndex == 0) {
- Logger.INFO("Slot is 0");
+ //Logger.INFO("Slot is 0");
if (aMouseclick == 0) {
Logger.INFO("Forward");
((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward();
@@ -168,7 +177,12 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
Logger.INFO("Backwards");
((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward();
}
- aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord());
+ if (aPlayer instanceof EntityPlayerMP) {
+ EntityPlayerMP aPlayerMP = (EntityPlayerMP) aPlayer;
+ changePage(aPlayerMP, ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode);
+ }
+ //FMLNetworkHandler.openGui(entityPlayer, mod, modGuiId, world, x, y, z);
+ //aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord());
}
else if (aSlotIndex <= 2 && this.mID == 3) {
if (aSlotIndex == 1) {
@@ -269,14 +283,21 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
}
}
else {
- Logger.INFO("Super 2");
+ //Logger.INFO("Super 2");
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
}
- Logger.INFO("???");
+ //Logger.INFO("???");
return null;
}
+
+
+ public void changePage(EntityPlayerMP aPlayerMP, int aMode) {
+ GT_TileEntity_ComputerCube aCompTile = (GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity();
+ aCompTile.onRightclick(mTileEntity, aPlayerMP);
+ }
+
public boolean doesBindPlayerInventory() {
return (this.mID != 1 && this.mID != 5);
}
@@ -288,26 +309,33 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
}
this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode;
this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut;
+ int[] aEUSplit1 = MathUtils.splitLongIntoTwoIntegers(mEUOut);
+ this.mEUOut1 = aEUSplit1[0];
+ this.mEUOut2 = aEUSplit1[1];
this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat;
this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat;
this.mHEM = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F);
this.mExplosionStrength = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F);
this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU;
this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress;
+ int[] aEUSplit2 = MathUtils.splitLongIntoTwoIntegers(mEU);
+ this.mEU1 = aEUSplit2[0];
+ this.mEU2 = aEUSplit2[1];
Iterator<ICrafting> var2 = this.crafters.iterator();
while (var2.hasNext()) {
ICrafting var1 = var2.next();
- var1.sendProgressBarUpdate((Container) this, 101, this.mEUOut);
+ var1.sendProgressBarUpdate((Container) this, 101, this.mID);
var1.sendProgressBarUpdate((Container) this, 102, this.mHeat & 0xFFFF);
var1.sendProgressBarUpdate((Container) this, 103, this.mMaxHeat & 0xFFFF);
var1.sendProgressBarUpdate((Container) this, 104, this.mHEM);
var1.sendProgressBarUpdate((Container) this, 105, this.mExplosionStrength);
var1.sendProgressBarUpdate((Container) this, 106, this.mHeat >>> 16);
var1.sendProgressBarUpdate((Container) this, 107, this.mMaxHeat >>> 16);
- var1.sendProgressBarUpdate((Container) this, 108, this.mEU & 0xFFFF);
- var1.sendProgressBarUpdate((Container) this, 109, this.mEU >>> 16);
+ var1.sendProgressBarUpdate((Container) this, 108, this.mEU1);
+ var1.sendProgressBarUpdate((Container) this, 109, this.mEU2);
var1.sendProgressBarUpdate((Container) this, 110, this.mProgress);
- var1.sendProgressBarUpdate((Container) this, 111, this.mID);
+ var1.sendProgressBarUpdate((Container) this, 111, this.mEUOut1);
+ var1.sendProgressBarUpdate((Container) this, 112, this.mEUOut2);
}
}
@@ -316,7 +344,7 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
super.updateProgressBar(par1, par2);
switch (par1) {
case 101 :
- this.mEUOut = par2;
+ this.mID = par2;
break;
case 102 :
this.mHeat = this.mHeat & 0xFFFF0000 | par2;
@@ -337,15 +365,19 @@ public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine {
this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16;
break;
case 108 :
- this.mEU = this.mEU & 0xFFFF0000 | par2;
+ this.mEU1 = par2;
case 109 :
- this.mEU = this.mEU & 0xFFFF | par2 << 16;
+ this.mEU2 = par2;
+ this.mEU = MathUtils.combineTwoIntegersToLong(mEU1, mEU2);
break;
case 110 :
this.mProgress = par2;
break;
case 111 :
- this.mID = par2;
+ this.mEUOut1 = par2;
+ case 112 :
+ this.mEUOut2 = par2;
+ this.mEUOut = MathUtils.combineTwoIntegersToLong(mEUOut1, mEUOut2);
break;
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java
index 47795f4510..c56e167319 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java
@@ -3,8 +3,9 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer;
import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription;
+import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
@@ -12,8 +13,12 @@ import net.minecraft.util.StatCollector;
public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machine {
public GT_GUIContainer_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) {
super(new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), CORE.RES_PATH_GUI + "computer/"+aID+".png");
- if (aID == 5)
+ GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer;
+ Logger.INFO("1 GUI Mode: "+aID);
+ Logger.INFO("2 GUI Mode: "+tContainer.mID);
+ if (tContainer.mID == 5) {
this.xSize += 50;
+ }
}
@@ -33,6 +38,7 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer;
+ //Logger.INFO("3 GUI Mode: "+xSize);
//GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity;
if (tContainer != null)
switch (tContainer.mID) {
@@ -78,13 +84,16 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin
this.fontRendererObj.drawString("OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255);
break;
case 5 :
- if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_ComputercubeDescription.sDescriptions.size())
- for (int i = 0; i < ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) {
+ if (tContainer.mID == 5 && this.xSize == 176) {
+ this.xSize += 50;
+ }
+ if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_Computercube_Description.sDescriptions.size())
+ for (int i = 0; i < ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) {
if (i == 0) {
- this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255);
+ this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255);
}
else {
- this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7
+ this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7
+ 8 * i, 16448255);
}
}
@@ -113,16 +122,16 @@ public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machin
}
}
- public String toNumber(int aNumber) {
+ public String toNumber(long mEU) {
String tString = "";
boolean temp = true, negative = false;
- if (aNumber < 0) {
- aNumber *= -1;
+ if (mEU < 0) {
+ mEU *= -1;
negative = true;
}
int i;
for (i = 1000000000; i > 0; i /= 10) {
- int tDigit = aNumber / i % 10;
+ long tDigit = mEU / i % 10;
if (temp && tDigit != 0)
temp = false;
if (!temp) {
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index ec7115cb0f..1232166baa 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -753,26 +753,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll);
}
- public boolean checkRecipeGeneric(GT_Recipe aRecipe,
- int aMaxParallelRecipes, int aEUPercent,
- int aSpeedBonusPercent, int aOutputChanceRoll, boolean isPerfectOC) {
- if (aRecipe == null) {
- return false;
- }
- ArrayList<ItemStack> tItems = getStoredInputs();
- ArrayList<FluidStack> tFluids = getStoredFluids();
- ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]);
- FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]);
- return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, isPerfectOC);
- }
-
- public boolean checkRecipeGeneric(
- ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
- int aMaxParallelRecipes, int aEUPercent,
- int aSpeedBonusPercent, int aOutputChanceRoll) {
- return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, false);
- }
-
public boolean checkRecipeGeneric(GT_Recipe aRecipe,
int aMaxParallelRecipes, int aEUPercent,
int aSpeedBonusPercent, int aOutputChanceRoll) {
@@ -783,14 +763,14 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
ArrayList<FluidStack> tFluids = getStoredFluids();
ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]);
FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]);
- return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, false);
+ return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe);
}
public boolean checkRecipeGeneric(
ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
int aMaxParallelRecipes, int aEUPercent,
- int aSpeedBonusPercent, int aOutputChanceRoll, boolean isPerfectOC) {
- return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, isPerfectOC);
+ int aSpeedBonusPercent, int aOutputChanceRoll) {
+ return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null);
}
@@ -941,10 +921,14 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
return rEnergy;
}
+ public boolean hasPerfectOverclock() {
+ return false;
+ }
+
public boolean checkRecipeGeneric(
ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
int aMaxParallelRecipes, int aEUPercent,
- int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) {
+ int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) {
// Based on the Processing Array. A bit overkill, but very flexible.
// Reset outputs and progress stats
@@ -1069,8 +1053,12 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
} else {
while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
this.mEUt *= 4;
- if (isPerpectOC) this.mMaxProgresstime /= 4;
- else this.mMaxProgresstime /= 2;
+ if (hasPerfectOverclock()) {
+ this.mMaxProgresstime /= 4;
+ }
+ else {
+ this.mMaxProgresstime /= 2;
+ }
}
}