aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2022-01-15 01:39:57 +0800
committerGitHub <noreply@github.com>2022-01-14 18:39:57 +0100
commit77f926b06d21cdcf484e7e2e84db9becd1b549ab (patch)
tree4090d8c804a87be4b1e8c1339d3e7c2c25b2059c /src/main/java/gregtech/api/metatileentity
parent119de99ec6386aa413480e5dd6a3e815c9fe06f8 (diff)
downloadGT5-Unofficial-77f926b06d21cdcf484e7e2e84db9becd1b549ab.tar.gz
GT5-Unofficial-77f926b06d21cdcf484e7e2e84db9becd1b549ab.tar.bz2
GT5-Unofficial-77f926b06d21cdcf484e7e2e84db9becd1b549ab.zip
Add recipe filter block (#870)
* add recipe filter block * Add tooltip to recipe filter GUI & improve type filter UI interaction now you can click special slot in type filter UI to directly set the oreprefix based on the stack held on the cursor
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java
new file mode 100644
index 0000000000..f5d43faffc
--- /dev/null
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java
@@ -0,0 +1,67 @@
+package gregtech.api.metatileentity.implementations;
+
+import gregtech.api.gui.GT_Container_SpecialFilter;
+import gregtech.api.gui.GT_GUIContainer_SpecialFilter;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_Buffer {
+ public static final int BUFFER_SLOT_COUNT = 9;
+ public static final int SPECIAL_SLOT_INDEX = 9;
+ public boolean bNBTAllowed = false;
+ public boolean bInvertFilter = false;
+
+ public GT_MetaTileEntity_SpecialFilter(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) {
+ // 9 buffer slot, 1 representation slot, 1 holo slot. last seems not needed...
+ super(aID, aName, aNameRegional, aTier, 11, aDescription);
+ }
+
+ public GT_MetaTileEntity_SpecialFilter(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_SpecialFilter(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < 9;
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_SpecialFilter(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_SpecialFilter(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ public abstract void clickTypeIcon(boolean aRightClick, ItemStack aHandStack);
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("bInvertFilter", this.bInvertFilter);
+ aNBT.setBoolean("bNBTAllowed", this.bNBTAllowed);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ this.bInvertFilter = aNBT.getBoolean("bInvertFilter");
+ this.bNBTAllowed = aNBT.getBoolean("bNBTAllowed");
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && ((this.bNBTAllowed) || (!aStack.hasTagCompound())) && (this.isStackAllowed(aStack) != this.bInvertFilter);
+ }
+
+ protected abstract boolean isStackAllowed(ItemStack aStack);
+}