mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Merge pull request #26 from dvdmandt/master
Initial support for channels on EnderFluidConduits
This commit is contained in:
7 files changed
+280
-41
No files matched your search
@@ -6,6 +6,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import crazypants.enderio.conduit.gui.*;
|
||||
import mods.immibis.core.api.multipart.IMultipartRenderingBlockMarker;
|
||||
import mods.immibis.core.api.multipart.IMultipartSystem;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -51,12 +52,6 @@ import crazypants.enderio.api.tool.ITool;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade.FacadeType;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitConnectorType;
|
||||
import crazypants.enderio.conduit.gui.ExternalConnectionContainer;
|
||||
import crazypants.enderio.conduit.gui.GuiExternalConnection;
|
||||
import crazypants.enderio.conduit.gui.GuiExternalConnectionSelector;
|
||||
import crazypants.enderio.conduit.gui.PacketFluidFilter;
|
||||
import crazypants.enderio.conduit.gui.PacketOpenConduitUI;
|
||||
import crazypants.enderio.conduit.gui.PacketSlotVisibility;
|
||||
import crazypants.enderio.conduit.gui.item.PacketExistingItemFilterSnapshot;
|
||||
import crazypants.enderio.conduit.gui.item.PacketModItemFilter;
|
||||
import crazypants.enderio.conduit.liquid.PacketFluidLevel;
|
||||
@@ -98,6 +93,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
PacketHandler.INSTANCE.registerMessage(PacketExistingItemFilterSnapshot.class, PacketExistingItemFilterSnapshot.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketModItemFilter.class, PacketModItemFilter.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketFluidFilter.class, PacketFluidFilter.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketFluidChannel.class, PacketFluidChannel.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketRedstoneConduitSignalColor.class, PacketRedstoneConduitSignalColor.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketRedstoneConduitOutputStrength.class, PacketRedstoneConduitOutputStrength.class, PacketHandler.nextID(),
|
||||
Side.SERVER);
|
||||
|
||||
@@ -48,9 +48,12 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
private static final int NEXT_FILTER_ID = 989322;
|
||||
|
||||
private static final int ID_CHANNEL = GuiExternalConnection.nextButtonId();
|
||||
|
||||
private final RedstoneModeButton rsB;
|
||||
private final ToggleButton roundRobinB;
|
||||
private final ColorButton colorB;
|
||||
private ColorButton channelB;
|
||||
|
||||
private static final String autoExtractStr = EnderIO.lang.localize("gui.conduit.fluid.autoExtract");
|
||||
private static final String filterStr = EnderIO.lang.localize("gui.conduit.fluid.filter");
|
||||
@@ -76,9 +79,11 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
eConduit = (EnderLiquidConduit) con;
|
||||
isEnder = true;
|
||||
|
||||
int x = gui.getXSize() - 20;
|
||||
|
||||
int x = 52;
|
||||
int y = customTop;
|
||||
|
||||
|
||||
inOutNextB = MultiIconButton.createRightArrowButton(gui, NEXT_FILTER_ID, x, y);
|
||||
|
||||
x = filterX - 20;
|
||||
@@ -91,9 +96,17 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
gui.getContainer().setInventorySlotsVisible(false);
|
||||
}
|
||||
|
||||
int x = gap + gui.getFontRenderer().getStringWidth(autoExtractStr) + gap * 2;
|
||||
int x = 66;
|
||||
int y = customTop;
|
||||
|
||||
if(isEnder)
|
||||
{
|
||||
channelB = new ColorButton(gui, ID_CHANNEL, x, y);
|
||||
channelB.setColorIndex(0);
|
||||
channelB.setToolTipHeading(EnderIO.lang.localize("gui.conduit.item.channel"));
|
||||
x += channelB.getWidth() + gap;
|
||||
}
|
||||
|
||||
rsB = new RedstoneModeButton(gui, ID_REDSTONE_BUTTON, x, y, new IRedstoneModeControlable() {
|
||||
|
||||
@Override
|
||||
@@ -147,6 +160,14 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
toggleBlacklist();
|
||||
} else if(guiButton.id == NEXT_FILTER_ID) {
|
||||
inOutShowIn = !inOutShowIn;
|
||||
if(channelB != null) {
|
||||
channelB.onGuiInit();
|
||||
if(isInput()) {
|
||||
channelB.setColorIndex(eConduit.getInputColor(gui.getDir()).ordinal());
|
||||
} else {
|
||||
channelB.setColorIndex(eConduit.getOutputColor(gui.getDir()).ordinal());
|
||||
}
|
||||
}
|
||||
if(isInput()) {
|
||||
if (isEnder) {
|
||||
roundRobinB.onGuiInit();
|
||||
@@ -163,6 +184,18 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
if(isFilterVisible()) {
|
||||
updateWhiteListButton(eConduit.getFilter(gui.getDir(), isInput()));
|
||||
}
|
||||
} else if(guiButton.id == ID_CHANNEL) {
|
||||
if(isEnder) {
|
||||
|
||||
DyeColor col = DyeColor.values()[channelB.getColorIndex()];
|
||||
|
||||
if (isInput()) {
|
||||
eConduit.setInputColor(gui.getDir(), col);
|
||||
} else {
|
||||
eConduit.setOutputColor(gui.getDir(), col);
|
||||
}
|
||||
setConduitChannel(col);
|
||||
}
|
||||
} else if(guiButton.id == ID_ROUND_ROBIN_BUTTON) {
|
||||
if (isEnder && isInput()) {
|
||||
final boolean selected = roundRobinB.isSelected();
|
||||
@@ -215,8 +248,18 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
protected void setConduitFilter(FluidFilter filter) {
|
||||
eConduit.setFilter(gui.getDir(), filter, isInput());
|
||||
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFluidFilter(eConduit, gui.getDir(), filter, isInput()));
|
||||
}
|
||||
protected void setConduitChannel(DyeColor channel) {
|
||||
if(isInput()) {
|
||||
eConduit.setInputColor(gui.getDir(), channel);
|
||||
} else {
|
||||
eConduit.setOutputColor(gui.getDir(), channel);
|
||||
}
|
||||
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFluidChannel(eConduit, gui.getDir(), isInput(), channel));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initCustomOptions() {
|
||||
@@ -235,6 +278,16 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
if(conduit.getConnectionMode(gui.getDir()) == ConnectionMode.DISABLED) {
|
||||
channelB.detach();
|
||||
} else {
|
||||
channelB.onGuiInit();
|
||||
if (isInput()) {
|
||||
channelB.setColorIndex(eConduit.getInputColor(gui.getDir()).ordinal());
|
||||
} else {
|
||||
channelB.setColorIndex(eConduit.getOutputColor(gui.getDir()).ordinal());
|
||||
}
|
||||
}
|
||||
if(isInput()) {
|
||||
roundRobinB.onGuiInit();
|
||||
roundRobinB.setSelected(eConduit.isRoundRobin(gui.getDir()));
|
||||
@@ -283,25 +336,23 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
}
|
||||
inOutNextB.detach();
|
||||
whiteListB.detach();
|
||||
channelB.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderCustomOptions(int top, float par1, int par2, int par3) {
|
||||
boolean isInput = isInput();
|
||||
if(isInput) {
|
||||
int x = gui.getGuiLeft() + gap + gui.getFontRenderer().getStringWidth(autoExtractStr) + gap + 2;
|
||||
int y = top;
|
||||
gui.getFontRenderer().drawString(autoExtractStr, left, y, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
}
|
||||
if(isEnder && isFilterVisible()) {
|
||||
|
||||
String inOutStr = EnderIO.lang.localize("gui.conduit.ioMode.output");
|
||||
if(conduit.getConnectionMode(gui.getDir()) == ConnectionMode.IN_OUT) {
|
||||
String inOutStr = inOutShowIn ? EnderIO.lang.localize("gui.conduit.ioMode.input") : EnderIO.lang.localize("gui.conduit.ioMode.output");
|
||||
int x = gui.getGuiLeft() + gui.getXSize() - 20 - 5 - gui.getFontRenderer().getStringWidth(inOutStr);
|
||||
int y = top;
|
||||
gui.getFontRenderer().drawString(inOutStr, x, y, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
inOutStr = inOutShowIn ? EnderIO.lang.localize("gui.conduit.ioMode.input") : EnderIO.lang.localize("gui.conduit.ioMode.output");
|
||||
} else if(conduit.getConnectionMode(gui.getDir()) == ConnectionMode.INPUT){
|
||||
inOutStr = EnderIO.lang.localize("gui.conduit.ioMode.input");
|
||||
}
|
||||
int x = left;
|
||||
int y = top;
|
||||
gui.getFontRenderer().drawString(inOutStr, x, y, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
gui.bindGuiTexture(1);
|
||||
@@ -309,8 +360,8 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
FontRenderer fr = gui.getFontRenderer();
|
||||
int sw = fr.getStringWidth(filterStr);
|
||||
int x = (gui.width / 2) - sw / 2;
|
||||
int y = top + 20;
|
||||
x = (gui.width / 2) - sw / 2;
|
||||
y = top + 20;
|
||||
fr.drawString(filterStr, x, y, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
|
||||
x = gui.getGuiLeft() + filterX;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
import com.enderio.core.common.util.DyeColor;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
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.conduit.liquid.EnderLiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.FluidFilter;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.packet.AbstractConduitPacket;
|
||||
import crazypants.enderio.conduit.packet.ConTypeEnum;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class PacketFluidChannel extends AbstractConduitPacket<ILiquidConduit> implements IMessageHandler<PacketFluidChannel, IMessage>{
|
||||
|
||||
private ForgeDirection dir;
|
||||
private boolean isInput;
|
||||
|
||||
private DyeColor channel;
|
||||
|
||||
public PacketFluidChannel() {
|
||||
}
|
||||
|
||||
public PacketFluidChannel(EnderLiquidConduit eConduit, ForgeDirection dir, boolean isInput, DyeColor channel) {
|
||||
super(eConduit.getBundle().getEntity(), ConTypeEnum.FLUID);
|
||||
this.dir = dir;
|
||||
this.isInput = isInput;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeShort(dir.ordinal());
|
||||
buf.writeBoolean(isInput);
|
||||
buf.writeShort(channel.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
dir = ForgeDirection.values()[buf.readShort()];
|
||||
isInput = buf.readBoolean();
|
||||
channel = DyeColor.values()[buf.readShort()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketFluidChannel message, MessageContext ctx) {
|
||||
ILiquidConduit conduit = message.getTileCasted(ctx);
|
||||
if(! (conduit instanceof EnderLiquidConduit)) {
|
||||
return null;
|
||||
}
|
||||
EnderLiquidConduit eCon = (EnderLiquidConduit)conduit;
|
||||
|
||||
if(message.isInput)
|
||||
eCon.setInputColor(message.dir, message.channel);
|
||||
else
|
||||
eCon.setOutputColor(message.dir, message.channel);
|
||||
|
||||
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
}
|
||||
};
|
||||
|
||||
x += channelB.getWidth() + 4;
|
||||
x += channelB.getWidth() + gap;
|
||||
priLeft = x - 8;
|
||||
|
||||
rsB = new RedstoneModeButton(gui, ID_REDSTONE_BUTTON, x, y, new IRedstoneModeControlable() {
|
||||
@@ -149,18 +149,18 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
}
|
||||
});
|
||||
|
||||
x += rsB.getWidth() + 4;
|
||||
x += rsB.getWidth() + gap;
|
||||
colorB = new ColorButton(gui, ID_COLOR_BUTTON, x, y);
|
||||
colorB.setColorIndex(itemConduit.getExtractionSignalColor(gui.getDir()).ordinal());
|
||||
colorB.setToolTipHeading(EnderIO.lang.localize("gui.conduit.item.sigCol"));
|
||||
|
||||
x += 4 + colorB.getWidth();
|
||||
x += gap + colorB.getWidth();
|
||||
roundRobinB = new ToggleButton(gui, ID_ROUND_ROBIN, x, y, IconEIO.ROUND_ROBIN_OFF, IconEIO.ROUND_ROBIN);
|
||||
roundRobinB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.roundRobinEnabled"));
|
||||
roundRobinB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.roundRobinDisabled"));
|
||||
roundRobinB.setPaintSelectedBorder(false);
|
||||
|
||||
x += 4 + roundRobinB.getWidth();
|
||||
x += gap + roundRobinB.getWidth();
|
||||
loopB = new ToggleButton(gui, ID_LOOP, x, y, IconEIO.LOOP_OFF, IconEIO.LOOP);
|
||||
loopB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.selfFeedEnabled"));
|
||||
loopB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.selfFeedDisabled"));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import com.enderio.core.common.util.DyeColor;
|
||||
|
||||
import com.enderio.core.client.render.IconUtil;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -7,8 +9,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.*;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.item.ItemConduit;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,9 +34,12 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
|
||||
public static final String ICON_KEY = "enderio:liquidConduitEnder";
|
||||
public static final String ICON_CORE_KEY = "enderio:liquidConduitCoreEnder";
|
||||
public static final String ICON_EXTRACT_KEY = "enderio:liquidConduitAdvancedInput";
|
||||
public static final String ICON_INSERT_KEY = "enderio:liquidConduitAdvancedOutput";
|
||||
public static final String ICON_IN_OUT_KEY = "enderio:liquidConduitAdvancedInOut";
|
||||
|
||||
public static final String ICON_KEY_INPUT = ItemConduit.ICON_KEY_INPUT;
|
||||
public static final String ICON_KEY_OUTPUT = ItemConduit.ICON_KEY_OUTPUT;
|
||||
public static final String ICON_KEY_IN_OUT_BG = ItemConduit.ICON_KEY_IN_OUT_BG;
|
||||
public static final String ICON_KEY_IN_OUT_OUT = ItemConduit.ICON_KEY_IN_OUT_OUT;
|
||||
public static final String ICON_KEY_IN_OUT_IN = ItemConduit.ICON_KEY_IN_OUT_IN;
|
||||
|
||||
static final Map<String, IIcon> ICONS = new HashMap<String, IIcon>();
|
||||
|
||||
@@ -44,9 +51,12 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
public void registerIcons(IIconRegister register) {
|
||||
ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY));
|
||||
ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY));
|
||||
ICONS.put(ICON_EXTRACT_KEY, register.registerIcon(ICON_EXTRACT_KEY));
|
||||
ICONS.put(ICON_INSERT_KEY, register.registerIcon(ICON_INSERT_KEY));
|
||||
ICONS.put(ICON_IN_OUT_KEY, register.registerIcon(ICON_IN_OUT_KEY));
|
||||
|
||||
ICONS.put(ICON_KEY_INPUT, register.registerIcon(ICON_KEY_INPUT));
|
||||
ICONS.put(ICON_KEY_OUTPUT, register.registerIcon(ICON_KEY_OUTPUT));
|
||||
ICONS.put(ICON_KEY_IN_OUT_OUT, register.registerIcon(ICON_KEY_IN_OUT_OUT));
|
||||
ICONS.put(ICON_KEY_IN_OUT_IN, register.registerIcon(ICON_KEY_IN_OUT_IN));
|
||||
ICONS.put(ICON_KEY_IN_OUT_BG, register.registerIcon(ICON_KEY_IN_OUT_BG));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +72,12 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
|
||||
private final EnumMap<ForgeDirection, FluidFilter> outputFilters = new EnumMap<ForgeDirection, FluidFilter>(ForgeDirection.class);
|
||||
private final EnumMap<ForgeDirection, FluidFilter> inputFilters = new EnumMap<ForgeDirection, FluidFilter>(ForgeDirection.class);
|
||||
|
||||
protected final EnumMap<ForgeDirection, DyeColor> outputColors = new EnumMap<ForgeDirection, DyeColor>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, DyeColor> inputColors = new EnumMap<ForgeDirection, DyeColor>(ForgeDirection.class);
|
||||
|
||||
private int roundRobin = 0;
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(EnderIO.itemLiquidConduit, 1, 2);
|
||||
@@ -159,17 +174,21 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
}
|
||||
|
||||
public IIcon getTextureForInputMode() {
|
||||
return ICONS.get(ICON_EXTRACT_KEY);
|
||||
return ICONS.get(ICON_KEY_INPUT);
|
||||
}
|
||||
|
||||
public IIcon getTextureForOutputMode() {
|
||||
return ICONS.get(ICON_INSERT_KEY);
|
||||
return ICONS.get(ICON_KEY_OUTPUT);
|
||||
}
|
||||
|
||||
public IIcon getTextureForInOutMode() {
|
||||
return ICONS.get(ICON_IN_OUT_KEY);
|
||||
|
||||
public IIcon getTextureForInOutMode(boolean input) {
|
||||
return input ? ICONS.get(ICON_KEY_IN_OUT_IN) : ICONS.get(ICON_KEY_IN_OUT_OUT);
|
||||
}
|
||||
|
||||
public IIcon getTextureForInOutBackground() {
|
||||
return ICONS.get(ICON_KEY_IN_OUT_BG);
|
||||
}
|
||||
@Override
|
||||
public IIcon getTransmitionTextureForState(CollidableComponent component) {
|
||||
return null;
|
||||
@@ -292,15 +311,60 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
}
|
||||
return network.getTankInfo(this, from);
|
||||
}
|
||||
//@Override
|
||||
public DyeColor getInputColor(ForgeDirection dir) {
|
||||
DyeColor result = inputColors.get(dir);
|
||||
if(result == null) {
|
||||
return DyeColor.GREEN;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public DyeColor getOutputColor(ForgeDirection dir) {
|
||||
DyeColor result = outputColors.get(dir);
|
||||
if(result == null) {
|
||||
return DyeColor.GREEN;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//@Override
|
||||
public void setInputColor(ForgeDirection dir, DyeColor col) {
|
||||
inputColors.put(dir, col);
|
||||
if(network != null) {
|
||||
network.notifyNetworkOfUpdate();
|
||||
}
|
||||
setClientStateDirty();
|
||||
collidablesDirty = true;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setOutputColor(ForgeDirection dir, DyeColor col) {
|
||||
outputColors.put(dir, col);
|
||||
if(network != null) {
|
||||
network.notifyNetworkOfUpdate();
|
||||
}
|
||||
setClientStateDirty();
|
||||
collidablesDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
|
||||
super.readTypeSettings(dir, dataRoot);
|
||||
|
||||
if (dataRoot.hasKey("inputColor")) {
|
||||
setInputColor(dir, DyeColor.values()[dataRoot.getShort("inputColor")]);
|
||||
}
|
||||
if (dataRoot.hasKey("outputColor")) {
|
||||
setOutputColor(dir, DyeColor.values()[dataRoot.getShort("outputColor")]);
|
||||
}
|
||||
|
||||
if(dataRoot.hasKey("roundRobin")) {
|
||||
setRoundRobin(dir, dataRoot.getBoolean("roundRobin"));
|
||||
} else {
|
||||
setRoundRobin(dir, true);
|
||||
}
|
||||
|
||||
if (dataRoot.hasKey("outputFilters")) {
|
||||
FluidFilter out = new FluidFilter();
|
||||
out.readFromNBT(dataRoot.getCompoundTag("outputFilters"));
|
||||
@@ -316,7 +380,12 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
@Override
|
||||
protected void writeTypeSettingsToNbt(ForgeDirection dir, NBTTagCompound dataRoot) {
|
||||
super.writeTypeSettingsToNbt(dir, dataRoot);
|
||||
|
||||
dataRoot.setShort("inputColor", (short)getInputColor(dir).ordinal());
|
||||
dataRoot.setShort("outputColor", (short)getOutputColor(dir).ordinal());
|
||||
|
||||
dataRoot.setBoolean("roundRobin", isRoundRobin(dir));
|
||||
|
||||
FluidFilter out = outputFilters.get(dir);
|
||||
if (out != null) {
|
||||
NBTTagCompound outTag = new NBTTagCompound();
|
||||
@@ -329,6 +398,7 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
in.writeToNBT(inTag);
|
||||
dataRoot.setTag("inputFilters", inTag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -355,6 +425,19 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entry<ForgeDirection, DyeColor> entry : inputColors.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
short ord = (short) entry.getValue().ordinal();
|
||||
nbtRoot.setShort("inSC." + entry.getKey().name(), ord);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, DyeColor> entry : outputColors.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
short ord = (short) entry.getValue().ordinal();
|
||||
nbtRoot.setShort("outSC." + entry.getKey().name(), ord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -385,6 +468,22 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
outputFilters.put(dir, f);
|
||||
}
|
||||
}
|
||||
|
||||
key = "inSC." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
short ord = nbtRoot.getShort(key);
|
||||
if(ord >= 0 && ord < DyeColor.values().length) {
|
||||
inputColors.put(dir, DyeColor.values()[ord]);
|
||||
}
|
||||
}
|
||||
|
||||
key = "outSC." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
short ord = nbtRoot.getShort(key);
|
||||
if(ord >= 0 && ord < DyeColor.values().length) {
|
||||
outputColors.put(dir, DyeColor.values()[ord]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
|
||||
TankIterator iterator;
|
||||
for (iterator = getIteratorForTank(tank).start(); iterator.hasNext(); ) {
|
||||
NetworkTank target = iterator.next();
|
||||
if (!target.equals(tank) && target.acceptsOuput && target.isValid() && matchedFilter(resource, target.con, target.conDir, false)) {
|
||||
if (!target.equals(tank) && target.con.getOutputColor(target.conDir).equals(tank.con.getInputColor(tank.conDir)) && target.acceptsOuput && target.isValid() && matchedFilter(resource, target.con, target.conDir, false)) {
|
||||
int vol = target.externalTank.fill(target.tankDir, resource.copy(), doFill);
|
||||
remaining -= vol;
|
||||
filled += vol;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import com.enderio.core.common.util.DyeColor;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
@@ -26,19 +29,42 @@ public class EnderLiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick,
|
||||
float worldLight, RenderBlocks rb) {
|
||||
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb);
|
||||
|
||||
EnderLiquidConduit pc = (EnderLiquidConduit) conduit;
|
||||
for (ForgeDirection dir : conduit.getExternalConnections()) {
|
||||
IIcon tex = null;
|
||||
DyeColor inChannel = null;
|
||||
DyeColor outChannel = null;
|
||||
IIcon inTex = null;
|
||||
IIcon outTex = null;
|
||||
boolean render = true;
|
||||
if(conduit.getConnectionMode(dir) == ConnectionMode.INPUT) {
|
||||
tex = pc.getTextureForInputMode();
|
||||
inTex = pc.getTextureForInputMode();
|
||||
inChannel = pc.getInputColor(dir);
|
||||
} else if(conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
|
||||
tex = pc.getTextureForOutputMode();
|
||||
outTex = pc.getTextureForOutputMode();
|
||||
outChannel = pc.getOutputColor(dir);
|
||||
} else if(conduit.getConnectionMode(dir) == ConnectionMode.IN_OUT) {
|
||||
tex = pc.getTextureForInOutMode();
|
||||
inTex = pc.getTextureForInOutMode(true);
|
||||
outTex = pc.getTextureForInOutMode(false);
|
||||
inChannel = pc.getInputColor(dir);
|
||||
outChannel = pc.getOutputColor(dir);
|
||||
} else {
|
||||
render = false;
|
||||
}
|
||||
if(tex != null) {
|
||||
if(render && !rb.hasOverrideBlockTexture()) {
|
||||
Offset offset = te.getOffset(ILiquidConduit.class, dir);
|
||||
ConnectionModeGeometry.renderModeConnector(dir, offset, tex, true);
|
||||
ConnectionModeGeometry.renderModeConnector(dir, offset, pc.getTextureForInOutBackground(), true);
|
||||
|
||||
if(inChannel != null) {
|
||||
Tessellator.instance.setColorOpaque_I(inChannel.getColor());
|
||||
ConnectionModeGeometry.renderModeConnector(dir, offset, inTex, false);
|
||||
}
|
||||
if(outChannel != null) {
|
||||
Tessellator.instance.setColorOpaque_I(outChannel.getColor());
|
||||
ConnectionModeGeometry.renderModeConnector(dir, offset, outTex, false);
|
||||
}
|
||||
|
||||
Tessellator.instance.setColorOpaque_F(1f, 1f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user