More Entanglement work. Now has a gui, can set it's frequency.
This commit is contained in:
parent
e9b87f8d56
commit
191d964003
6 changed files with 173 additions and 14 deletions
|
@ -25,6 +25,7 @@ import mekanism.client.gui.GuiElectrolyticSeparator;
|
|||
import mekanism.client.gui.GuiEnergizedSmelter;
|
||||
import mekanism.client.gui.GuiEnergyCube;
|
||||
import mekanism.client.gui.GuiEnrichmentChamber;
|
||||
import mekanism.client.gui.GuiEntangledBlock;
|
||||
import mekanism.client.gui.GuiFactory;
|
||||
import mekanism.client.gui.GuiFluidicPlenisher;
|
||||
import mekanism.client.gui.GuiGasTank;
|
||||
|
@ -128,6 +129,7 @@ import mekanism.common.tile.TileEntityEliteFactory;
|
|||
import mekanism.common.tile.TileEntityEnergizedSmelter;
|
||||
import mekanism.common.tile.TileEntityEnergyCube;
|
||||
import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
|
@ -480,7 +482,7 @@ public class ClientProxy extends CommonProxy
|
|||
case 44:
|
||||
return new GuiLaserAmplifier(player.inventory, (TileEntityLaserAmplifier)tileEntity);
|
||||
case 45:
|
||||
return null; //new GuiEntangledBlock(player.sharedInventory, (TileEntityEntangledInventory)tileEntity);
|
||||
return new GuiEntangledBlock(player.inventory, (TileEntityEntangledBlock)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
131
src/main/java/mekanism/client/gui/GuiEntangledBlock.java
Normal file
131
src/main/java/mekanism/client/gui/GuiEntangledBlock.java
Normal file
|
@ -0,0 +1,131 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.gui.GuiGauge.Type;
|
||||
import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.inventory.container.ContainerLaserAmplifier;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||
import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiEntangledBlock extends GuiMekanism
|
||||
{
|
||||
public TileEntityEntangledBlock tileEntity;
|
||||
|
||||
public GuiTextField frequencyField;
|
||||
|
||||
public GuiEntangledBlock(InventoryPlayer inventory, TileEntityEntangledBlock tentity)
|
||||
{
|
||||
super(new ContainerNull(inventory.player, tentity));
|
||||
tileEntity = tentity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 55, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.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);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
frequencyField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
|
||||
frequencyField.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
frequencyField.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
if(!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
}
|
||||
|
||||
if(i == Keyboard.KEY_RETURN)
|
||||
{
|
||||
if(frequencyField.isFocused())
|
||||
{
|
||||
setFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
frequencyField.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
||||
private void setFrequency()
|
||||
{
|
||||
if(!frequencyField.getText().isEmpty())
|
||||
{
|
||||
String toUse;
|
||||
|
||||
toUse = frequencyField.getText();
|
||||
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(0);
|
||||
data.add(toUse);
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
|
||||
frequencyField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
String prevFreq = frequencyField != null ? frequencyField.getText() : "";
|
||||
|
||||
frequencyField = new GuiTextField(fontRendererObj, guiWidth + 75, guiHeight + 55, 96, 11);
|
||||
frequencyField.setMaxStringLength(10);
|
||||
frequencyField.setText(prevFreq);
|
||||
}
|
||||
}
|
|
@ -438,9 +438,8 @@ public class CommonProxy
|
|||
case 43:
|
||||
return new ContainerUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity);
|
||||
case 44:
|
||||
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
|
||||
case 45:
|
||||
return null; // new ContainerEntangledInventory(player.sharedInventory, (TileEntityEntangledInventory)tileEntity)
|
||||
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -59,7 +59,7 @@ import mekanism.common.tile.TileEntityBoundingBlock;
|
|||
import mekanism.common.tile.TileEntityCardboardBox;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.tile.TileEntityEnergizedSmelter;
|
||||
import mekanism.common.tile.TileEntityEntangledInventory;
|
||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||
import mekanism.common.tile.TileEntitySalinationBlock;
|
||||
import mekanism.common.tile.TileEntitySalinationValve;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
|
@ -937,7 +937,7 @@ public class Mekanism
|
|||
GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "CardboardBox");
|
||||
GameRegistry.registerTileEntity(TileEntitySalinationValve.class, "SalinationValve");
|
||||
GameRegistry.registerTileEntity(TileEntitySalinationBlock.class, "SalinationTank");
|
||||
GameRegistry.registerTileEntity(TileEntityEntangledInventory.class, "EntangledBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityEntangledBlock.class, "EntangledBlock");
|
||||
|
||||
//Load tile entities that have special renderers.
|
||||
proxy.registerSpecialTileEntities();
|
||||
|
|
|
@ -48,7 +48,7 @@ import mekanism.common.tile.TileEntityElectrolyticSeparator;
|
|||
import mekanism.common.tile.TileEntityEliteFactory;
|
||||
import mekanism.common.tile.TileEntityEnergizedSmelter;
|
||||
import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||
import mekanism.common.tile.TileEntityEntangledInventory;
|
||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||
import mekanism.common.tile.TileEntityLaser;
|
||||
|
@ -1212,7 +1212,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
FLUIDIC_PLENISHER(MekanismBlocks.MachineBlock2, 12, "FluidicPlenisher", 42, 10000, TileEntityFluidicPlenisher.class, true, true, false),
|
||||
LASER(MekanismBlocks.MachineBlock2, 13, "Laser", -1, 100000, TileEntityLaser.class, true, true, false),
|
||||
LASER_AMPLIFIER(MekanismBlocks.MachineBlock2, 14, "LaserAmplifier", 44, 0, TileEntityLaserAmplifier.class, false, true, false),
|
||||
ENTANGLED_BLOCK(MekanismBlocks.MachineBlock2, 15, "EntangledBlock", 45, 0, TileEntityEntangledInventory.class, true, false, false);
|
||||
ENTANGLED_BLOCK(MekanismBlocks.MachineBlock2, 15, "EntangledBlock", 45, 0, TileEntityEntangledBlock.class, true, false, false);
|
||||
|
||||
public Block typeBlock;
|
||||
public int meta;
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.api.gas.Gas;
|
|||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.teleportation.SharedInventory;
|
||||
import mekanism.common.teleportation.SharedInventoryManager;
|
||||
import mekanism.common.util.CableUtils;
|
||||
|
@ -18,11 +19,15 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileEntityEntangledInventory extends TileEntityElectricBlock implements IFluidHandler, IGasHandler, ITubeConnection
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityEntangledBlock extends TileEntityElectricBlock implements IFluidHandler, IGasHandler, ITubeConnection
|
||||
{
|
||||
public SharedInventory sharedInventory;
|
||||
|
||||
public TileEntityEntangledInventory()
|
||||
public static final EnumSet<ForgeDirection> nothing = EnumSet.noneOf(ForgeDirection.class);
|
||||
|
||||
public TileEntityEntangledBlock()
|
||||
{
|
||||
super("Entangled", 0);
|
||||
inventory = new ItemStack[0];
|
||||
|
@ -41,17 +46,39 @@ public class TileEntityEntangledInventory extends TileEntityElectricBlock implem
|
|||
sharedInventory = SharedInventoryManager.getInventory(frequency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
switch(dataStream.readInt())
|
||||
{
|
||||
case 0:
|
||||
setInventory(PacketHandler.readString(dataStream));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
setEnergy(dataStream.readDouble());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
data.add(getEnergy());
|
||||
return data;
|
||||
}
|
||||
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.UP);
|
||||
return sharedInventory == null ? nothing : EnumSet.of(ForgeDirection.UP);
|
||||
}
|
||||
|
||||
protected EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
EnumSet set = EnumSet.allOf(ForgeDirection.class);
|
||||
set.remove(ForgeDirection.UNKNOWN);
|
||||
set.remove(ForgeDirection.UP);
|
||||
return set;
|
||||
return sharedInventory == null ? nothing : EnumSet.complementOf(EnumSet.of(ForgeDirection.UNKNOWN, ForgeDirection.UP));
|
||||
}
|
||||
|
||||
public double getMaxOutput()
|
Loading…
Add table
Reference in a new issue