mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
Merge branch 'master' into 1.6.4
This commit is contained in:
commit
f89950519b
8 files changed
+238
-134
No files matched your search
@@ -46,11 +46,11 @@ public class PacketHandler implements IPacketHandler {
|
||||
|
||||
public static final int ID_ALLOY_SMELTING_MODE_PACKET = 6;
|
||||
|
||||
public static final int ID_HYPER_CUBE_REDSTONE_PACKET = 7;
|
||||
public static final int ID_HYPER_CUBE_PUBLIC_CHANNEL_LIST = 8;
|
||||
public static final int ID_HYPER_CUBE_ADD_REMOVE_CHANNEL = 9;
|
||||
public static final int ID_HYPER_CUBE_PRIVATE_CHANNEL_LIST = 10;
|
||||
public static final int ID_HYPER_CUBE_CHANNEL_SELECTED = 11;
|
||||
public static final int ID_TRANSCEIVER_IO_MODE = 7;
|
||||
public static final int ID_TRANSCEIVER_PUBLIC_CHANNEL_LIST = 8;
|
||||
public static final int ID_TRANSCEIVER_ADD_REMOVE_CHANNEL = 9;
|
||||
public static final int ID_TRANSCEIVER_PRIVATE_CHANNEL_LIST = 10;
|
||||
public static final int ID_TRANSCEIVER_CHANNEL_SELECTED = 11;
|
||||
|
||||
public static final int ID_MJ_READER_INFO_REQUEST = 12;
|
||||
public static final int ID_POWER_MONITOR_PACKET = 13;
|
||||
|
||||
@@ -26,6 +26,8 @@ public class IconButtonEIO extends GuiButton {
|
||||
protected IGuiScreen gui;
|
||||
|
||||
protected GuiToolTip toolTip;
|
||||
private int marginY = 0;
|
||||
private int marginX = 0;
|
||||
|
||||
public IconButtonEIO(IGuiScreen gui, int id, int x, int y, IconEIO icon) {
|
||||
super(id, x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, "");
|
||||
@@ -68,6 +70,11 @@ public class IconButtonEIO extends GuiButton {
|
||||
}
|
||||
}
|
||||
|
||||
public void setIconMargin(int x, int y) {
|
||||
marginX = x;
|
||||
marginY = y;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
@@ -115,7 +122,7 @@ public class IconButtonEIO extends GuiButton {
|
||||
|
||||
background.renderIcon(x, y, width, height, 0, false);
|
||||
if(icon != null) {
|
||||
icon.renderIcon(x, y, width, height, 0, false);
|
||||
icon.renderIcon(x + marginX, y + marginY, width - (2 * marginX), height - (2 * marginY), 0, false);
|
||||
}
|
||||
|
||||
tes.draw();
|
||||
|
||||
@@ -22,10 +22,15 @@ public final class IconEIO {
|
||||
|
||||
public static final IconEIO WRENCH_OVERLAY_ALL_ON = new IconEIO(0, 148, 64, 64);
|
||||
public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(64, 148, 64, 64);
|
||||
|
||||
public static final IconEIO WRENCH_OVERLAY_POWER = new IconEIO(0, 148, 32, 32);
|
||||
public static final IconEIO WRENCH_OVERLAY_POWER_OFF = new IconEIO(64, 148, 32, 32);
|
||||
|
||||
public static final IconEIO WRENCH_OVERLAY_REDSTONE = new IconEIO(32, 148, 32, 32);
|
||||
public static final IconEIO WRENCH_OVERLAY_ITEM = new IconEIO(0, 180, 32, 32);
|
||||
|
||||
public static final IconEIO WRENCH_OVERLAY_FLUID = new IconEIO(32, 180, 32, 32);
|
||||
public static final IconEIO WRENCH_OVERLAY_FLUID_OFF = new IconEIO(32 + 64, 180, 32, 32);
|
||||
|
||||
public static final IconEIO ACTIVE_TAB = new IconEIO(237, 0, 19, 24);
|
||||
public static final IconEIO INACTIVE_TAB = new IconEIO(237, 25, 19, 24);
|
||||
@@ -50,6 +55,14 @@ public final class IconEIO {
|
||||
public static final IconEIO FILTER_NBT_OFF = new IconEIO(64 + 22, 212, 22, 22);
|
||||
public static final IconEIO FILTER_ORE_DICT_OFF = new IconEIO(64 + 44, 212, 22, 22);
|
||||
|
||||
public static final IconEIO INPUT = new IconEIO(128, 197, 30, 14);
|
||||
public static final IconEIO OUTPUT = new IconEIO(128, 180, 30, 14);
|
||||
public static final IconEIO INPUT_OUTPUT = new IconEIO(158, 180, 30, 8);
|
||||
|
||||
public static final IconEIO INPUT_OFF = new IconEIO(188, 180, 30, 14);
|
||||
public static final IconEIO OUTPUT_OFF = new IconEIO(188, 197, 30, 14);
|
||||
public static final IconEIO INPUT_OUTPUT_OFF = new IconEIO(218, 180, 30, 8);
|
||||
|
||||
private static final int TEX_SIZE = 256;
|
||||
private static final double PIX_SIZE = 1d / TEX_SIZE;
|
||||
|
||||
@@ -83,6 +96,10 @@ public final class IconEIO {
|
||||
renderIcon(x, y, width, height, 0, false);
|
||||
}
|
||||
|
||||
public void renderIcon(double x, double y, boolean doDraw) {
|
||||
renderIcon(x, y, width, height, 0, doDraw);
|
||||
}
|
||||
|
||||
public void renderIcon(double x, double y, double width, double height, double zLevel, boolean doDraw) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import crazypants.gui.GuiScrollableList;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class GuiChannelList extends GuiScrollableList<Channel> {
|
||||
|
||||
@@ -78,11 +77,10 @@ public class GuiChannelList extends GuiScrollableList<Channel> {
|
||||
}
|
||||
int col = ColorUtil.getRGB(Color.white);
|
||||
if(c.equals(activeChannel)) {
|
||||
col = ColorUtil.getRGB(Color.cyan);
|
||||
if(isActiveChannelListed()) {
|
||||
RenderUtil.renderQuad2D(xPosition - 1, yPosition, 0, width, rowHeight + 2, ColorUtil.getRGB(Color.darkGray));
|
||||
col = ColorUtil.getRGB(Color.cyan);
|
||||
} else {
|
||||
RenderUtil.renderQuad2D(xPosition - 1, yPosition, 0, width, rowHeight + 2, ColorUtil.getRGB(Color.red.darker()));
|
||||
col = ColorUtil.getRGB(Color.red);
|
||||
}
|
||||
}
|
||||
parent.drawString(parent.getFontRenderer(), c.name, xPosition + margin, yPosition + margin / 2, col);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package crazypants.enderio.machine.hypercube;
|
||||
|
||||
import static crazypants.enderio.machine.GuiMachineBase.BUTTON_SIZE;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
@@ -18,13 +16,11 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.ToggleButtonEIO;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
|
||||
import crazypants.gui.GuiScreenBase;
|
||||
import crazypants.gui.GuiScrollableList;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.gui.IconButton;
|
||||
import crazypants.gui.ListSelectionListener;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
@@ -42,6 +38,9 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
protected static final int DELETE_PRIVATE_BUTTON_ID = 7;
|
||||
protected static final int DELETE_PUBLIC_BUTTON_ID = 8;
|
||||
|
||||
protected static final int POWER_MODE_BUTTON_ID = 9;
|
||||
protected static final int FLUID_MODE_BUTTON_ID = 10;
|
||||
|
||||
private static final int POWER_X = 227;
|
||||
private static final int POWER_Y = 46;
|
||||
private static final int POWER_WIDTH = 10;
|
||||
@@ -50,9 +49,6 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
|
||||
private final TileHyperCube cube;
|
||||
|
||||
private IconButton powerInputRedstoneButton;
|
||||
private IconButton powerOutputRedstoneButton;
|
||||
|
||||
private IconButtonEIO addButton;
|
||||
private ToggleButtonEIO privateButton;
|
||||
|
||||
@@ -68,6 +64,12 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
private IconButtonEIO selectPrivateB;
|
||||
private IconButtonEIO deletePrivateB;
|
||||
|
||||
private IconButtonEIO powerB;
|
||||
private IconButtonEIO fluidB;
|
||||
|
||||
// private IconEIO inputIcon;
|
||||
// private IconEIO outputIcon;
|
||||
|
||||
public GuiHyperCube(TileHyperCube te) {
|
||||
super(245, 145);
|
||||
this.cube = te;
|
||||
@@ -82,27 +84,6 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
|
||||
});
|
||||
|
||||
addToolTip(new GuiToolTip(new Rectangle(198, 12, BUTTON_SIZE, BUTTON_SIZE), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
text.add("Input Redstone Mode");
|
||||
text.add(cube.getInputControlMode().tooltip);
|
||||
}
|
||||
|
||||
});
|
||||
addToolTip(new GuiToolTip(new Rectangle(219, 12, GuiMachineBase.BUTTON_SIZE, GuiMachineBase.BUTTON_SIZE), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
text.add("Output Redstone Mode");
|
||||
text.add(cube.getOutputControlMode().tooltip);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
addButton = new IconButtonEIO(this, ADD_BUTTON_ID, 137, 12, IconEIO.PLUS);
|
||||
addButton.setToolTip("Add Channel");
|
||||
addButton.enabled = false;
|
||||
@@ -121,6 +102,14 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
selectPrivateB = new IconButtonEIO(this, SELECT_PRIVATE_BUTTON_ID, 204, 117, IconEIO.TICK);
|
||||
selectPrivateB.setToolTip("Activate Channel");
|
||||
|
||||
powerB = new IconButtonEIO(this, POWER_MODE_BUTTON_ID, 203, 12, IconEIO.WRENCH_OVERLAY_POWER);
|
||||
powerB.setIconMargin(3, 3);
|
||||
|
||||
fluidB = new IconButtonEIO(this, FLUID_MODE_BUTTON_ID, 222, 12, IconEIO.WRENCH_OVERLAY_FLUID);
|
||||
fluidB.setIconMargin(3, 3);
|
||||
|
||||
updateIoButtons();
|
||||
|
||||
int w = 104;
|
||||
int h = 68;
|
||||
int x = 7;
|
||||
@@ -158,6 +147,24 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
|
||||
}
|
||||
|
||||
private void updateIoButtons() {
|
||||
IoMode mode = cube.getModeForChannel(SubChannel.POWER);
|
||||
if(mode.isRecieveEnabled() || mode.isSendEnabled()) {
|
||||
powerB.setIcon(IconEIO.WRENCH_OVERLAY_POWER);
|
||||
} else {
|
||||
powerB.setIcon(IconEIO.WRENCH_OVERLAY_POWER_OFF);
|
||||
}
|
||||
powerB.setToolTip("Power Mode", mode.getUnlocalisedName());
|
||||
|
||||
mode = cube.getModeForChannel(SubChannel.FLUID);
|
||||
if(mode.isRecieveEnabled() || mode.isSendEnabled()) {
|
||||
fluidB.setIcon(IconEIO.WRENCH_OVERLAY_FLUID);
|
||||
} else {
|
||||
fluidB.setIcon(IconEIO.WRENCH_OVERLAY_FLUID_OFF);
|
||||
}
|
||||
fluidB.setToolTip("Fluid Mode", mode.getUnlocalisedName());
|
||||
}
|
||||
|
||||
private boolean isPublic(Channel chan) {
|
||||
if(chan == null) {
|
||||
return false;
|
||||
@@ -181,19 +188,6 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
int x = guiLeft + 203;
|
||||
int y = guiTop + 12;
|
||||
|
||||
powerInputRedstoneButton = new IconButton(fontRenderer, POWER_INPUT_BUTTON_ID, x, y, AbstractMachineBlock.getRedstoneControlIcon(cube
|
||||
.getInputControlMode()),
|
||||
RenderUtil.BLOCK_TEX);
|
||||
powerInputRedstoneButton.setSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
buttonList.add(powerInputRedstoneButton);
|
||||
|
||||
x = x + 5 + BUTTON_SIZE;
|
||||
powerOutputRedstoneButton = new IconButton(fontRenderer, POWER_OUTPUT_BUTTON_ID, x, y, AbstractMachineBlock.getRedstoneControlIcon(cube
|
||||
.getOutputControlMode()),
|
||||
RenderUtil.BLOCK_TEX);
|
||||
powerOutputRedstoneButton.setSize(GuiMachineBase.BUTTON_SIZE, GuiMachineBase.BUTTON_SIZE);
|
||||
buttonList.add(powerOutputRedstoneButton);
|
||||
|
||||
y = guiTop + 12;
|
||||
x = guiLeft + 8;
|
||||
newChannelTF = new GuiTextField(fontRenderer, x, y, 103, 16);
|
||||
@@ -208,6 +202,9 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
deletePrivateB.onGuiInit();
|
||||
deletePublicB.onGuiInit();
|
||||
|
||||
powerB.onGuiInit();
|
||||
fluidB.onGuiInit();
|
||||
|
||||
publicChannelList.onGuiInit(this);
|
||||
privateChannelList.onGuiInit(this);
|
||||
|
||||
@@ -215,26 +212,29 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == POWER_INPUT_BUTTON_ID) {
|
||||
int ordinal = cube.getInputControlMode().ordinal();
|
||||
ordinal++;
|
||||
if(ordinal >= RedstoneControlMode.values().length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
cube.setInputControlMode(RedstoneControlMode.values()[ordinal]);
|
||||
powerInputRedstoneButton.setIcon(AbstractMachineBlock.getRedstoneControlIcon(cube.getInputControlMode()));
|
||||
Packet pkt = HyperCubePacketHandler.createRedstoneControlPacket(cube);
|
||||
|
||||
if(par1GuiButton.id == FLUID_MODE_BUTTON_ID) {
|
||||
|
||||
IoMode curMode = cube.getModeForChannel(SubChannel.FLUID);
|
||||
IoMode nextMode = curMode.next();
|
||||
cube.setModeForChannel(SubChannel.FLUID, nextMode);
|
||||
|
||||
updateIoButtons();
|
||||
|
||||
Packet pkt = HyperCubePacketHandler.createIoModePacket(cube);
|
||||
PacketDispatcher.sendPacketToServer(pkt);
|
||||
} else if(par1GuiButton.id == POWER_OUTPUT_BUTTON_ID) {
|
||||
int ordinal = cube.getOutputControlMode().ordinal();
|
||||
ordinal++;
|
||||
if(ordinal >= RedstoneControlMode.values().length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
cube.setOutputControlMode(RedstoneControlMode.values()[ordinal]);
|
||||
powerOutputRedstoneButton.setIcon(AbstractMachineBlock.getRedstoneControlIcon(cube.getOutputControlMode()));
|
||||
Packet pkt = HyperCubePacketHandler.createRedstoneControlPacket(cube);
|
||||
|
||||
} else if(par1GuiButton.id == POWER_MODE_BUTTON_ID) {
|
||||
|
||||
IoMode curMode = cube.getModeForChannel(SubChannel.POWER);
|
||||
IoMode nextMode = curMode.next();
|
||||
cube.setModeForChannel(SubChannel.POWER, nextMode);
|
||||
|
||||
updateIoButtons();
|
||||
|
||||
Packet pkt = HyperCubePacketHandler.createIoModePacket(cube);
|
||||
PacketDispatcher.sendPacketToServer(pkt);
|
||||
|
||||
} else if(par1GuiButton.id == ADD_BUTTON_ID) {
|
||||
|
||||
Channel c;
|
||||
@@ -247,6 +247,8 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
Packet pkt = HyperCubePacketHandler.createAddRemoveChannelPacket(c, true);
|
||||
PacketDispatcher.sendPacketToServer(pkt);
|
||||
|
||||
setActiveChannel(c);
|
||||
|
||||
if(privateButton.isSelected()) {
|
||||
privateChannelList.setSelection(c);
|
||||
} else {
|
||||
@@ -342,6 +344,22 @@ public class GuiHyperCube extends GuiScreenBase {
|
||||
x += 109;
|
||||
drawString(fontRenderer, "Private", x, y, rgb);
|
||||
|
||||
IoMode fluidMode = cube.getModeForChannel(SubChannel.FLUID);
|
||||
IoMode powerMode = cube.getModeForChannel(SubChannel.POWER);
|
||||
if(fluidMode.isRecieveEnabled()) {
|
||||
IconEIO.INPUT.renderIcon(guiLeft + 222 + 15, guiTop + 4 + 7, -15, -7, 0, true);
|
||||
}
|
||||
if(powerMode.isRecieveEnabled()) {
|
||||
IconEIO.INPUT.renderIcon(guiLeft + 203 + 15, guiTop + 4 + 7, -15, -7, 0, true);
|
||||
}
|
||||
|
||||
if(fluidMode.isSendEnabled()) {
|
||||
IconEIO.OUTPUT.renderIcon(guiLeft + 223, guiTop + 29, 15, 7, 0, true);
|
||||
}
|
||||
if(powerMode.isSendEnabled()) {
|
||||
IconEIO.OUTPUT.renderIcon(guiLeft + 204, guiTop + 29, 15, 7, 0, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,28 +26,29 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.IPacketProcessor;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
|
||||
|
||||
public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHandler {
|
||||
|
||||
@Override
|
||||
public boolean canProcessPacket(int packetID) {
|
||||
return PacketHandler.ID_HYPER_CUBE_REDSTONE_PACKET == packetID || PacketHandler.ID_HYPER_CUBE_PUBLIC_CHANNEL_LIST == packetID
|
||||
|| PacketHandler.ID_HYPER_CUBE_ADD_REMOVE_CHANNEL == packetID || PacketHandler.ID_HYPER_CUBE_PRIVATE_CHANNEL_LIST == packetID
|
||||
|| PacketHandler.ID_HYPER_CUBE_CHANNEL_SELECTED == packetID;
|
||||
return PacketHandler.ID_TRANSCEIVER_IO_MODE == packetID || PacketHandler.ID_TRANSCEIVER_PUBLIC_CHANNEL_LIST == packetID
|
||||
|| PacketHandler.ID_TRANSCEIVER_ADD_REMOVE_CHANNEL == packetID || PacketHandler.ID_TRANSCEIVER_PRIVATE_CHANNEL_LIST == packetID
|
||||
|| PacketHandler.ID_TRANSCEIVER_CHANNEL_SELECTED == packetID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(int packetID, INetworkManager manager, DataInputStream data, Player player) throws IOException {
|
||||
if(packetID == PacketHandler.ID_HYPER_CUBE_REDSTONE_PACKET) {
|
||||
handleHyperCubeRedstoneControlPacket(data, manager, player);
|
||||
} else if(packetID == PacketHandler.ID_HYPER_CUBE_PUBLIC_CHANNEL_LIST) {
|
||||
if(packetID == PacketHandler.ID_TRANSCEIVER_IO_MODE) {
|
||||
handleIoModePacket(data, manager, player);
|
||||
} else if(packetID == PacketHandler.ID_TRANSCEIVER_PUBLIC_CHANNEL_LIST) {
|
||||
handlePublicChannelListPacket(data, manager, player);
|
||||
} else if(packetID == PacketHandler.ID_HYPER_CUBE_ADD_REMOVE_CHANNEL) {
|
||||
} else if(packetID == PacketHandler.ID_TRANSCEIVER_ADD_REMOVE_CHANNEL) {
|
||||
handleAddRemoveChannelPacket(data, manager, player);
|
||||
} else if(packetID == PacketHandler.ID_HYPER_CUBE_PRIVATE_CHANNEL_LIST) {
|
||||
} else if(packetID == PacketHandler.ID_TRANSCEIVER_PRIVATE_CHANNEL_LIST) {
|
||||
handlePrivateChannelPacket(data, manager, player);
|
||||
} else if(packetID == PacketHandler.ID_HYPER_CUBE_CHANNEL_SELECTED) {
|
||||
} else if(packetID == PacketHandler.ID_TRANSCEIVER_CHANNEL_SELECTED) {
|
||||
handleChannelSelectedPacket(data, manager, player);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_HYPER_CUBE_CHANNEL_SELECTED);
|
||||
dos.writeInt(PacketHandler.ID_TRANSCEIVER_CHANNEL_SELECTED);
|
||||
dos.writeInt(cube.xCoord);
|
||||
dos.writeInt(cube.yCoord);
|
||||
dos.writeInt(cube.zCoord);
|
||||
@@ -122,7 +123,7 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_HYPER_CUBE_PRIVATE_CHANNEL_LIST);
|
||||
dos.writeInt(PacketHandler.ID_TRANSCEIVER_PRIVATE_CHANNEL_LIST);
|
||||
dos.writeUTF(username);
|
||||
dos.writeInt(channels.size());
|
||||
for (Channel channel : channels) {
|
||||
@@ -156,7 +157,7 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_HYPER_CUBE_ADD_REMOVE_CHANNEL);
|
||||
dos.writeInt(PacketHandler.ID_TRANSCEIVER_ADD_REMOVE_CHANNEL);
|
||||
dos.writeBoolean(isAdd);
|
||||
dos.writeBoolean(channel.isPublic());
|
||||
dos.writeUTF(channel.name);
|
||||
@@ -206,7 +207,7 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
List<Channel> channels = HyperCubeRegister.instance.getPublicChannels();
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_HYPER_CUBE_PUBLIC_CHANNEL_LIST);
|
||||
dos.writeInt(PacketHandler.ID_TRANSCEIVER_PUBLIC_CHANNEL_LIST);
|
||||
dos.writeInt(channels.size());
|
||||
for (Channel channel : channels) {
|
||||
dos.writeUTF(channel.name);
|
||||
@@ -232,16 +233,16 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
ClientChannelRegister.instance.setPublicChannels(channels);
|
||||
}
|
||||
|
||||
public static Packet createRedstoneControlPacket(TileHyperCube te) {
|
||||
public static Packet createIoModePacket(TileHyperCube te) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_HYPER_CUBE_REDSTONE_PACKET);
|
||||
dos.writeInt(PacketHandler.ID_TRANSCEIVER_IO_MODE);
|
||||
dos.writeInt(te.xCoord);
|
||||
dos.writeInt(te.yCoord);
|
||||
dos.writeInt(te.zCoord);
|
||||
dos.writeShort((short) te.getInputControlMode().ordinal());
|
||||
dos.writeShort((short) te.getOutputControlMode().ordinal());
|
||||
dos.writeShort((short) te.getModeForChannel(SubChannel.POWER).ordinal());
|
||||
dos.writeShort((short) te.getModeForChannel(SubChannel.FLUID).ordinal());
|
||||
} catch (IOException e) {
|
||||
// never thrown
|
||||
}
|
||||
@@ -254,18 +255,18 @@ public class HyperCubePacketHandler implements IPacketProcessor, IConnectionHand
|
||||
return pkt;
|
||||
}
|
||||
|
||||
private void handleHyperCubeRedstoneControlPacket(DataInputStream data, INetworkManager manager, Player player) throws IOException {
|
||||
private void handleIoModePacket(DataInputStream data, INetworkManager manager, Player player) throws IOException {
|
||||
int x = data.readInt();
|
||||
int y = data.readInt();
|
||||
int z = data.readInt();
|
||||
short powerInputOrdinal = data.readShort();
|
||||
short powerOutputOrdinal = data.readShort();
|
||||
short powerModeOrdinal = data.readShort();
|
||||
short fluidModeOrdinal = data.readShort();
|
||||
EntityPlayerMP p = (EntityPlayerMP) player;
|
||||
TileEntity te = p.worldObj.getBlockTileEntity(x, y, z);
|
||||
if(te instanceof TileHyperCube) {
|
||||
TileHyperCube cb = (TileHyperCube) te;
|
||||
cb.setInputControlMode(RedstoneControlMode.values()[powerInputOrdinal]);
|
||||
cb.setOutputControlMode(RedstoneControlMode.values()[powerOutputOrdinal]);
|
||||
cb.setModeForChannel(SubChannel.POWER, IoMode.values()[powerModeOrdinal]);
|
||||
cb.setModeForChannel(SubChannel.FLUID, IoMode.values()[fluidModeOrdinal]);
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.hypercube;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
@@ -19,7 +20,6 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
@@ -35,13 +35,56 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
private static final float MILLIBUCKET_TRANSMISSION_COST = (float) Config.transceiverBucketTransmissionCost / 1000F;
|
||||
|
||||
private RedstoneControlMode inputControlMode = RedstoneControlMode.IGNORE;
|
||||
public static enum IoMode {
|
||||
|
||||
private RedstoneControlMode outputControlMode = RedstoneControlMode.IGNORE;
|
||||
SEND("Send"),
|
||||
RECIEVE("Recieve"),
|
||||
BOTH("Send & Recieve"),
|
||||
NEITHER("Disabled");
|
||||
|
||||
private boolean powerOutputEnabled = true;
|
||||
public static IoMode next(IoMode mode) {
|
||||
int index = mode.ordinal() + 1;
|
||||
if(index >= values().length) {
|
||||
index = 0;
|
||||
}
|
||||
return values()[index];
|
||||
}
|
||||
|
||||
private boolean powerInputEnabled = true;
|
||||
public static boolean isRecieveEnabled(IoMode mode) {
|
||||
return mode == RECIEVE || mode == BOTH;
|
||||
}
|
||||
|
||||
public static boolean isSendEnabled(IoMode mode) {
|
||||
return mode == SEND || mode == BOTH;
|
||||
}
|
||||
|
||||
private final String unlocalisedName;
|
||||
|
||||
private IoMode(String unlocalisedName) {
|
||||
this.unlocalisedName = unlocalisedName;
|
||||
}
|
||||
|
||||
public boolean isRecieveEnabled() {
|
||||
return isRecieveEnabled(this);
|
||||
}
|
||||
|
||||
public boolean isSendEnabled() {
|
||||
return isSendEnabled(this);
|
||||
}
|
||||
|
||||
public IoMode next() {
|
||||
return next(this);
|
||||
}
|
||||
|
||||
public String getUnlocalisedName() {
|
||||
return unlocalisedName;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum SubChannel {
|
||||
POWER,
|
||||
FLUID
|
||||
}
|
||||
|
||||
private final BasicCapacitor internalCapacitor = new BasicCapacitor(Config.transceiverMaxIO, 25000);
|
||||
|
||||
@@ -66,24 +109,22 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
private float milliBucketsTransfered = 0;
|
||||
|
||||
private EnumMap<SubChannel, IoMode> ioModes = new EnumMap<TileHyperCube.SubChannel, TileHyperCube.IoMode>(SubChannel.class);
|
||||
|
||||
public TileHyperCube() {
|
||||
powerHandler = PowerHandlerUtil.createHandler(internalCapacitor, this, Type.STORAGE);
|
||||
}
|
||||
|
||||
public RedstoneControlMode getInputControlMode() {
|
||||
return inputControlMode;
|
||||
public IoMode getModeForChannel(SubChannel channel) {
|
||||
IoMode mode = ioModes.get(channel);
|
||||
if(mode == null) {
|
||||
return IoMode.NEITHER;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setInputControlMode(RedstoneControlMode powerInputControlMode) {
|
||||
this.inputControlMode = powerInputControlMode;
|
||||
}
|
||||
|
||||
public RedstoneControlMode getOutputControlMode() {
|
||||
return outputControlMode;
|
||||
}
|
||||
|
||||
public void setOutputControlMode(RedstoneControlMode powerOutputControlMode) {
|
||||
this.outputControlMode = powerOutputControlMode;
|
||||
public void setModeForChannel(SubChannel channel, IoMode mode) {
|
||||
ioModes.put(channel, mode);
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
@@ -196,12 +237,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
milliBucketsTransfered = 0;
|
||||
|
||||
powerInputEnabled = RedstoneControlMode.isConditionMet(inputControlMode, this);
|
||||
powerOutputEnabled = RedstoneControlMode.isConditionMet(outputControlMode, this);
|
||||
|
||||
if(powerOutputEnabled) {
|
||||
transmitEnergy();
|
||||
}
|
||||
transmitEnergy();
|
||||
|
||||
balanceCubeNetworkEnergy();
|
||||
|
||||
@@ -241,6 +277,10 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
private boolean transmitEnergy() {
|
||||
|
||||
if(!getModeForChannel(SubChannel.POWER).isRecieveEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(powerHandler.getEnergyStored() <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -290,7 +330,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
if(powerInputEnabled) {
|
||||
if(getModeForChannel(SubChannel.POWER).isSendEnabled()) {
|
||||
return powerHandler;
|
||||
}
|
||||
return getDisabledPowerHandler();
|
||||
@@ -311,7 +351,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if(powerInputEnabled) {
|
||||
if(getModeForChannel(SubChannel.POWER).isSendEnabled()) {
|
||||
return PowerHandlerUtil.recieveRedstoneFlux(from, powerHandler, maxReceive, simulate);
|
||||
}
|
||||
return 0;
|
||||
@@ -366,13 +406,13 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(!powerInputEnabled) {
|
||||
if(!canSendFluid()) {
|
||||
return 0;
|
||||
}
|
||||
FluidStack in = resource.copy();
|
||||
int result = 0;
|
||||
for (NetworkFluidHandler h : getNetworkHandlers()) {
|
||||
if(h.node.powerOutputEnabled && h.handler.canFill(h.dirOp, in.getFluid())) {
|
||||
if(h.node.canRecieveFluid() && h.handler.canFill(h.dirOp, in.getFluid())) {
|
||||
int filled = h.handler.fill(h.dirOp, in, doFill);
|
||||
in.amount -= filled;
|
||||
result += filled;
|
||||
@@ -384,16 +424,32 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean canSendFluid() {
|
||||
return getModeForChannel(SubChannel.FLUID).isSendEnabled();
|
||||
}
|
||||
|
||||
private boolean canSendPower() {
|
||||
return getModeForChannel(SubChannel.POWER).isSendEnabled();
|
||||
}
|
||||
|
||||
private boolean canRecieveFluid() {
|
||||
return getModeForChannel(SubChannel.FLUID).isRecieveEnabled();
|
||||
}
|
||||
|
||||
private boolean canRecievePower() {
|
||||
return getModeForChannel(SubChannel.POWER).isRecieveEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if(!powerOutputEnabled || resource == null) {
|
||||
if(!canRecieveFluid() || resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack in = resource.copy();
|
||||
FluidStack result = null;
|
||||
for (NetworkFluidHandler h : getNetworkHandlers()) {
|
||||
if(h.node.powerInputEnabled && h.handler.canDrain(h.dirOp, in.getFluid())) {
|
||||
if(h.node.canSendFluid() && h.handler.canDrain(h.dirOp, in.getFluid())) {
|
||||
FluidStack res = h.handler.drain(h.dirOp, in, false);
|
||||
if(res != null) {
|
||||
if(result == null) {
|
||||
@@ -417,13 +473,13 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrainIn, boolean doDrain) {
|
||||
if(!powerOutputEnabled) {
|
||||
if(!canRecieveFluid()) {
|
||||
return null;
|
||||
}
|
||||
int maxDrain = maxDrainIn;
|
||||
FluidStack result = null;
|
||||
for (NetworkFluidHandler h : getNetworkHandlers()) {
|
||||
if(h.node.powerInputEnabled) {
|
||||
if(h.node.canSendFluid()) {
|
||||
FluidStack res = h.handler.drain(h.dirOp, maxDrain, false);
|
||||
if(res != null) {
|
||||
if(result == null) {
|
||||
@@ -447,11 +503,11 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
if(!powerInputEnabled) {
|
||||
if(!canSendFluid()) {
|
||||
return false;
|
||||
}
|
||||
for (NetworkFluidHandler h : getNetworkHandlers()) {
|
||||
if(h.node.powerOutputEnabled) {
|
||||
if(h.node.canRecieveFluid()) {
|
||||
if(h.handler.canFill(h.dirOp, fluid)) {
|
||||
return true;
|
||||
}
|
||||
@@ -462,11 +518,11 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
if(!powerOutputEnabled) {
|
||||
if(!canRecieveFluid()) {
|
||||
return false;
|
||||
}
|
||||
for (NetworkFluidHandler h : getNetworkHandlers()) {
|
||||
if(h.node.powerInputEnabled) {
|
||||
if(h.node.canSendFluid()) {
|
||||
if(h.handler.canDrain(h.dirOp, fluid)) {
|
||||
return true;
|
||||
}
|
||||
@@ -535,9 +591,6 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
super.readFromNBT(nbtRoot);
|
||||
powerHandler.setEnergy(nbtRoot.getFloat("storedEnergy"));
|
||||
inputControlMode = RedstoneControlMode.values()[nbtRoot.getShort("inputControlMode")];
|
||||
outputControlMode = RedstoneControlMode.values()[nbtRoot.getShort("outputControlMode")];
|
||||
|
||||
String channelName = nbtRoot.getString("channelName");
|
||||
String channelUser = nbtRoot.getString("channelUser");
|
||||
if(channelName != null && !channelName.isEmpty()) {
|
||||
@@ -547,14 +600,19 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
}
|
||||
|
||||
owner = nbtRoot.getString("owner");
|
||||
|
||||
for (SubChannel subChannel : SubChannel.values()) {
|
||||
String key = "subChannel" + subChannel.ordinal();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
setModeForChannel(subChannel, IoMode.values()[nbtRoot.getShort(key)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeToNBT(nbtRoot);
|
||||
nbtRoot.setFloat("storedEnergy", powerHandler.getEnergyStored());
|
||||
nbtRoot.setShort("inputControlMode", (short) inputControlMode.ordinal());
|
||||
nbtRoot.setShort("outputControlMode", (short) outputControlMode.ordinal());
|
||||
if(channel != null) {
|
||||
nbtRoot.setString("channelName", channel.name);
|
||||
if(channel.user != null) {
|
||||
@@ -564,6 +622,11 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
if(owner != null && !(owner.isEmpty())) {
|
||||
nbtRoot.setString("owner", owner);
|
||||
}
|
||||
|
||||
for (SubChannel subChannel : SubChannel.values()) {
|
||||
IoMode mode = getModeForChannel(subChannel);
|
||||
nbtRoot.setShort("subChannel" + subChannel.ordinal(), (short) mode.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 35 KiB |
Reference in new issue
Block a user