Added GUI classes for the Item Distributor, fixed EU IO logic
This commit is contained in:
parent
b9f8927b3d
commit
baa04cc51b
4 changed files with 102 additions and 6 deletions
|
@ -0,0 +1,77 @@
|
|||
package gregtech.common.gui;
|
||||
|
||||
import gregtech.api.gui.GT_ContainerMetaTile_Machine;
|
||||
import gregtech.api.gui.GT_Slot_Holo;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import gregtech.common.tileentities.automation.GT_MetaTileEntity_ItemDistributor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GT_Container_ItemDistributor
|
||||
extends GT_ContainerMetaTile_Machine {
|
||||
public GT_Container_ItemDistributor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
|
||||
super(aInventoryPlayer, aTileEntity);
|
||||
}
|
||||
|
||||
public void addSlots(InventoryPlayer aInventoryPlayer) {
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(this.mTileEntity, x + y * 9, 8 + x * 18, 5 + y * 18));
|
||||
}
|
||||
}
|
||||
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1));
|
||||
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1));
|
||||
addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1));
|
||||
}
|
||||
|
||||
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
|
||||
if (aSlotIndex < 27) {
|
||||
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
|
||||
}
|
||||
Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex);
|
||||
if (tSlot != null) {
|
||||
if (this.mTileEntity.getMetaTileEntity() == null) {
|
||||
return null;
|
||||
}
|
||||
if (aSlotIndex == 27) {
|
||||
((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput);
|
||||
if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput) {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("116","Emit Energy to Outputside"));
|
||||
} else {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("117","Don't emit Energy"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (aSlotIndex == 28) {
|
||||
((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull);
|
||||
if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("118","Emit Redstone if no Slot is free"));
|
||||
} else {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("119","Don't emit Redstone"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (aSlotIndex == 29) {
|
||||
((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert = (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert);
|
||||
if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert) {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("120","Invert Redstone"));
|
||||
} else {
|
||||
GT_Utility.sendChatToPlayer(aPlayer, trans("121","Don't invert Redstone"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
|
||||
}
|
||||
|
||||
public int getSlotCount() {
|
||||
return 27;
|
||||
}
|
||||
|
||||
public int getShiftClickSlotCount() {
|
||||
return 27;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package gregtech.common.gui;
|
||||
|
||||
import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GT_GUIContainer_ItemDistributor
|
||||
extends GT_GUIContainerMetaTile_Machine {
|
||||
public GT_GUIContainer_ItemDistributor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
|
||||
super(new GT_Container_ItemDistributor(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/ItemDistributor.png");
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
|||
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Buffer;
|
||||
import gregtech.api.objects.GT_RenderedTexture;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import gregtech.common.gui.GT_Container_ChestBuffer;
|
||||
import gregtech.common.gui.GT_GUIContainer_ChestBuffer;
|
||||
import gregtech.common.gui.GT_Container_ItemDistributor;
|
||||
import gregtech.common.gui.GT_GUIContainer_ItemDistributor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -58,7 +58,7 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
|
|||
}
|
||||
|
||||
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||
return new GT_GUIContainer_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity);
|
||||
return new GT_GUIContainer_ItemDistributor(aPlayerInventory, aBaseMetaTileEntity);
|
||||
}
|
||||
|
||||
public ITexture getOverlayIcon() {
|
||||
|
@ -66,7 +66,7 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
|
|||
}
|
||||
|
||||
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||
return new GT_Container_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity);
|
||||
return new GT_Container_ItemDistributor(aPlayerInventory, aBaseMetaTileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,12 +96,12 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
|
|||
|
||||
@Override
|
||||
public boolean isInputFacing(byte aSide) {
|
||||
return getBaseMetaTileEntity().getFrontFacing() == aSide;
|
||||
return getBaseMetaTileEntity().getFrontFacing() == aSide || itemsPerSide[aSide] == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputFacing(byte aSide) {
|
||||
return getBaseMetaTileEntity().getFrontFacing() != aSide;
|
||||
return getBaseMetaTileEntity().getFrontFacing() != aSide && itemsPerSide[aSide] > 0;
|
||||
}
|
||||
|
||||
public boolean isValidSlot(int aIndex) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
Loading…
Reference in a new issue