Work on EIM interface

This commit is contained in:
Aidan C. Brady 2015-03-03 13:16:58 -05:00
parent 562352d54c
commit 8d3dfc0c2c
15 changed files with 287 additions and 11 deletions

View file

@ -32,6 +32,7 @@ import mekanism.client.gui.GuiEntangledBlock;
import mekanism.client.gui.GuiFactory;
import mekanism.client.gui.GuiFluidicPlenisher;
import mekanism.client.gui.GuiGasTank;
import mekanism.client.gui.GuiInductionMatrix;
import mekanism.client.gui.GuiLaserAmplifier;
import mekanism.client.gui.GuiLaserTractorBeam;
import mekanism.client.gui.GuiMetallurgicInfuser;
@ -500,6 +501,8 @@ public class ClientProxy extends CommonProxy
return new GuiSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity);
case 48:
return new GuiAmbientAccumulator(player, (TileEntityAmbientAccumulator)tileEntity);
case 49:
return new GuiInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity);
}
return null;

View file

@ -0,0 +1,111 @@
package mekanism.client.gui;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.content.tank.TankUpdateProtocol;
import mekanism.common.inventory.container.ContainerInductionMatrix;
import mekanism.common.tile.TileEntityInductionCasing;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiInductionMatrix extends GuiMekanism
{
public TileEntityInductionCasing tileEntity;
public GuiInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tentity)
{
super(tentity, new ContainerInductionMatrix(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png")));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
/*fontRendererObj.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00);
fontRendererObj.drawString(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00);
if(tileEntity.structure.fluidStored != null)
{
fontRendererObj.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
}
if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}*/
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
/*if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0);
displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1);
}*/
}
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/)
{
if(fluid == null)
{
return;
}
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
int start = 0;
while(true)
{
int renderRemaining = 0;
if(scale > 16)
{
renderRemaining = 16;
scale -= 16;
}
else {
renderRemaining = scale;
scale = 0;
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
start+=16;
if(renderRemaining == 0 || scale == 0)
{
break;
}
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"));
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
}
}

View file

@ -31,6 +31,7 @@ import mekanism.common.inventory.container.ContainerFactory;
import mekanism.common.inventory.container.ContainerFilter;
import mekanism.common.inventory.container.ContainerFluidicPlenisher;
import mekanism.common.inventory.container.ContainerGasTank;
import mekanism.common.inventory.container.ContainerInductionMatrix;
import mekanism.common.inventory.container.ContainerLaserAmplifier;
import mekanism.common.inventory.container.ContainerLaserTractorBeam;
import mekanism.common.inventory.container.ContainerMetallurgicInfuser;
@ -481,6 +482,8 @@ public class CommonProxy
return new ContainerSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity);
case 48:
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
case 49:
return new ContainerInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity);
}
return null;

View file

@ -179,13 +179,15 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
//ctms[1][0] = new CTMData("ctm/SteamBoiler", this, Arrays.asList(1, 2)).registerIcons(register);
//ctms[2][0] = new CTMData("ctm/BoilerValve", this, Arrays.asList(2, 1)).registerIcons(register);
ctms[1][0] = new CTMData("ctm/InductionCasing", this, Arrays.asList(1, 2)).registerIcons(register);
ctms[2][0] = new CTMData("ctm/InductionPort", this, Arrays.asList(2, 1)).registerIcons(register);
ctms[2][0] = new CTMData("ctm/InductionPortInput", this, Arrays.asList(2, 1)).registerIcons(register);
ctms[2][1] = new CTMData("ctm/InductionPortOutput", this, Arrays.asList(2, 1)).registerIcons(register);
icons[0][0] = ctms[0][0].mainTextureData.icon;
//icons[1][0] = ctms[1][0].mainTextureData.icon;
//icons[2][0] = ctms[2][0].mainTextureData.icon;
icons[1][0] = ctms[1][0].mainTextureData.icon;
icons[2][0] = ctms[2][0].mainTextureData.icon;
icons[2][1] = ctms[2][1].mainTextureData.icon;
icons[3][0] = register.registerIcon("mekanism:InductionCellBasic");
icons[3][1] = register.registerIcon("mekanism:InductionCellAdvanced");
icons[3][2] = register.registerIcon("mekanism:InductionCellElite");
@ -243,12 +245,15 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
case BASIC_BLOCK_2:
switch(meta)
{
case 2:
TileEntityInductionPort tileEntity = (TileEntityInductionPort)world.getTileEntity(x, y, z);
return icons[meta][tileEntity.mode ? 1 : 0];
case 3:
TileEntityInductionCell tileEntity = (TileEntityInductionCell)world.getTileEntity(x, y, z);
return icons[meta][tileEntity.tier.ordinal()];
case 4:
TileEntityInductionProvider tileEntity1 = (TileEntityInductionProvider)world.getTileEntity(x, y, z);
TileEntityInductionCell tileEntity1 = (TileEntityInductionCell)world.getTileEntity(x, y, z);
return icons[meta][tileEntity1.tier.ordinal()];
case 4:
TileEntityInductionProvider tileEntity2 = (TileEntityInductionProvider)world.getTileEntity(x, y, z);
return icons[meta][tileEntity2.tier.ordinal()];
default:
return getIcon(side, meta);
}

