mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Add configurable I/O for buffers. Improve GUI. Improve power logic.
This commit is contained in:
1 parent
3add27b550
commit
ac7f744163
10 files changed
+284
-97
No files matched your search
@@ -17,6 +17,7 @@ import net.minecraft.world.World;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
@@ -25,28 +26,30 @@ import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.painter.BasicPainterTemplate;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFacade {
|
||||
|
||||
|
||||
public static BlockBuffer create() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketBufferIO.class, PacketBufferIO.class, PacketHandler.nextID(), Side.SERVER);
|
||||
BlockBuffer res = new BlockBuffer();
|
||||
res.init();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private BlockBuffer() {
|
||||
super(ModObject.blockBuffer, TileBuffer.class);
|
||||
setBlockTextureName("enderio:blockBuffer");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
protected void init() {
|
||||
GameRegistry.registerBlock(this, BlockItemBuffer.class, modObject.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(teClass, modObject.unlocalisedName + "TileEntity");
|
||||
EnderIO.guiHandler.registerGuiHandler(getGuiId(), this);
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
@@ -74,17 +77,17 @@ public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFa
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
return this.textureName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBackIconKey(boolean active) {
|
||||
return getMachineFrontIconKey(active);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getSideIconKey(boolean active) {
|
||||
return getMachineFrontIconKey(active);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
@@ -120,13 +123,13 @@ public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFa
|
||||
protected boolean shouldDropDefaultItem(World world, EntityPlayer player, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
if(!world.isRemote) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileBuffer) {
|
||||
TileBuffer cb = (TileBuffer) te;
|
||||
TileBuffer cb = (TileBuffer) te;
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
dropBlockAsItem(world, x, y, z, createDrop(cb));
|
||||
}
|
||||
@@ -141,12 +144,12 @@ public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFa
|
||||
te.writeCommon(stack.stackTagCompound);
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack createItemStackForSourceBlock(ItemStack machine, Block block, int sourceMeta) {
|
||||
PainterUtil.setSourceBlock(machine, block, sourceMeta);
|
||||
return machine;
|
||||
}
|
||||
|
||||
|
||||
public final class PainterTemplate extends BasicPainterTemplate {
|
||||
|
||||
public PainterTemplate() {
|
||||
@@ -167,8 +170,8 @@ public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFa
|
||||
@Override
|
||||
public int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileBuffer) {
|
||||
return ((TileBuffer)te).getSourceBlockMetadata();
|
||||
if(te instanceof TileBuffer) {
|
||||
return ((TileBuffer) te).getSourceBlockMetadata();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -176,8 +179,8 @@ public class BlockBuffer extends AbstractMachineBlock<TileBuffer> implements IFa
|
||||
@Override
|
||||
public Block getFacade(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileBuffer) {
|
||||
return ((TileBuffer)te).getSourceBlock();
|
||||
if(te instanceof TileBuffer) {
|
||||
return ((TileBuffer) te).getSourceBlock();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,9 @@ public class ContainerBuffer extends AbstractMachineContainer {
|
||||
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
if(((TileBuffer)tileEntity).hasInventory()) {
|
||||
Point point = new Point(62, 15);
|
||||
TileBuffer buf = (TileBuffer) tileEntity;
|
||||
if(buf.hasInventory()) {
|
||||
Point point = new Point(buf.hasInventory() && buf.hasPower() ? 96 : 62, 15);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new Slot(this.tileEntity, i, point.x + ((i % 3) * 18), point.y + ((i / 3) * 18)));
|
||||
}
|
||||
@@ -24,6 +25,6 @@ public class ContainerBuffer extends AbstractMachineContainer {
|
||||
|
||||
@Override
|
||||
public Point getPlayerInventoryOffset() {
|
||||
return new Point(8, 96);
|
||||
return super.getPlayerInventoryOffset();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio.machine.buffer;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
@@ -7,104 +8,214 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
|
||||
|
||||
private static final String TEXTURE_SIMPLE = "enderio:textures/gui/buffer.png";
|
||||
private static final String TEXTURE_FULL = "enderio:textures/gui/buffer_full.png";
|
||||
|
||||
private GuiTextField maxInput;
|
||||
private GuiTextField maxOutput;
|
||||
|
||||
private int lastInput, lastOutput;
|
||||
|
||||
public GuiBuffer(InventoryPlayer par1InventoryPlayer, TileBuffer te) {
|
||||
super(te, new ContainerBuffer(par1InventoryPlayer, te));
|
||||
redstoneButton.setPosition(116, 24);
|
||||
configB.setPosition(116, 42);
|
||||
redstoneButton.setPosition(isFull() ? 153 : 120, 24);
|
||||
configB.setPosition(isFull() ? 153 : 120, 42);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int x = guiLeft + (isFull() ? 20 : 58);
|
||||
int y = guiTop + 27;
|
||||
maxInput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
maxInput.setCanLoseFocus(true);
|
||||
maxInput.setMaxStringLength(10);
|
||||
maxInput.setFocused(false);
|
||||
maxInput.setText(PowerDisplayUtil.formatPower(getTileEntity().getMaxInput()));
|
||||
|
||||
y += 28;
|
||||
maxOutput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
maxOutput.setCanLoseFocus(true);
|
||||
maxOutput.setMaxStringLength(10);
|
||||
maxOutput.setFocused(getTileEntity().hasPower());
|
||||
maxOutput.setText(PowerDisplayUtil.formatPower(getTileEntity().getMaxOutput()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
super.keyTyped(par1, par2);
|
||||
if(par1 == 'e') {
|
||||
super.keyTyped(par1, 1);
|
||||
}
|
||||
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.textboxKeyTyped(par1, par2);
|
||||
maxOutput.textboxKeyTyped(par1, par2);
|
||||
updateInputOutput();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInputOutput() {
|
||||
int input = PowerDisplayUtil.parsePower(maxInput);
|
||||
setMaxInput(input);
|
||||
int output = PowerDisplayUtil.parsePower(maxOutput);
|
||||
setMaxOutput(output);
|
||||
sendUpdateToServer();
|
||||
}
|
||||
|
||||
private void setMaxOutput(int output) {
|
||||
if(output != lastOutput) {
|
||||
lastOutput = output;
|
||||
maxOutput.setText(PowerDisplayUtil.formatPower(output));
|
||||
}
|
||||
}
|
||||
|
||||
private void setMaxInput(int input) {
|
||||
if(input != lastInput) {
|
||||
lastInput = input;
|
||||
maxInput.setText(PowerDisplayUtil.formatPower(input));
|
||||
sendUpdateToServer();
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendUpdateToServer() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBufferIO(getTileEntity(), lastInput, lastOutput));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.mouseClicked(par1, par2, par3);
|
||||
maxOutput.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.updateCursorCounter();
|
||||
maxOutput.updateCursorCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showRecipeButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean renderPowerBar() {
|
||||
return getTileEntity().hasPower();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getYSize() {
|
||||
return ySize + 12;
|
||||
return ySize;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerHeight() {
|
||||
return 52;
|
||||
return 52;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerX() {
|
||||
return 48;
|
||||
return isFull() ? 6 : 44;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerY() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerV() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/buffer.png");
|
||||
|
||||
RenderUtil.bindTexture(isFull() ? TEXTURE_FULL : TEXTURE_SIMPLE);
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, xSize, ySize);
|
||||
|
||||
if (getTileEntity().hasPower()) {
|
||||
|
||||
RenderUtil.bindTexture(TEXTURE_SIMPLE);
|
||||
|
||||
if(getTileEntity().hasPower()) {
|
||||
drawPowerBg(sx, sy);
|
||||
}
|
||||
|
||||
if (getTileEntity().hasInventory()) {
|
||||
|
||||
if(getTileEntity().hasInventory()) {
|
||||
drawSlotBg(sx, sy);
|
||||
}
|
||||
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
String invName = Lang.localize(getTileEntity().getInventoryName() + ".name", false);
|
||||
getFontRenderer().drawStringWithShadow(invName, sx + (xSize / 2) - (getFontRenderer().getStringWidth(invName) / 2), sy + 4, 0xFFFFFF);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/buffer.png");
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
if(getTileEntity().hasPower()) {
|
||||
sx += isFull() ? 19 : 57;
|
||||
sy += 17;
|
||||
|
||||
getFontRenderer().drawStringWithShadow(Lang.localize("gui.simple.in"), sx, sy, 0xFFFFFF);
|
||||
getFontRenderer().drawStringWithShadow(Lang.localize("gui.simple.out"), sx, sy + 27, 0xFFFFFF);
|
||||
|
||||
maxInput.drawTextBox();
|
||||
maxOutput.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFull() {
|
||||
return getTileEntity().hasInventory() && getTileEntity().hasPower();
|
||||
}
|
||||
|
||||
public void renderSlotHighlights(IoMode mode) {
|
||||
for (int slot = 0; slot <= getTileEntity().getSizeInventory(); slot++) {
|
||||
if (!getTileEntity().hasInventory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < getTileEntity().getSizeInventory(); slot++) {
|
||||
renderSlotHighlight(slot, mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void renderSlotHighlight(int slot, IoMode mode) {
|
||||
Slot invSlot = (Slot) inventorySlots.inventorySlots.get(slot);
|
||||
if (mode == IoMode.PULL) {
|
||||
if(mode == IoMode.PULL) {
|
||||
renderSlotHighlight(slot, PULL_COLOR);
|
||||
} else if (mode == IoMode.PUSH) {
|
||||
} else if(mode == IoMode.PUSH) {
|
||||
renderSlotHighlight(slot, PUSH_COLOR);
|
||||
} else if (mode == IoMode.PUSH_PULL) {
|
||||
} else if(mode == IoMode.PUSH_PULL) {
|
||||
renderSplitHighlight(invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void renderSplitHighlight(int x, int y, int width, int height) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderUtil.renderQuad2D(getGuiLeft() + x, getGuiTop() + y, 0, width, height / 2, PULL_COLOR);
|
||||
RenderUtil.renderQuad2D(getGuiLeft() + x, getGuiTop() + y + (height / 2), 0, width, height / 2, PUSH_COLOR);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
private void drawPowerBg(int sx, int sy) {
|
||||
drawTexturedModalRect(sx + 47, sy + 14, xSize + 10, 0, 12, 54);
|
||||
drawTexturedModalRect(sx + (isFull() ? 5 : 43), sy + 14, xSize + 10, 0, 12, 54);
|
||||
}
|
||||
|
||||
|
||||
private void drawSlotBg(int sx, int sy) {
|
||||
drawTexturedModalRect(sx + 61, sy + 14, xSize + 22, 0, 54, 54);
|
||||
drawTexturedModalRect(sx + (isFull() ? 95 : 61), sy + 14, xSize + 22, 0, 54, 54);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package crazypants.enderio.machine.buffer;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
|
||||
public class PacketBufferIO extends MessageTileEntity<TileBuffer> implements IMessage, IMessageHandler<PacketBufferIO, IMessage> {
|
||||
|
||||
public PacketBufferIO() {}
|
||||
|
||||
private int in, out;
|
||||
|
||||
public PacketBufferIO(TileBuffer tile, int in, int out) {
|
||||
super(tile);
|
||||
tile.setIO(in, out);
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.in = buf.readInt();
|
||||
this.out = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(this.in);
|
||||
buf.writeInt(this.out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketBufferIO message, MessageContext ctx) {
|
||||
TileBuffer buf = message.getTileEntity(message.getWorld(ctx));
|
||||
if (buf != null) {
|
||||
buf.setIO(message.in, message.out);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,20 +11,22 @@ import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.painter.IPaintableTileEntity;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.enderio.power.IInternalPowerHandler;
|
||||
import crazypants.enderio.power.PowerDistributor;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintableTileEntity {
|
||||
public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintableTileEntity, IInternalPowerHandler {
|
||||
|
||||
private Block sourceBlock;
|
||||
private int sourceBlockMetadata;
|
||||
|
||||
|
||||
private boolean hasPower, hasInventory, isCreative;
|
||||
|
||||
|
||||
private PowerDistributor dist;
|
||||
|
||||
private final int maxOut = Config.powerConduitTierThreeRF;
|
||||
|
||||
|
||||
private int maxOut = Config.powerConduitTierThreeRF;
|
||||
private int maxIn = maxOut;
|
||||
|
||||
public TileBuffer() {
|
||||
super(new SlotDefinition(9, 0, 0));
|
||||
}
|
||||
@@ -51,50 +53,55 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
if (getEnergyStored() <= 0) {
|
||||
if(getEnergyStored() <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (dist == null) {
|
||||
if(dist == null) {
|
||||
dist = new PowerDistributor(new BlockCoord(this));
|
||||
}
|
||||
int transmitted = dist.transmitEnergy(worldObj, Math.min(maxOut, getEnergyStored()));
|
||||
setEnergyStored(getEnergyStored() - transmitted);
|
||||
int transmitted = dist.transmitEnergy(worldObj, Math.min(getMaxOutput(), getEnergyStored()));
|
||||
setEnergyStored(getEnergyStored() - transmitted);
|
||||
return transmitted > 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setIoMode(ForgeDirection faceHit, IoMode mode) {
|
||||
super.setIoMode(faceHit, mode);
|
||||
if (dist != null) {
|
||||
if(dist != null) {
|
||||
dist.neighboursChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack var2, int side) {
|
||||
return hasInventory() && super.canInsertItem(slot, var2, side) && getIoMode(ForgeDirection.VALID_DIRECTIONS[side]).canRecieveInput();
|
||||
return hasInventory() && super.canInsertItem(slot, var2, side) && getIoMode(ForgeDirection.VALID_DIRECTIONS[side]).canRecieveInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemstack, int side) {
|
||||
return hasInventory() && super.canExtractItem(slot, itemstack, side) && getIoMode(ForgeDirection.VALID_DIRECTIONS[side]).canOutput();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return hasPower;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyRecieved(ForgeDirection dir) {
|
||||
return maxOut;
|
||||
return maxIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return hasPower() && getIoMode(from).canRecieveInput() ? super.receiveEnergy(from, maxReceive, isCreative() || simulate) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return hasPower() ? super.receiveEnergy(from, maxReceive, isCreative() || simulate) : 0;
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doPull(ForgeDirection dir) {
|
||||
ItemStack[] invCopy = new ItemStack[inventory.length];
|
||||
@@ -122,7 +129,7 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
invCopy[i] = inventory[i] == null ? null : inventory[i].copy();
|
||||
}
|
||||
|
||||
|
||||
BlockCoord loc = getLocation().getLocation(dir);
|
||||
TileEntity te = worldObj.getTileEntity(loc.x, loc.y, loc.z);
|
||||
|
||||
@@ -134,7 +141,7 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
@@ -142,13 +149,13 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
nbtRoot.setBoolean("hasPower", hasPower);
|
||||
nbtRoot.setBoolean("creative", isCreative);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
PainterUtil.setSourceBlock(nbtRoot, sourceBlock, sourceBlockMetadata);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.readCustomNBT(nbtRoot);
|
||||
@@ -156,7 +163,7 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
this.hasPower = nbtRoot.getBoolean("hasPower");
|
||||
this.isCreative = nbtRoot.getBoolean("creative");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
@@ -187,25 +194,38 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
public boolean hasInventory() {
|
||||
return hasInventory;
|
||||
}
|
||||
|
||||
|
||||
public void setHasInventory(boolean hasInventory) {
|
||||
this.hasInventory = hasInventory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasPower() {
|
||||
return hasPower;
|
||||
}
|
||||
|
||||
|
||||
public void setHasPower(boolean hasPower) {
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
public boolean isCreative() {
|
||||
|
||||
public boolean isCreative() {
|
||||
return isCreative;
|
||||
}
|
||||
|
||||
public void setCreative(boolean isCreative) {
|
||||
this.isCreative = isCreative;
|
||||
}
|
||||
|
||||
public void setIO(int in, int out) {
|
||||
this.maxIn = in;
|
||||
this.maxOut = out;
|
||||
}
|
||||
|
||||
public int getMaxInput() {
|
||||
return maxIn;
|
||||
}
|
||||
|
||||
public int getMaxOutput() {
|
||||
return maxOut;
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import crazypants.enderio.machine.capbank.network.CapBankClientNetwork;
|
||||
import crazypants.enderio.machine.capbank.network.NetworkState;
|
||||
import crazypants.enderio.machine.capbank.packet.PacketGuiChange;
|
||||
import crazypants.enderio.machine.capbank.packet.PacketNetworkStateRequest;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.enderio.machine.gui.GuiOverlayIoConfig;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.GuiContainerBase;
|
||||
@@ -232,11 +232,11 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
}
|
||||
|
||||
private void updateInputOutput() {
|
||||
int input = parsePower(maxInputTF);
|
||||
int input = PowerDisplayUtil.parsePower(maxInputTF);
|
||||
if(input >= 0 && network.getMaxInput() != input) {
|
||||
setMaxInput(input);
|
||||
}
|
||||
int output = parsePower(maxOutputTF);
|
||||
int output = PowerDisplayUtil.parsePower(maxOutputTF);
|
||||
if(output >= 0 && network.getMaxOutput() != output) {
|
||||
setMaxOutput(output);
|
||||
}
|
||||
@@ -264,19 +264,6 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
private int parsePower(GuiTextField tf) {
|
||||
String txt = tf.getText();
|
||||
try {
|
||||
Integer power = PowerDisplayUtil.parsePower(txt);
|
||||
if(power == null) {
|
||||
return -1;
|
||||
}
|
||||
return power.intValue();
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
|
||||
@@ -4,8 +4,11 @@ import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class PowerDisplayUtil {
|
||||
@@ -105,5 +108,19 @@ public class PowerDisplayUtil {
|
||||
public static String abrevation() {
|
||||
return Lang.localize("power.rf");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static int parsePower(GuiTextField tf) {
|
||||
String txt = tf.getText();
|
||||
try {
|
||||
Integer power = PowerDisplayUtil.parsePower(txt);
|
||||
if(power == null) {
|
||||
return -1;
|
||||
}
|
||||
return power.intValue();
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user