Further un-stupified the routing GUI.
This commit is contained in:
parent
413b150142
commit
3e7187610a
|
@ -1,21 +1,27 @@
|
|||
package WayofTime.bloodmagic.client.gui;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.client.CPacketCustomPayload;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.ItemRouterButtonPacketProcessor;
|
||||
import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode;
|
||||
import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiItemRoutingNode extends GuiContainer
|
||||
|
@ -29,7 +35,10 @@ public class GuiItemRoutingNode extends GuiContainer
|
|||
private GuiButton incrementButton;
|
||||
private GuiButton decrementButton;
|
||||
|
||||
private GuiTextField textBox;
|
||||
|
||||
private TileFilteredRoutingNode inventory;
|
||||
private ContainerItemRoutingNode container;
|
||||
|
||||
private int left, top;
|
||||
|
||||
|
@ -39,6 +48,7 @@ public class GuiItemRoutingNode extends GuiContainer
|
|||
this.xSize = 176;
|
||||
this.ySize = 169;
|
||||
inventory = (TileFilteredRoutingNode) tileRoutingNode;
|
||||
container = (ContainerItemRoutingNode) this.inventorySlots;
|
||||
}
|
||||
|
||||
private int getCurrentActiveSlotPriority()
|
||||
|
@ -69,6 +79,60 @@ public class GuiItemRoutingNode extends GuiContainer
|
|||
this.buttonList.add(this.incrementButton = new GuiButton(6, left + 97, top + 14, 18, 17, "^"));
|
||||
this.buttonList.add(this.decrementButton = new GuiButton(7, left + 97, top + 50, 18, 17, "v"));
|
||||
disableDirectionalButton(inventory.currentActiveSlot);
|
||||
|
||||
this.textBox = new GuiTextField(0, this.fontRendererObj, left + 9, top + 73, 103, 12);
|
||||
this.textBox.setEnableBackgroundDrawing(false);
|
||||
this.textBox.setText("Test");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException
|
||||
{
|
||||
if (this.textBox.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
// System.out.println(typedChar + ", " + keyCode);
|
||||
// this.renameItem();
|
||||
} else
|
||||
{
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void renameItem()
|
||||
{
|
||||
String s = this.textBox.getText();
|
||||
Slot slot = this.container.getSlot(1);
|
||||
|
||||
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
|
||||
{
|
||||
s = "";
|
||||
}
|
||||
|
||||
// this.container.updateItemName(s);
|
||||
this.mc.thePlayer.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
||||
*/
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.textBox.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
this.textBox.drawTextBox();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,19 +18,20 @@ import net.minecraft.item.ItemStack;
|
|||
public class ContainerItemRoutingNode extends Container
|
||||
{
|
||||
private final IInventory tileItemRoutingNode;
|
||||
private final ItemInventory itemInventory;
|
||||
// private final ItemInventory itemInventory;
|
||||
private int slotsOccupied;
|
||||
|
||||
private final TileFilteredRoutingNode inventory;
|
||||
|
||||
public int lastGhostSlotClicked = -1;
|
||||
|
||||
public ContainerItemRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileItemRoutingNode)
|
||||
{
|
||||
this.tileItemRoutingNode = tileItemRoutingNode;
|
||||
inventory = (TileFilteredRoutingNode) tileItemRoutingNode;
|
||||
|
||||
this.addSlotToContainer(new SlotItemFilter(this, tileItemRoutingNode, 0, 8, 33));
|
||||
ItemStack masterStack = tileItemRoutingNode.getStackInSlot(inventory.currentActiveSlot);
|
||||
itemInventory = new ItemInventory(masterStack, 9, "");
|
||||
ItemInventory itemInventory = inventory.itemInventory;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ public class ContainerItemRoutingNode extends Container
|
|||
|
||||
public void resetItemInventory(ItemStack masterStack)
|
||||
{
|
||||
itemInventory.initializeInventory(masterStack);
|
||||
inventory.itemInventory.initializeInventory(masterStack);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,6 +77,9 @@ public class ContainerItemRoutingNode extends Container
|
|||
|
||||
if (slot instanceof SlotGhostItem) //TODO: make the slot clicking work!
|
||||
{
|
||||
lastGhostSlotClicked = slot.getSlotIndex();
|
||||
// System.out.println(lastGhostSlotClicked);
|
||||
|
||||
if ((dragType == 0 || dragType == 1) && (clickTypeIn == ClickType.PICKUP || clickTypeIn == ClickType.QUICK_MOVE))
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
|
|
@ -7,12 +7,15 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
|
||||
public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedInventory
|
||||
{
|
||||
public int currentActiveSlot = 0;
|
||||
public int[] priorities = new int[6];
|
||||
|
||||
public ItemInventory itemInventory = new ItemInventory(null, 9, "");
|
||||
|
||||
public TileFilteredRoutingNode(int size, String name)
|
||||
{
|
||||
super(size, name);
|
||||
|
@ -63,6 +66,8 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemInventory = new ItemInventory(getStackInSlot(currentActiveSlot), 9, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,6 +83,7 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
public void swapFilters(int requestedSlot)
|
||||
{
|
||||
currentActiveSlot = requestedSlot;
|
||||
itemInventory.initializeInventory(getStackInSlot(currentActiveSlot));
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import WayofTime.bloodmagic.item.routing.IItemFilterProvider;
|
||||
import WayofTime.bloodmagic.routing.DefaultItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IInputItemRoutingNode;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class TileInputRoutingNode extends TileFilteredRoutingNode implements IInputItemRoutingNode
|
||||
{
|
||||
public TileInputRoutingNode()
|
||||
{
|
||||
super(7, "inputNode");
|
||||
super(6, "inputNode");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import WayofTime.bloodmagic.item.routing.IItemFilterProvider;
|
||||
import WayofTime.bloodmagic.routing.DefaultItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IOutputItemRoutingNode;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IOutputItemRoutingNode
|
||||
{
|
||||
public TileOutputRoutingNode()
|
||||
{
|
||||
super(7, "outputNode");
|
||||
super(6, "outputNode");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in a new issue