Implemented Priority System for the item routing system. Lower numbers are looked at first.

This commit is contained in:
WayofTime 2016-02-22 21:19:22 -05:00
parent 2c49c49441
commit 7104138e2b
10 changed files with 97 additions and 10 deletions

View file

@ -7,7 +7,7 @@ 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.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -15,6 +15,7 @@ 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;
@SideOnly(Side.CLIENT)
public class GuiItemRoutingNode extends GuiContainer
@ -25,15 +26,28 @@ public class GuiItemRoutingNode extends GuiContainer
private GuiButton southButton;
private GuiButton westButton;
private GuiButton eastButton;
private GuiButton incrementButton;
private GuiButton decrementButton;
private TileEntity inventory;
private TileFilteredRoutingNode inventory;
public GuiItemRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode)
{
super(new ContainerItemRoutingNode(playerInventory, tileRoutingNode));
this.xSize = 176;
this.ySize = 169;
inventory = (TileEntity) tileRoutingNode;
inventory = (TileFilteredRoutingNode) tileRoutingNode;
}
private int getCurrentActiveSlotPriority()
{
EnumFacing direction = EnumFacing.getFront(inventory.currentActiveSlot);
if (direction != null)
{
return inventory.getPriority(direction);
}
return 0;
}
@Override
@ -47,6 +61,9 @@ public class GuiItemRoutingNode extends GuiContainer
this.buttonList.add(this.southButton = new GuiButton(3, (this.width - this.xSize) / 2 + 151, (this.height - this.ySize) / 2 + 50, 18, 18, "S"));
this.buttonList.add(this.westButton = new GuiButton(4, (this.width - this.xSize) / 2 + 133, (this.height - this.ySize) / 2 + 32, 18, 18, "W"));
this.buttonList.add(this.eastButton = new GuiButton(5, (this.width - this.xSize) / 2 + 151, (this.height - this.ySize) / 2 + 32, 18, 18, "E"));
this.buttonList.add(this.incrementButton = new GuiButton(6, (this.width - this.xSize) / 2 + 97, (this.height - this.ySize) / 2 + 14, 18, 17, "^"));
this.buttonList.add(this.decrementButton = new GuiButton(7, (this.width - this.xSize) / 2 + 97, (this.height - this.ySize) / 2 + 50, 18, 17, "v"));
disableDirectionalButton(inventory.currentActiveSlot);
}
/**
@ -59,14 +76,31 @@ public class GuiItemRoutingNode extends GuiContainer
if (button.enabled)
{
BloodMagicPacketHandler.INSTANCE.sendToServer(new ItemRouterButtonPacketProcessor(button.id, inventory.getPos(), inventory.getWorld()));
if (button.id < 6)
{
enableAllDirectionalButtons();
button.enabled = false;
}
}
}
private void enableAllDirectionalButtons()
{
for (GuiButton button : this.buttonList)
{
button.enabled = true;
}
}
private void disableDirectionalButton(int id)
{
this.buttonList.get(id).enabled = false;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
// this.fontRendererObj.drawString(TextHelper.localize("tile.BloodMagic.soulForge.name"), 8, 5, 4210752);
// this.fontRendererObj.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752);
this.fontRendererObj.drawString("" + getCurrentActiveSlotPriority(), 98 + 5, 33 + 4, 0xFFFFFF);
}
@Override