Add disable sort option for input bus. Default behavior will stay same
This commit is contained in:
parent
cd841ad39e
commit
eaa93a0a75
1 changed files with 45 additions and 8 deletions
|
@ -6,24 +6,29 @@ import gregtech.api.interfaces.ITexture;
|
||||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
import gregtech.api.metatileentity.MetaTileEntity;
|
import gregtech.api.metatileentity.MetaTileEntity;
|
||||||
import gregtech.api.objects.GT_RenderedTexture;
|
import gregtech.api.objects.GT_RenderedTexture;
|
||||||
|
import gregtech.api.util.GT_LanguageManager;
|
||||||
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
|
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
|
public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
|
||||||
public GT_Recipe_Map mRecipeMap = null;
|
public GT_Recipe_Map mRecipeMap = null;
|
||||||
|
public boolean disableSort;
|
||||||
|
|
||||||
public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) {
|
public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) {
|
||||||
super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Input for Multiblocks",
|
super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{
|
||||||
"Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")});
|
"Item Input for Multiblocks",
|
||||||
|
"Shift + right click with screwdriver to turn Sort mode on/off",
|
||||||
|
"Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")});
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
|
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
|
||||||
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
|
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
|
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
|
||||||
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
|
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
|
||||||
}
|
}
|
||||||
|
@ -114,11 +119,43 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillStacksIntoFirstSlots() {
|
protected void fillStacksIntoFirstSlots() {
|
||||||
for (int i = 0; i < mInventory.length; i++)
|
if (disableSort) {
|
||||||
for (int j = i + 1; j < mInventory.length; j++)
|
for (int i = 0; i < mInventory.length; i++)
|
||||||
if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) {
|
for (int j = i + 1; j < mInventory.length; j++)
|
||||||
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
|
if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j])))
|
||||||
}
|
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < mInventory.length; i++)
|
||||||
|
for (int j = i + 1; j < mInventory.length; j++)
|
||||||
|
if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j])))
|
||||||
|
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveNBTData(NBTTagCompound aNBT) {
|
||||||
|
super.saveNBTData(aNBT);
|
||||||
|
aNBT.setBoolean("disableSort", disableSort);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadNBTData(NBTTagCompound aNBT) {
|
||||||
|
super.loadNBTData(aNBT);
|
||||||
|
disableSort = aNBT.getBoolean("disableSort");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
|
||||||
|
if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
|
||||||
|
return;
|
||||||
|
if (aPlayer.isSneaking()) {
|
||||||
|
disableSort = !disableSort;
|
||||||
|
GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String trans(String aKey, String aEnglish) {
|
||||||
|
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue