Worked on that GUI, I think I've got down how this is gonna work

This commit is contained in:
Aidan Brady 2013-10-26 00:02:57 -04:00
parent 8bb6b7ac43
commit 51f24f058a
19 changed files with 194 additions and 78 deletions

View file

@ -351,7 +351,7 @@ public class ClientProxy extends CommonProxy
case 25:
return new GuiRobitRepair(player.inventory, world, x);
case 26:
return new GuiLogisticalSorter(player.inventory, (TileEntityLogisticalSorter)tileEntity);
return new GuiLogisticalSorter(player, (TileEntityLogisticalSorter)tileEntity);
}
return null;

View file

@ -16,16 +16,16 @@ public abstract class GuiElement
protected ResourceLocation RESOURCE;
public GuiContainer guiContainer;
public GuiScreen guiObj;
public TileEntity tileEntity;
public ResourceLocation defaultLocation;
public GuiElement(ResourceLocation resource, GuiContainer gui, TileEntity tile, ResourceLocation def)
public GuiElement(ResourceLocation resource, GuiScreen gui, TileEntity tile, ResourceLocation def)
{
RESOURCE = resource;
guiContainer = gui;
guiObj = gui;
tileEntity = tile;
defaultLocation = def;
}
@ -35,26 +35,32 @@ public abstract class GuiElement
try {
Method m = GuiContainer.class.getDeclaredMethod("drawCreativeTabHoveringText", String.class, Integer.TYPE, Integer.TYPE);
m.setAccessible(true);
m.invoke(guiContainer, s, xAxis, yAxis);
m.invoke(guiObj, s, xAxis, yAxis);
} catch(Exception e) {}
}
protected void offsetX(int xSize)
{
try {
Field f = GuiContainer.class.getDeclaredField("xSize");
f.setAccessible(true);
f.set(guiContainer, ((Integer)f.get(guiContainer))+xSize);
} catch(Exception e) {}
if(guiObj instanceof GuiContainer)
{
try {
Field f = GuiContainer.class.getDeclaredField("xSize");
f.setAccessible(true);
f.set(guiObj, ((Integer)f.get(guiObj))+xSize);
} catch(Exception e) {}
}
}
protected void offsetY(int ySize)
{
try {
Field f = GuiContainer.class.getDeclaredField("ySize");
f.setAccessible(true);
f.set(guiContainer, ((Integer)f.get(guiContainer))+ySize);
} catch(Exception e) {}
if(guiObj instanceof GuiContainer)
{
try {
Field f = GuiContainer.class.getDeclaredField("ySize");
f.setAccessible(true);
f.set(guiObj, ((Integer)f.get(guiObj))+ySize);
} catch(Exception e) {}
}
}
protected FontRenderer getFontRenderer()
@ -62,7 +68,7 @@ public abstract class GuiElement
try {
Field f = GuiScreen.class.getDeclaredField("fontRenderer");
f.setAccessible(true);
return (FontRenderer)f.get(guiContainer);
return (FontRenderer)f.get(guiObj);
} catch(Exception e) {}
return null;

View file

@ -0,0 +1,5 @@
package mekanism.client.gui;
public class GuiItemStackFilter {
}

View file

@ -1,11 +1,11 @@
package mekanism.client.gui;
import mekanism.common.inventory.container.ContainerItemStackFilter;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import org.lwjgl.opengl.GL11;
@ -17,25 +17,59 @@ public class GuiLogisticalSorter extends GuiMekanism
{
public TileEntityLogisticalSorter tileEntity;
public GuiLogisticalSorter(InventoryPlayer inventory, TileEntityLogisticalSorter tentity)
public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter tentity)
{
super(new ContainerItemStackFilter(inventory, tentity));
super(new ContainerNull(player, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png")));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
public boolean doesGuiPauseGame()
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
return false;
}
@Override
public void initGui()
{
super.initGui();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
buttonList.clear();
buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 54, 20, "ItemStack"));
buttonList.add(new GuiButton(1, guiWidth + 110, guiHeight + 136, 43, 20, "OreDict"));
}
@Override
protected void actionPerformed(GuiButton guibutton)
{
super.actionPerformed(guibutton);
if(guibutton.id == 0)
{
}
else if(guibutton.id == 1)
{
}
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString("Logistical Sorter", 43, 6, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
}
fontRenderer.drawString("Filters:", 11, 17, 0x00CD00);
fontRenderer.drawString("- " + tileEntity.filters.size(), 11, 26, 0x00CD00);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
@ -47,8 +81,5 @@ public class GuiLogisticalSorter extends GuiMekanism
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight;
}
}

View file

@ -0,0 +1,9 @@
package mekanism.client.gui;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import net.minecraft.client.gui.GuiScreen;
public class GuiOreDictFilter extends GuiScreen
{
public TileEntityLogisticalTransporter tileEntity;
}

View file

@ -19,12 +19,12 @@ public class GuiRecipeType extends GuiElement
{
mc.renderEngine.bindTexture(RESOURCE);
guiContainer.drawTexturedModalRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63);
guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63);
TileEntityFactory factory = (TileEntityFactory)tileEntity;
int displayInt = factory.getScaledRecipeProgress(15);
guiContainer.drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt);
guiObj.drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}

View file

@ -8,13 +8,13 @@ import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketRedstoneControl;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class GuiRedstoneControl extends GuiElement
{
public GuiRedstoneControl(GuiContainer gui, TileEntity tile, ResourceLocation def)
public GuiRedstoneControl(GuiScreen gui, TileEntity tile, ResourceLocation def)
{
super(MekanismUtils.getResource(ResourceType.GUI, "GuiRedstoneControl.png"), gui, tile, def);
}
@ -24,17 +24,17 @@ public class GuiRedstoneControl extends GuiElement
{
mc.renderEngine.bindTexture(RESOURCE);
guiContainer.drawTexturedModalRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26);
guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26);
IRedstoneControl control = (IRedstoneControl)tileEntity;
int renderX = 26 + (18*control.getControlType().ordinal());
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
{
guiContainer.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18);
guiObj.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18);
}
else {
guiContainer.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18);
guiObj.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18);
}
mc.renderEngine.bindTexture(defaultLocation);
@ -70,6 +70,7 @@ public class GuiRedstoneControl extends GuiElement
RedstoneControl current = control.getControlType();
int ordinalToSet = current.ordinal() < (RedstoneControl.values().length-1) ? current.ordinal()+1 : 0;
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
PacketHandler.sendPacket(Transmission.SERVER, new PacketRedstoneControl().setParams(Object3D.get(tileEntity), RedstoneControl.values()[ordinalToSet]));
}
}

View file

@ -23,12 +23,12 @@ public class GuiUpgradeManagement extends GuiElement
{
mc.renderEngine.bindTexture(RESOURCE);
guiContainer.drawTexturedModalRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63);
guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63);
IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
int displayInt = upgradeTile.getComponent().getScaledUpgradeProgress(14);
guiContainer.drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt);
guiObj.drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}

View file

@ -8,9 +8,10 @@ import mekanism.common.inventory.container.ContainerElectricMachine;
import mekanism.common.inventory.container.ContainerElectricPump;
import mekanism.common.inventory.container.ContainerEnergyCube;
import mekanism.common.inventory.container.ContainerFactory;
import mekanism.common.inventory.container.ContainerFilter;
import mekanism.common.inventory.container.ContainerGasTank;
import mekanism.common.inventory.container.ContainerItemStackFilter;
import mekanism.common.inventory.container.ContainerMetallurgicInfuser;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.inventory.container.ContainerRobitCrafting;
import mekanism.common.inventory.container.ContainerRobitInventory;
import mekanism.common.inventory.container.ContainerRobitMain;
@ -21,6 +22,7 @@ import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityContainerBlock;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
@ -33,7 +35,6 @@ import mekanism.common.tileentity.TileEntityEnergyCube;
import mekanism.common.tileentity.TileEntityEnrichmentChamber;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityMetallurgicInfuser;
@ -283,7 +284,11 @@ public class CommonProxy
case 25:
return new ContainerRobitRepair(player.inventory, world);
case 26:
return new ContainerItemStackFilter(player.inventory, (TileEntityLogisticalSorter)tileEntity);
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
case 27:
return new ContainerFilter(player.inventory);
case 28:
return new ContainerFilter(player.inventory);
}
return null;

View file

@ -59,6 +59,7 @@ import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketDigitUpdate;
import mekanism.common.network.PacketElectricBowState;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketLogisticalSorterGui;
import mekanism.common.network.PacketPortableTeleport;
import mekanism.common.network.PacketPortalFX;
import mekanism.common.network.PacketRedstoneControl;
@ -1136,6 +1137,7 @@ public class Mekanism
PacketHandler.registerPacket(PacketRemoveUpgrade.class);
PacketHandler.registerPacket(PacketRedstoneControl.class);
PacketHandler.registerPacket(PacketWalkieTalkieState.class);
PacketHandler.registerPacket(PacketLogisticalSorterGui.class);
//Donators
donators.add("mrgreaper");

View file

@ -21,6 +21,7 @@ import mekanism.common.PacketHandler.Transmission;
import mekanism.common.Tier;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.network.PacketLogisticalSorterGui;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBasicBlock;
import mekanism.common.tileentity.TileEntityChargepad;
@ -829,6 +830,19 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
int metadata = world.getBlockMetadata(x, y, z);
if(metadata != MachineType.CHARGEPAD.meta)
{
return true;
}
return false;
}
public static enum MachineType
{
ENRICHMENT_CHAMBER(0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false),

View file

@ -1,24 +1,19 @@
package mekanism.common.inventory.container;
import mekanism.api.gas.EnumGas;
import mekanism.common.inventory.slot.SlotStorageTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.util.ChargeUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerItemStackFilter extends Container
public class ContainerFilter extends Container
{
private TileEntityLogisticalSorter tileEntity;
public ContainerItemStackFilter(InventoryPlayer inventory, TileEntityLogisticalSorter tentity)
{
tileEntity = tentity;
addSlotToContainer(new Slot(tentity, 0, 8, 8));
int slotX;
public ContainerFilter(InventoryPlayer inventory)
{
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
{
@ -32,23 +27,18 @@ public class ContainerItemStackFilter extends Container
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
}
@Override
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
return true;
}
@Override
@ -62,7 +52,26 @@ public class ContainerItemStackFilter extends Container
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
//TODO
if(slotID >= 0 && slotID <= 26)
{
if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 26)
{
if(!mergeItemStack(slotStack, 0, 26, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true))
{
return null;
}
}
if(slotStack.stackSize == 0)
{

View file

@ -0,0 +1,33 @@
package mekanism.common.inventory.container;
import mekanism.common.tileentity.TileEntityContainerBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
public class ContainerNull extends Container
{
private TileEntityContainerBlock tileEntity;
public ContainerNull(EntityPlayer player, TileEntityContainerBlock tile)
{
tileEntity = tile;
tileEntity.openChest();
tileEntity.playersUsing.add(player);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return true;
}
}

View file

@ -1,14 +1,10 @@
package mekanism.common.network;
import java.io.DataOutputStream;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.common.ITileNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -21,7 +17,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
{
public Object3D object3D;
public int filterIndex;
public int type;
@Override
public String getName()
@ -33,7 +29,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
public IMekanismPacket setParams(Object... data)
{
object3D = (Object3D)data[0];
filterIndex = (Integer)data[1];
type = (Integer)data[1];
return this;
}
@ -47,7 +43,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
int id = dataStream.readInt();
int index = dataStream.readInt();
int type = dataStream.readInt();
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(id);
@ -55,12 +51,14 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
{
TileEntity tileEntity = worldServer.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityLogisticalSorter)
if(type == 0)
{
((TileEntityDynamicTank)tileEntity).sendStructure = true;
player.openGui(Mekanism.instance, 27, worldServer, x, y, z);
}
else if(type == 1)
{
player.openGui(Mekanism.instance, 28, worldServer, x, y, z);
}
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(worldServer.getBlockTileEntity(x, y, z)), ((ITileNetwork)worldServer.getBlockTileEntity(x, y, z)).getNetworkedData(new ArrayList())));
}
}
@ -73,6 +71,6 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
dataStream.writeInt(object3D.dimensionId);
dataStream.writeInt(filterIndex);
dataStream.writeInt(type);
}
}

View file

@ -89,6 +89,9 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
inventory.setInventorySlotContents(inInventory.slotID, null);
setActive(true);
}
else {
inventory.setInventorySlotContents(inInventory.slotID, inInventory.itemStack);
}
}
delayTicks = 10;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB