More connections fixing and work on yeta wrench overlay

This commit is contained in:
tterrag1098 committed 2014-11-02 15:08:39 -05:00
1 parent 9bc4e21c2f
commit 8e933c1db3
7 files changed
+61 -8

No files matched your search

@@ -855,10 +855,10 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
} else {
IMEConduit cond = getConduit(IMEConduit.class);
if (cond != null) {
if (cond.getConnectionMode(dir) != ConnectionMode.IN_OUT) {
return null;
} else {
if (cond.getConnectionMode(dir.getOpposite()) == ConnectionMode.IN_OUT) {
return (IGridNode) node;
} else {
return null;
}
}
}
@@ -148,12 +148,19 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
return mode;
}
@Override
public ConnectionMode getConnectionMode(ForgeDirection dir) {
ConnectionMode mode = conectionModes.get(dir);
return mode == null ? validConnections.contains(dir) ? ConnectionMode.IN_OUT : ConnectionMode.DISABLED : mode;
}
@Override
@Method(modid = "appliedenergistics2")
protected void connectionsChanged() {
super.connectionsChanged();
onNodeChanged();
}
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
super.onBlockActivated(player, res, all);
@@ -181,6 +188,28 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
}
return false;
}
@Method(modid = "appliedenergistics2")
public void onNodeChanged() {
boolean foundConnection = false;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getBundle().getBlockCoord().getLocation(dir).getTileEntity(getBundle().getWorld());
if (te != null && te instanceof IGridHost) {
IGridNode node = ((IGridHost)te).getGridNode(ForgeDirection.UNKNOWN);
foundConnection |= validConnections.contains(dir);
if (node == null) {
node = ((IGridHost)te).getGridNode(dir.getOpposite());
}
if (node != null) {
node.updateState();
}
}
}
if (!foundConnection && hasNode()) {
getNode().destroy();
}
}
@Override
@Method(modid = "appliedenergistics2")
@@ -200,6 +229,10 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
return getBundle().getGridNode(null);
}
private boolean hasNode() {
return getNode() != null;
}
@Override
public EnumSet<ForgeDirection> getConnections() {
return validConnections;
@@ -0,0 +1,11 @@
package crazypants.enderio.conduit.me;
import cpw.mods.fml.common.Loader;
public class MEUtil {
public static boolean isMEEnabled() {
return Loader.isModLoaded("appliedenergistics2");
}
}
@@ -4,6 +4,7 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import crazypants.enderio.conduit.gas.GasConduit;
import crazypants.enderio.conduit.gas.GasUtil;
import crazypants.enderio.conduit.me.MEUtil;
import crazypants.render.RenderUtil;
public final class IconEIO {
@@ -23,8 +24,8 @@ public final class IconEIO {
public static final IconEIO BUTTON_DOWN = new IconEIO(48, 116);
public static final IconEIO BUTTON_DOWN_HIGHLIGHT = new IconEIO(64, 116);
public static final IconEIO WRENCH_OVERLAY_ALL_ON = new IconEIO(0, 148, GasUtil.isGasConduitEnabled() ? 96 : 64, 64);
public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(96, 148, GasUtil.isGasConduitEnabled() ? 96 : 64, 64);
public static final IconEIO WRENCH_OVERLAY_ALL_ON = new IconEIO(0, 148, MEUtil.isMEEnabled() || GasUtil.isGasConduitEnabled() ? 96 : 64, 64);
public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(96, 148, MEUtil.isMEEnabled() || GasUtil.isGasConduitEnabled() ? 96 : 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(0 + 96, 148, 32, 32);
@@ -12,6 +12,7 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.conduit.ConduitDisplayMode;
import crazypants.enderio.conduit.gas.GasUtil;
import crazypants.enderio.conduit.me.MEUtil;
import crazypants.enderio.gui.IconEIO;
public class YetaWrenchOverlayRenderer {
@@ -45,7 +46,7 @@ public class YetaWrenchOverlayRenderer {
double offsetX = 16;
double offsetY = res.getScaledHeight() - 16;
int width = GasUtil.isGasConduitEnabled() ? 48 : 32;
int width = MEUtil.isMEEnabled() || GasUtil.isGasConduitEnabled() ? 48 : 32;
if(mode == ConduitDisplayMode.ALL) {
GL11.glColor4f(1, 1, 1, 0.75f);