View file

@ -2,7 +2,6 @@ package mekanism.common.inventory.container;
import mekanism.common.inventory.slot.SlotOutput;
import mekanism.common.tile.TileEntityDynamicTank;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@ -21,15 +20,15 @@ public class ContainerDynamicTank extends Container
addSlotToContainer(new SlotOutput(tentity, 1, 146, 51));
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; ++slotY)
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
for(slotX = 0; slotX < 9; slotX++)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
@ -81,7 +80,7 @@ public class ContainerDynamicTank extends Container
}
}
else {
if(slotID >= 2 && slotID <= 8)
if(slotID >= 2 && slotID <= 28)
{
if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false))
{

View file

@ -0,0 +1,124 @@
package mekanism.common.inventory.container;
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.tile.TileEntityInductionCasing;
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;
import net.minecraftforge.fluids.FluidContainerRegistry;
public class ContainerInductionMatrix extends Container
{
private TileEntityInductionCasing tileEntity;
public ContainerInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotCharge(tentity, 0, 146, 20));
addSlotToContainer(new SlotDischarge(tentity, 1, 146, 51));
int slotX;
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; slotX++)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.open(inventory.player);
tileEntity.openInventory();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.close(entityplayer);
tileEntity.closeInventory();
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot currentSlot = (Slot)inventorySlots.get(slotID);
if(currentSlot != null && currentSlot.getHasStack())
{
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack))
{
if(slotID != 0 && slotID != 1)
{
if(!mergeItemStack(slotStack, 0, 1, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true))
{
return null;
}
}
}
else {
if(slotID >= 2 && slotID <= 28)
{
if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 28)
{
if(!mergeItemStack(slotStack, 2, 28, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true))
{
return null;
}
}
}
if(slotStack.stackSize == 0)
{
currentSlot.putStack((ItemStack)null);
}
else {
currentSlot.onSlotChanged();
}
if(slotStack.stackSize == stack.stackSize)
{
return null;
}
currentSlot.onPickupFromSlot(player, slotStack);
}
return stack;
}
}

View file

@ -13,14 +13,19 @@ import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.IConfigurable;
import mekanism.api.MekanismConfig.general;
import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
@ -34,7 +39,7 @@ import cpw.mods.fml.common.Optional.Method;
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2"),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
})
public class TileEntityInductionPort extends TileEntityInductionCasing implements IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
public class TileEntityInductionPort extends TileEntityInductionCasing implements IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter, IConfigurable
{
public boolean ic2Registered = false;
@ -393,4 +398,24 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
return toUse;
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
if(!worldObj.isRemote)
{
mode = !mode;
String modeText = " " + (mode ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(mode) + ".";
player.addChatMessage(new ChatComponentText(MekanismUtils.localize("tooltip.inductionPortMode") + modeText));
markDirty();
}
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
}

View file

@ -15,6 +15,11 @@ public final class LangUtils
{
return MekanismUtils.localize("tooltip." + (b ? "yes" : "no"));
}
public static String transOutputInput(boolean b)
{
return MekanismUtils.localize("gui." + (b ? "output" : "input"));
}
public static String localizeFluidStack(FluidStack fluidStack)
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -526,6 +526,7 @@ tooltip.configurator.linkMsg=Bound to
tooltip.configurator.dim=dimension
tooltip.configurator.setLink=Set link to block
tooltip.configurator.plenisherReset=Reset Fluidic Plenisher calculation
tooltip.configurator.inductionPortMode=Toggled Induction Port transfer mode to
tooltip.upgrade.speed=Speed
tooltip.upgrade.energy=Energy

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB