diff options
Diffstat (limited to 'src/main/java')
4 files changed, 73 insertions, 16 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index d509e6afe3..30874b2897 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -33,7 +33,7 @@ import static gregtech.api.enums.GT_Values.*; * <p/> * I know this File causes some Errors, because of missing Main Functions, but if you just need to compile Stuff, then remove said erroreous Functions. */ -public class GT_Recipe { +public class GT_Recipe implements Comparable<GT_Recipe> { public static volatile int VERSION = 509; /** * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps. @@ -412,7 +412,27 @@ public class GT_Recipe { return true; } - + @Override + public int compareTo(GT_Recipe recipe) { + // first lowest tier recipes + // then fastest + // then with lowest special value + // then dry recipes + // then with fewer inputs + if (this.mEUt != recipe.mEUt) { + return this.mEUt - recipe.mEUt; + } else if (this.mDuration != recipe.mDuration) { + return this.mDuration - recipe.mDuration; + } else if (this.mSpecialValue != recipe.mSpecialValue) { + return this.mSpecialValue - recipe.mSpecialValue; + } else if (this.mFluidInputs.length != recipe.mFluidInputs.length) { + return this.mFluidInputs.length - recipe.mFluidInputs.length; + } else if (this.mInputs.length != recipe.mInputs.length) { + return this.mInputs.length - recipe.mInputs.length; + } + return 0; + } + public static class GT_Recipe_AssemblyLine{ public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>(); diff --git a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java index 3e8f9402ca..c9e51ecb81 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java @@ -36,6 +36,8 @@ public class GT_Container_Regulator addSlotToContainer(new Slot(this.mTileEntity, 7, 26, 42));
addSlotToContainer(new Slot(this.mTileEntity, 8, 44, 42));
+ addSlotToContainer(new Slot(this.mTileEntity, 19, 44, 63));
+
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 9, 64, 7, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 81, 7, false, true, 1));
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 11, 98, 7, false, true, 1));
@@ -60,7 +62,7 @@ public class GT_Container_Regulator }
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
- if (aSlotIndex < 9) {
+ if (aSlotIndex < 10) {
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex);
@@ -68,7 +70,7 @@ public class GT_Container_Regulator if (this.mTileEntity.getMetaTileEntity() == null) {
return null;
}
- if (aSlotIndex == 27) {
+ if (aSlotIndex == 28) {
((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput);
if (((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit Energy to Outputside");
@@ -77,7 +79,7 @@ public class GT_Container_Regulator }
return null;
}
- if ((aSlotIndex < 18)) {
+ if ((aSlotIndex < 19)) {
ItemStack tStack = aPlayer.inventory.getItemStack();
if (tStack != null) {
tSlot.putStack(GT_Utility.copy(new Object[]{tStack}));
@@ -96,8 +98,8 @@ public class GT_Container_Regulator }
return null;
}
- if ((aSlotIndex < 27)) {
- ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[(aSlotIndex - 18)] = Math.min(99, Math.max(0, ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[(aSlotIndex - 18)] + (aMouseclick == 0 ? -1 : 1) * (aShifthold == 0 ? 1 : 16)));
+ if ((aSlotIndex < 28)) {
+ ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[(aSlotIndex - 19)] = Math.min(99, Math.max(0, ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[(aSlotIndex - 19)] + (aMouseclick == 0 ? -1 : 1) * (aShifthold == 0 ? 1 : 16)));
return null;
}
}
@@ -156,10 +158,10 @@ public class GT_Container_Regulator }
public int getSlotCount() {
- return 9;
+ return 10;
}
public int getShiftClickSlotCount() {
- return 9;
+ return 10;
}
}
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java index 3a89b8c82e..04930ae54b 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java @@ -18,9 +18,10 @@ import java.util.Arrays; public class GT_MetaTileEntity_Regulator
extends GT_MetaTileEntity_Buffer {
public int[] mTargetSlots = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+ private boolean charge = false, decharge = false;
public GT_MetaTileEntity_Regulator(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, 19, "Regulating incoming Items");
+ super(aID, aName, aNameRegional, aTier, 20, "Regulating incoming Items");
}
public GT_MetaTileEntity_Regulator(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
@@ -36,7 +37,7 @@ public class GT_MetaTileEntity_Regulator }
public boolean isValidSlot(int aIndex) {
- return aIndex < 9;
+ return aIndex < 9 || aIndex == 19;
}
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
@@ -90,4 +91,33 @@ public class GT_MetaTileEntity_Regulator public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (GT_Utility.areStacksEqual(aStack, this.mInventory[(aIndex + 9)]));
}
+
+ @Override
+ public int rechargerSlotStartIndex() {
+ return 19;
+ }
+
+ @Override
+ public int dechargerSlotStartIndex() {
+ return 19;
+ }
+
+ @Override
+ public int rechargerSlotCount() {
+ return charge ? 1 : 0;
+ }
+
+ @Override
+ public int dechargerSlotCount() {
+ return decharge ? 1 : 0;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide()) {
+ charge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3;
+ decharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3;
+ }
+ }
}
diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index 247a7df4a6..71e458c634 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -29,8 +29,7 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.*;
import java.util.List;
public class GT_NEI_DefaultHandler
@@ -55,6 +54,12 @@ public class GT_NEI_DefaultHandler }
}
+ public List<GT_Recipe> getSortedRecipes() {
+ List<GT_Recipe> result = new ArrayList<>(this.mRecipeMap.mRecipeList);
+ Collections.sort(result);
+ return result;
+ }
+
public static void drawText(int aX, int aY, String aString, int aColor) {
Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor);
}
@@ -65,7 +70,7 @@ public class GT_NEI_DefaultHandler public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getOverlayIdentifier())) {
- for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) {
+ for (GT_Recipe tRecipe : getSortedRecipes()) {
if (!tRecipe.mHidden) {
this.arecipes.add(new CachedDefaultRecipe(tRecipe));
}
@@ -95,7 +100,7 @@ public class GT_NEI_DefaultHandler }
}
}
- for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) {
+ for (GT_Recipe tRecipe : getSortedRecipes()) {
if (!tRecipe.mHidden) {
CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe);
for (ItemStack tStack : tResults) {
@@ -129,7 +134,7 @@ public class GT_NEI_DefaultHandler }
}
}
- for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) {
+ for (GT_Recipe tRecipe : getSortedRecipes()) {
if (!tRecipe.mHidden) {
CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe);
for (ItemStack tStack : tInputs) {
|