gas conduits completely hidden if disabled.

This commit is contained in:
CrazyPants committed 2014-08-29 18:02:27 +08:00
1 parent 496ce2ed8d
commit edecfa3ba8
8 files changed
+64 -17

No files matched your search

@@ -3,6 +3,7 @@ package crazypants.enderio.conduit;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.gas.GasUtil;
public enum ConduitDisplayMode {
ALL,
@@ -17,7 +18,11 @@ public enum ConduitDisplayMode {
if(index >= values().length) {
index = 0;
}
return values()[index];
ConduitDisplayMode res = values()[index];
if(res == GAS && !GasUtil.isGasConduitEnabled()) {
return next(res);
}
return res;
}
public static ConduitDisplayMode previous(ConduitDisplayMode mode) {
@@ -25,7 +30,11 @@ public enum ConduitDisplayMode {
if(index < 0) {
index = values().length - 1;
}
return values()[index];
ConduitDisplayMode res = values()[index];
if(res == GAS && !GasUtil.isGasConduitEnabled()) {
return previous(res);
}
return res;
}
public static ConduitDisplayMode getDisplayMode(ItemStack equipped) {
@@ -1,5 +1,7 @@
package crazypants.enderio.conduit.gas;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
import net.minecraft.tileentity.TileEntity;
@@ -7,9 +9,28 @@ import net.minecraft.world.IBlockAccess;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.IPipeTile.PipeType;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.config.Config;
import crazypants.util.BlockCoord;
public class GasUtil {
public final class GasUtil {
private static boolean useCheckPerformed = false;
private static boolean isGasConduitEnabled = false;
public static boolean isGasConduitEnabled() {
if(!useCheckPerformed) {
String configOption = Config.isGasConduitEnabled;
if(configOption.equalsIgnoreCase("auto")) {
isGasConduitEnabled = Loader.isModLoaded("Mekanism");
} else if(configOption.equalsIgnoreCase("true")) {
isGasConduitEnabled = true;
} else {
isGasConduitEnabled = false;
}
useCheckPerformed = true;
}
return isGasConduitEnabled;
}
public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc) {
IGasHandler con = getGasHandler(world, bc);
@@ -47,4 +68,7 @@ public class GasUtil {
return false;
}
private GasUtil() {
}
}
@@ -29,6 +29,9 @@ public class ItemGasConduit extends AbstractItemConduit implements IAdvancedTool
protected ItemGasConduit() {
super(ModObject.itemGasConduit);
if(!GasUtil.isGasConduitEnabled()) {
setCreativeTab(null);
}
}
@Override
@@ -252,6 +252,8 @@ public final class Config {
public static boolean allowTileEntitiesAsPaintSource = true;
public static String isGasConduitEnabled = "auto";
public static void load(FMLPreInitializationEvent event) {
FMLCommonHandler.instance().bus().register(new Config());
@@ -672,6 +674,9 @@ public final class Config {
"The reach of attacks to each side of Joe.").getDouble(killerJoeAttackWidth);
killerJoeAttackLength = config.get(sectionKiller.name, "killerJoeAttackLength", killerJoeAttackLength,
"The reach of attacks in front of Joe.").getDouble(killerJoeAttackLength);
isGasConduitEnabled = config.getString(sectionItems.name, "isGasConduitEnabled", isGasConduitEnabled,
"Can be set to 'auto', 'true' or 'false'. When set to auto the gas conduit will only be enabled when Mekanism is installed.");
}
private Config() {
@@ -2,6 +2,8 @@ package crazypants.enderio.gui;
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.render.RenderUtil;
public final class IconEIO {
@@ -20,14 +22,14 @@ 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, 96, 64);
public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(96, 148, 96, 64);
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_POWER = new IconEIO(16, 148, 32, 32);
public static final IconEIO WRENCH_OVERLAY_POWER_OFF = new IconEIO(16 + 96, 148, 32, 32);
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);
public static final IconEIO WRENCH_OVERLAY_REDSTONE = new IconEIO(48, 148, 32, 32);
public static final IconEIO WRENCH_OVERLAY_REDSTONE_OFF = new IconEIO(48 + 96, 148, 32, 32);
public static final IconEIO WRENCH_OVERLAY_REDSTONE = new IconEIO(32, 148, 32, 32);
public static final IconEIO WRENCH_OVERLAY_REDSTONE_OFF = new IconEIO(32 + 96, 148, 32, 32);
public static final IconEIO WRENCH_OVERLAY_FLUID = new IconEIO(0, 180, 32, 32);
public static final IconEIO WRENCH_OVERLAY_FLUID_OFF = new IconEIO(96, 180, 32, 32);
@@ -35,8 +37,8 @@ public final class IconEIO {
public static final IconEIO WRENCH_OVERLAY_ITEM = new IconEIO(32, 180, 32, 32);
public static final IconEIO WRENCH_OVERLAY_ITEM_OFF = new IconEIO(32 + 96, 180, 32, 32);
public static final IconEIO WRENCH_OVERLAY_GAS = new IconEIO(64, 180, 32, 32);
public static final IconEIO WRENCH_OVERLAY_GAS_OFF = new IconEIO(64 + 96, 180, 32, 32);
public static final IconEIO WRENCH_OVERLAY_GAS = new IconEIO(64, 164, 32, 32);
public static final IconEIO WRENCH_OVERLAY_GAS_OFF = new IconEIO(64 + 96, 164, 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);
@@ -11,6 +11,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.gui.IconEIO;
public class YetaWrenchOverlayRenderer {
@@ -44,27 +45,28 @@ public class YetaWrenchOverlayRenderer {
double offsetX = 16;
double offsetY = res.getScaledHeight() - 16;
int width = GasUtil.isGasConduitEnabled() ? 48 : 32;
if(mode == ConduitDisplayMode.ALL) {
GL11.glColor4f(1, 1, 1, 0.75f);
IconEIO.WRENCH_OVERLAY_ALL_ON.renderIcon(offsetX, offsetY - 32, 48, 32, 0, true);
IconEIO.WRENCH_OVERLAY_ALL_ON.renderIcon(offsetX, offsetY - 32, width, 32, 0, true);
return;
}
float c = 0.6f;
GL11.glColor4f(c, c, c, 0.33f);
IconEIO.WRENCH_OVERLAY_ALL_OFF.renderIcon(offsetX, offsetY - 32, 48, 32, 0, true);
IconEIO.WRENCH_OVERLAY_ALL_OFF.renderIcon(offsetX, offsetY - 32, width, 32, 0, true);
GL11.glColor4f(1, 1, 1, 0.75f);
if(mode == ConduitDisplayMode.POWER) {
IconEIO.WRENCH_OVERLAY_POWER.renderIcon(offsetX + 8, offsetY - 32, 16, 16, 0, true);
IconEIO.WRENCH_OVERLAY_POWER.renderIcon(offsetX, offsetY - 32, 16, 16, 0, true);
} else if(mode == ConduitDisplayMode.REDSTONE) {
IconEIO.WRENCH_OVERLAY_REDSTONE.renderIcon(offsetX + 24, offsetY - 32, 16, 16, 0, true);
IconEIO.WRENCH_OVERLAY_REDSTONE.renderIcon(offsetX + 16, offsetY - 32, 16, 16, 0, true);
} else if(mode == ConduitDisplayMode.FLUID) {
IconEIO.WRENCH_OVERLAY_FLUID.renderIcon(offsetX, offsetY - 16, 16, 16, 0, true);
} else if(mode == ConduitDisplayMode.ITEM) {
IconEIO.WRENCH_OVERLAY_ITEM.renderIcon(offsetX + 16, offsetY - 16, 16, 16, 0, true);
} else if(mode == ConduitDisplayMode.GAS) {
IconEIO.WRENCH_OVERLAY_GAS.renderIcon(offsetX + 32, offsetY - 16, 16, 16, 0, true);
IconEIO.WRENCH_OVERLAY_GAS.renderIcon(offsetX + 32, offsetY - 24, 16, 16, 0, true);
}
}
@@ -5,6 +5,7 @@ import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import cpw.mods.fml.common.Loader;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.gas.GasUtil;
import crazypants.enderio.config.Config;
public class NEIEnderIOConfig implements IConfigureNEI {
@@ -32,6 +33,7 @@ public class NEIEnderIOConfig implements IConfigureNEI {
API.hideItem(new ItemStack(EnderIO.blockPaintedSlab));
API.hideItem(new ItemStack(EnderIO.blockPaintedStair));
API.hideItem(new ItemStack(EnderIO.blockPaintedWall));
API.hideItem(new ItemStack(EnderIO.blockConduitBundle));
if(!Config.photovoltaicCellEnabled) {
API.hideItem(new ItemStack(EnderIO.blockSolarPanel));
@@ -43,7 +45,7 @@ public class NEIEnderIOConfig implements IConfigureNEI {
API.hideItem(new ItemStack(EnderIO.blockReinforcedObsidian));
}
if(!Loader.isModLoaded("Mekanism")) {
if(!GasUtil.isGasConduitEnabled()) {
API.hideItem(new ItemStack(EnderIO.itemGasConduit));
}
}