mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
Ender Fluid Conduit filters and auto extract can now be used when in/out mode
This commit is contained in:
1 parent
7efe4a6682
commit
0a7220e578
6 files changed
+109
-44
No files matched your search
@@ -146,6 +146,12 @@ public abstract class AbstractConduit implements IConduit {
|
||||
|
||||
@Override
|
||||
public boolean hasConnectionMode(ConnectionMode mode) {
|
||||
if(mode == null) {
|
||||
return false;
|
||||
}
|
||||
if(mode == getDefaultConnectionMode() && conectionModes.size() != 6) {
|
||||
return true;
|
||||
}
|
||||
for (ConnectionMode cm : conectionModes.values()) {
|
||||
if(cm == mode) {
|
||||
return true;
|
||||
|
||||
@@ -22,6 +22,7 @@ import crazypants.enderio.conduit.liquid.FluidFilter;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.packet.PacketExtractMode;
|
||||
import crazypants.enderio.gui.ColorButton;
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.RedstoneModeButton;
|
||||
import crazypants.enderio.machine.IRedstoneModeControlable;
|
||||
@@ -39,6 +40,8 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
private static final int ID_COLOR_BUTTON = GuiExternalConnection.nextButtonId();
|
||||
|
||||
private static final int NEXT_FILTER_ID = 989322;
|
||||
|
||||
private RedstoneModeButton rsB;
|
||||
|
||||
private ColorButton colorB;
|
||||
@@ -55,6 +58,9 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
private Rectangle filterBounds = new Rectangle(filterX, filterY, 90, 18);
|
||||
private GuiToolTip[] filterToolTips;
|
||||
|
||||
private boolean inOutShowIn = true;
|
||||
private IconButtonEIO inOutNextB;
|
||||
|
||||
protected LiquidSettings(final GuiExternalConnection gui, IConduit con) {
|
||||
super(IconEIO.WRENCH_OVERLAY_FLUID, Lang.localize("itemLiquidConduit.name"), gui, con);
|
||||
|
||||
@@ -62,10 +68,13 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
if(con instanceof EnderLiquidConduit) {
|
||||
eConduit = (EnderLiquidConduit) con;
|
||||
isEnder = true;
|
||||
if(isFilterVisible()) {
|
||||
gui.getContainer().setInventorySlotsVisible(true);
|
||||
}
|
||||
addFilterTooltips();
|
||||
|
||||
int x = gui.getXSize() - 20;
|
||||
int y = customTop;
|
||||
|
||||
inOutNextB = new IconButtonEIO(gui, NEXT_FILTER_ID, x, y, IconEIO.RIGHT_ARROW);
|
||||
inOutNextB.setSize(8, 16);
|
||||
|
||||
} else {
|
||||
isEnder = false;
|
||||
gui.getContainer().setInventorySlotsVisible(false);
|
||||
@@ -100,8 +109,8 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
private void addFilterTooltips() {
|
||||
filterToolTips = new GuiToolTip[5];
|
||||
for(int i=0;i<5;i++) {
|
||||
Rectangle bound = new Rectangle(filterX + (i*18), filterY, 18, 18);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Rectangle bound = new Rectangle(filterX + (i * 18), filterY, 18, 18);
|
||||
filterToolTips[i] = new FilterToolTip(bound, i);
|
||||
gui.addToolTip(filterToolTips[i]);
|
||||
}
|
||||
@@ -113,26 +122,22 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
if(guiButton.id == ID_COLOR_BUTTON) {
|
||||
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.values()[colorB.getColorIndex()]);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(conduit, gui.getDir()));
|
||||
} else if(guiButton.id == NEXT_FILTER_ID) {
|
||||
inOutShowIn = !inOutShowIn;
|
||||
if(isInput()) {
|
||||
rsB.onGuiInit();
|
||||
colorB.onGuiInit();
|
||||
} else {
|
||||
rsB.detach();
|
||||
colorB.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connectionModeChanged(ConnectionMode conectionMode) {
|
||||
super.connectionModeChanged(conectionMode);
|
||||
if(conectionMode == ConnectionMode.INPUT) {
|
||||
rsB.onGuiInit();
|
||||
colorB.onGuiInit();
|
||||
} else {
|
||||
rsB.detach();
|
||||
colorB.detach();
|
||||
}
|
||||
|
||||
if(isEnder && isFilterVisible()) {
|
||||
gui.getContainer().setInventorySlotsVisible(true);
|
||||
} else {
|
||||
gui.getContainer().setInventorySlotsVisible(false);
|
||||
}
|
||||
|
||||
updateGuiVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +153,7 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
}
|
||||
if(filter == null) {
|
||||
filter = new FluidFilter();
|
||||
}
|
||||
}
|
||||
if(filterBounds.contains(x, y)) {
|
||||
int slot = (x - filterX) / 18;
|
||||
filter.setFluid(slot, st);
|
||||
@@ -158,18 +163,51 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initCustomOptions() {
|
||||
updateGuiVisibility();
|
||||
}
|
||||
|
||||
private void updateGuiVisibility() {
|
||||
deactivate();
|
||||
|
||||
if(isInput()) {
|
||||
rsB.onGuiInit();
|
||||
colorB.onGuiInit();
|
||||
}
|
||||
|
||||
if(!isEnder) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(isFilterVisible()) {
|
||||
gui.getContainer().setInventorySlotsVisible(true);
|
||||
addFilterTooltips();
|
||||
} else {
|
||||
gui.getContainer().setInventorySlotsVisible(false);
|
||||
}
|
||||
|
||||
ConnectionMode mode = con.getConnectionMode(gui.getDir());
|
||||
if(mode == ConnectionMode.IN_OUT) {
|
||||
inOutNextB.onGuiInit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
rsB.setToolTip((String[]) null);
|
||||
colorB.setToolTip((String[]) null);
|
||||
|
||||
rsB.detach();
|
||||
colorB.detach();
|
||||
if(isEnder) {
|
||||
gui.getContainer().setInventorySlotsVisible(false);
|
||||
for(GuiToolTip tt : filterToolTips) {
|
||||
if(tt != null) {
|
||||
gui.removeToolTip(tt);
|
||||
if(filterToolTips != null) {
|
||||
for (GuiToolTip tt : filterToolTips) {
|
||||
if(tt != null) {
|
||||
gui.removeToolTip(tt);
|
||||
}
|
||||
}
|
||||
}
|
||||
inOutNextB.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,15 +216,22 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
boolean isInput = isInput();
|
||||
if(isInput) {
|
||||
int x = gui.getGuiLeft() + gap + gui.getFontRenderer().getStringWidth(autoExtractStr) + gap + 2;
|
||||
int y = customTop;
|
||||
gui.getFontRenderer().drawString(autoExtractStr, left, top, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
int y = top;
|
||||
gui.getFontRenderer().drawString(autoExtractStr, left, y, ColorUtil.getRGB(Color.DARK_GRAY));
|
||||
}
|
||||
if(isEnder && isFilterVisible()) {
|
||||
|
||||
if(conduit.getConnectionMode(gui.getDir()) == ConnectionMode.IN_OUT) {
|
||||
String inOutStr = inOutShowIn ? "Extract" : "Insert";
|
||||
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));
|
||||
}
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft(), gui.getGuiTop() + 55, 0, 55, gui.getXSize(), 145);
|
||||
|
||||
|
||||
FontRenderer fr = gui.getFontRenderer();
|
||||
int sw = fr.getStringWidth(filterStr);
|
||||
int x = (gui.width / 2) - sw / 2;
|
||||
@@ -207,7 +252,6 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
renderFluid(f, x + (i * 18), y);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,7 +267,12 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
}
|
||||
|
||||
private boolean isInput() {
|
||||
return conduit.getConnectionMode(gui.getDir()) == ConnectionMode.INPUT;
|
||||
ConnectionMode mode = conduit.getConnectionMode(gui.getDir());
|
||||
return mode != ConnectionMode.DISABLED &&
|
||||
(
|
||||
mode == ConnectionMode.INPUT ||
|
||||
(conduit.getConnectionMode(gui.getDir()) == ConnectionMode.IN_OUT && inOutShowIn)
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isFilterVisible() {
|
||||
@@ -231,16 +280,16 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
return false;
|
||||
}
|
||||
ConnectionMode mode = conduit.getConnectionMode(gui.getDir());
|
||||
return mode == ConnectionMode.INPUT || mode == ConnectionMode.OUTPUT;
|
||||
return mode == ConnectionMode.INPUT || mode == ConnectionMode.OUTPUT || mode == ConnectionMode.IN_OUT;
|
||||
}
|
||||
|
||||
|
||||
private class FilterToolTip extends GuiToolTip {
|
||||
|
||||
int index;
|
||||
|
||||
|
||||
public FilterToolTip(Rectangle bounds, int index) {
|
||||
super(bounds, (String[])null);
|
||||
this.index = index;
|
||||
super(bounds, (String[]) null);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,7 +306,7 @@ public class LiquidSettings extends BaseSettingsPanel {
|
||||
}
|
||||
return Collections.singletonList(filter.getFluidAt(index).getLocalizedName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
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";
|
||||
|
||||
static final Map<String, IIcon> ICONS = new HashMap<String, IIcon>();
|
||||
|
||||
@@ -48,6 +49,7 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,6 +169,10 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
return ICONS.get(ICON_INSERT_KEY);
|
||||
}
|
||||
|
||||
public IIcon getTextureForInOutMode() {
|
||||
return ICONS.get(ICON_IN_OUT_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTransmitionTextureForState(CollidableComponent component) {
|
||||
return null;
|
||||
@@ -217,9 +223,14 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
doExtract();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtractingFromDir(ForgeDirection dir) {
|
||||
return getConnectionMode(dir).acceptsInput();
|
||||
}
|
||||
|
||||
private void doExtract() {
|
||||
BlockCoord loc = getLocation();
|
||||
if(!hasConnectionMode(ConnectionMode.INPUT)) {
|
||||
if(!hasConnectionMode(ConnectionMode.INPUT) && !hasConnectionMode(ConnectionMode.IN_OUT)) {
|
||||
return;
|
||||
}
|
||||
if(network == null) {
|
||||
|
||||
@@ -25,10 +25,6 @@ public class EnderLiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick,
|
||||
float worldLight) {
|
||||
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight);
|
||||
|
||||
if(!conduit.hasConnectionMode(ConnectionMode.INPUT) && !conduit.hasConnectionMode(ConnectionMode.OUTPUT)) {
|
||||
return;
|
||||
}
|
||||
EnderLiquidConduit pc = (EnderLiquidConduit) conduit;
|
||||
for (ForgeDirection dir : conduit.getExternalConnections()) {
|
||||
IIcon tex = null;
|
||||
@@ -36,6 +32,8 @@ public class EnderLiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
tex = pc.getTextureForInputMode();
|
||||
} else if(conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
|
||||
tex = pc.getTextureForOutputMode();
|
||||
} else if(conduit.getConnectionMode(dir) == ConnectionMode.IN_OUT) {
|
||||
tex = pc.getTextureForInOutMode();
|
||||
}
|
||||
if(tex != null) {
|
||||
Offset offset = te.getOffset(ILiquidConduit.class, dir);
|
||||
|
||||
Reference in new issue
Block a user