diff --git a/common/crazypants/enderio/ClientProxy.java b/common/crazypants/enderio/ClientProxy.java index 3d303a23..261a5275 100644 --- a/common/crazypants/enderio/ClientProxy.java +++ b/common/crazypants/enderio/ClientProxy.java @@ -15,13 +15,14 @@ import crazypants.enderio.conduit.BlockConduitBundle; import crazypants.enderio.conduit.IConduit; import crazypants.enderio.conduit.TileConduitBundle; import crazypants.enderio.conduit.facade.FacadeRenderer; +import crazypants.enderio.conduit.item.ItemConduit; import crazypants.enderio.conduit.liquid.LiquidConduit; import crazypants.enderio.conduit.liquid.LiquidConduitRenderer; import crazypants.enderio.conduit.power.PowerConduit; import crazypants.enderio.conduit.power.PowerConduitRenderer; import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit; -import crazypants.enderio.conduit.redstone.RedstoneConduit; import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduitRenderer; +import crazypants.enderio.conduit.redstone.RedstoneConduit; import crazypants.enderio.conduit.redstone.RedstoneSwitch; import crazypants.enderio.conduit.redstone.RedstoneSwitchRenderer; import crazypants.enderio.conduit.render.ConduitBundleRenderer; @@ -67,12 +68,15 @@ public class ClientProxy extends CommonProxy { RedstoneSwitch.initIcons(); PowerConduit.initIcons(); LiquidConduit.initIcons(); + ItemConduit.initIcons(); } private List conduitRenderers = new ArrayList(); private DefaultConduitRenderer dcr = new DefaultConduitRenderer(); + private ConduitBundleRenderer cbr; + @Override public World getClientWorld() { return FMLClientHandler.instance().getClient().theWorld; @@ -83,13 +87,21 @@ public class ClientProxy extends CommonProxy { return Minecraft.getMinecraft().thePlayer; } + public ConduitBundleRenderer getConduitBundleRenderer() { + return cbr; + } + + public void setCbr(ConduitBundleRenderer cbr) { + this.cbr = cbr; + } + @Override public void load() { super.load(); // Renderers - ConduitBundleRenderer cbr = new ConduitBundleRenderer((float) Config.conduitScale); + cbr = new ConduitBundleRenderer((float) Config.conduitScale); BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(cbr); @@ -114,6 +126,7 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit.itemID, itemConRenderer); MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit.itemID, itemConRenderer); MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit.itemID, itemConRenderer); + MinecraftForgeClient.registerItemRenderer(EnderIO.itemItemConduit.itemID, itemConRenderer); PaintedItemRenderer pir = new PaintedItemRenderer(); MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomFence.blockID, pir); @@ -131,6 +144,7 @@ public class ClientProxy extends CommonProxy { conduitRenderers.add(new LiquidConduitRenderer()); conduitRenderers.add(new PowerConduitRenderer()); conduitRenderers.add(new InsulatedRedstoneConduitRenderer()); + conduitRenderers.add(new crazypants.enderio.conduit.item.ItemConduitRenderer()); EnderIoRenderer eior = new EnderIoRenderer(); ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior); diff --git a/common/crazypants/enderio/Config.java b/common/crazypants/enderio/Config.java index c3c22edd..b2f9eaf0 100644 --- a/common/crazypants/enderio/Config.java +++ b/common/crazypants/enderio/Config.java @@ -40,9 +40,13 @@ public final class Config { public static boolean useHardRecipes = false; public static boolean detailedPowerTrackingEnabled = true; - + public static double maxPhotovoltaicOutput = 1.0; + public static boolean useSneakMouseWheelYetaWrench = true; + + public static boolean useSneakRightClickYetaWrench = false; + public static void load(FMLPreInitializationEvent event) { configDirectory = new File(event.getModConfigurationDirectory(), "enderio"); if(!configDirectory.exists()) { @@ -91,7 +95,7 @@ public final class Config { maxPhotovoltaicOutput = config.get("Settings", "maxPhotovoltaicOutput", maxPhotovoltaicOutput, "Maximum output in MJ/t of the Photovoltaic Panels.").getDouble(maxPhotovoltaicOutput); - + useAlternateBinderRecipe = config.get("Settings", "useAlternateBinderRecipe", false, "Create conduit binder in crafting table instead of furnace") .getBoolean(useAlternateBinderRecipe); @@ -115,8 +119,19 @@ public final class Config { detailedPowerTrackingEnabled = config.get("Settings", "detailedPowerTrackingEnabled", detailedPowerTrackingEnabled, "Enable per tick sampling on individual power inputs and outputs") .getBoolean(detailedPowerTrackingEnabled); - - + + useSneakMouseWheelYetaWrench = config.get("Settings", "useSneakMouseWheelYetaWrench", useSneakMouseWheelYetaWrench, + "If true, shift-mouse wheel will change the conduit display mode when the YetaWrench is eqipped.") + .getBoolean(useSneakMouseWheelYetaWrench); + + useSneakRightClickYetaWrench = config.get("Settings", "useSneakRightClickYetaWrench", useSneakRightClickYetaWrench, + "If true, shift-clicking the YetaWrench on a null or non wrenchable object will change the conduit display mode.") + .getBoolean(useSneakRightClickYetaWrench); + + if(!useSneakMouseWheelYetaWrench && !useSneakRightClickYetaWrench) { + Log.warn("Both useSneakMouseWheelYetaWrench and useSneakRightClickYetaWrench are set to false. Enabling mouse wheel."); + useSneakMouseWheelYetaWrench = true; + } } diff --git a/common/crazypants/enderio/EnderIO.java b/common/crazypants/enderio/EnderIO.java index 344442e4..d28ba550 100644 --- a/common/crazypants/enderio/EnderIO.java +++ b/common/crazypants/enderio/EnderIO.java @@ -19,12 +19,15 @@ import crazypants.enderio.conduit.ConduitRecipes; import crazypants.enderio.conduit.facade.BlockConduitFacade; import crazypants.enderio.conduit.facade.ItemConduitFacade; import crazypants.enderio.conduit.geom.ConduitGeometryUtil; +import crazypants.enderio.conduit.item.ItemItemConduit; import crazypants.enderio.conduit.liquid.ItemLiquidConduit; import crazypants.enderio.conduit.power.ItemPowerConduit; import crazypants.enderio.conduit.redstone.ItemRedstoneConduit; import crazypants.enderio.enderface.BlockEnderIO; import crazypants.enderio.enderface.EnderfaceRecipes; import crazypants.enderio.enderface.ItemEnderface; +import crazypants.enderio.item.ItemRecipes; +import crazypants.enderio.item.ItemYetaWrench; import crazypants.enderio.machine.MachineRecipeRegistry; import crazypants.enderio.machine.MachineRecipes; import crazypants.enderio.machine.RedstoneModePacketProcessor; @@ -55,7 +58,6 @@ import crazypants.enderio.material.ItemFusedQuartzFrame; import crazypants.enderio.material.ItemMachinePart; import crazypants.enderio.material.ItemMaterial; import crazypants.enderio.material.ItemPowderIngot; -import crazypants.enderio.material.ItemYetaWrench; import crazypants.enderio.material.MaterialRecipes; import crazypants.enderio.trigger.TriggerEnderIO; import crazypants.enderio.trigger.TriggerProviderEIO; @@ -101,6 +103,7 @@ public class EnderIO { public static ItemRedstoneConduit itemRedstoneConduit; public static ItemPowerConduit itemPowerConduit; public static ItemLiquidConduit itemLiquidConduit; + public static ItemItemConduit itemItemConduit; // Machines public static BlockStirlingGenerator blockStirlingGenerator; @@ -169,6 +172,7 @@ public class EnderIO { itemRedstoneConduit = ItemRedstoneConduit.create(); itemPowerConduit = ItemPowerConduit.create(); itemLiquidConduit = ItemLiquidConduit.create(); + itemItemConduit = ItemItemConduit.create(); blockElectricLight = BlockElectricLight.create(); blockLightNode = BlockLightNode.create(); @@ -193,6 +197,7 @@ public class EnderIO { MaterialRecipes.addRecipes(); ConduitRecipes.addRecipes(); MachineRecipes.addRecipes(); + ItemRecipes.addRecipes(); triggerNoEnergy = new TriggerEnderIO("enderIO.trigger.noEnergy", 0); triggerHasEnergy = new TriggerEnderIO("enderIO.trigger.hasEnergy", 1); diff --git a/common/crazypants/enderio/ModObject.java b/common/crazypants/enderio/ModObject.java index 82472482..e38e9360 100644 --- a/common/crazypants/enderio/ModObject.java +++ b/common/crazypants/enderio/ModObject.java @@ -62,7 +62,9 @@ public enum ModObject { itemMJReader(++Config.IID, CATEGORY_ITEM, "MJ Reader"), itemMaterial(++Config.IID, CATEGORY_ITEM, "Materials"), - blockPowerMonitor(++Config.BID, CATEGORY_BLOCK, "Power Monitor"); + blockPowerMonitor(++Config.BID, CATEGORY_BLOCK, "Power Monitor"), + + itemItemConduit(++Config.IID, CATEGORY_ITEM, "Item Conduit"); public final String unlocalisedName; public final String name; diff --git a/common/crazypants/enderio/PacketHandler.java b/common/crazypants/enderio/PacketHandler.java index 27f6a53a..51a29e9c 100644 --- a/common/crazypants/enderio/PacketHandler.java +++ b/common/crazypants/enderio/PacketHandler.java @@ -55,6 +55,8 @@ public class PacketHandler implements IPacketHandler { public static final int ID_MJ_READER_INFO_REQUEST = 12; public static final int ID_POWER_MONITOR_PACKET = 13; + public static final int ID_YETA_WRENCH_MODE_PACKET = 14; + public static final String CHANNEL = "EnderIO"; public static PacketHandler instance; diff --git a/common/crazypants/enderio/conduit/AbstractConduit.java b/common/crazypants/enderio/conduit/AbstractConduit.java index d5343bf8..30d659ca 100644 --- a/common/crazypants/enderio/conduit/AbstractConduit.java +++ b/common/crazypants/enderio/conduit/AbstractConduit.java @@ -58,11 +58,15 @@ public abstract class AbstractConduit implements IConduit { public ConnectionMode getConectionMode(ForgeDirection dir) { ConnectionMode res = conectionModes.get(dir); if(res == null) { - return ConnectionMode.IN_OUT; + return getDefaultConnectionMode(); } return res; } + protected ConnectionMode getDefaultConnectionMode() { + return ConnectionMode.IN_OUT; + } + @Override public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) { ConnectionMode oldVal = conectionModes.get(dir); @@ -171,6 +175,16 @@ public abstract class AbstractConduit implements IConduit { return !externalConnections.isEmpty(); } + @Override + public boolean hasConnections() { + return hasConduitConnections() || hasExternalConnections(); + } + + @Override + public boolean hasConduitConnections() { + return !conduitConnections.isEmpty(); + } + @Override public boolean containsExternalConnection(ForgeDirection dir) { return externalConnections.contains(dir); diff --git a/common/crazypants/enderio/conduit/BlockConduitBundle.java b/common/crazypants/enderio/conduit/BlockConduitBundle.java index 49a95929..76526d26 100644 --- a/common/crazypants/enderio/conduit/BlockConduitBundle.java +++ b/common/crazypants/enderio/conduit/BlockConduitBundle.java @@ -534,31 +534,59 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC boolean result = false; // if its a connector pass the event on to all conduits for (IConduit con : bundle.getConduits()) { - if(con.onBlockActivated(player, closest, all)) { + if(ConduitUtil.renderConduit(player, con.getCollidableType()) && con.onBlockActivated(player, getHitForConduitType(all, con.getCollidableType()), all)) { bundle.getEntity().onInventoryChanged(); result = true; } } - return result; + if(result) { + return true; + } } if(closest == null || closest.component == null || closest.component.conduitType == - null) { + null && all == null) { // Nothing of interest hit return false; } // Conduit specific actions - if(bundle.getConduit(closest.component.conduitType) != null && bundle.getConduit(closest.component.conduitType).onBlockActivated(player, - closest, all)) { - bundle.getEntity().onInventoryChanged(); - return true; + if(all != null) { + RaytraceResult.sort(getEyePosition(world, player), all); + for (RaytraceResult rr : all) { + if(ConduitUtil.renderConduit(player, rr.component.conduitType) && !(rr.component.data instanceof + ConduitConnectorType)) { + + IConduit con = bundle.getConduit(rr.component.conduitType); + if(con != null && con.onBlockActivated(player, + rr, all)) { + bundle.getEntity().onInventoryChanged(); + return true; + } + } + } + } else { + IConduit closestConduit = bundle.getConduit(closest.component.conduitType); + if(closestConduit != null && ConduitUtil.renderConduit(player, closestConduit) && closestConduit.onBlockActivated(player, + closest, all)) { + bundle.getEntity().onInventoryChanged(); + return true; + } } return false; } + private RaytraceResult getHitForConduitType(List all, Class collidableType) { + for (RaytraceResult rr : all) { + if(rr.component != null && rr.component.conduitType == collidableType) { + return rr; + } + } + return null; + } + @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { @@ -656,13 +684,18 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC if(allHits == null) { return null; } + Vec3 origin = getEyePosition(world, entityPlayer); + return RaytraceResult.getClosestHit(origin, allHits); + } + + private Vec3 getEyePosition(World world, EntityPlayer entityPlayer) { double posY = entityPlayer.posY + 1.62 - entityPlayer.yOffset; if(!world.isRemote && entityPlayer.isSneaking()) { posY -= 0.08; } Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, posY, entityPlayer.posZ); - return RaytraceResult.getClosestHit(origin, allHits); + return origin; } public List doRayTraceAll(World world, int x, int y, int z, @@ -676,12 +709,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC double reachDistance = EnderIO.proxy.getReachDistanceForPlayer(entityPlayer); - double posY = entityPlayer.posY + 1.62 - entityPlayer.yOffset; - if(!world.isRemote && entityPlayer.isSneaking()) { - posY -= 0.08; - } - Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, posY, - entityPlayer.posZ); + Vec3 origin = getEyePosition(world, entityPlayer); Vec3 direction = origin.addVector(dirX * reachDistance, dirY * reachDistance, dirZ * reachDistance); return doRayTraceAll(world, x, y, z, origin, direction, diff --git a/common/crazypants/enderio/conduit/ConduitDisplayMode.java b/common/crazypants/enderio/conduit/ConduitDisplayMode.java new file mode 100644 index 00000000..26f731a4 --- /dev/null +++ b/common/crazypants/enderio/conduit/ConduitDisplayMode.java @@ -0,0 +1,52 @@ +package crazypants.enderio.conduit; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public enum ConduitDisplayMode { + ALL, + POWER, + REDSTONE, + ITEM, + FLUID; + + public static ConduitDisplayMode next(ConduitDisplayMode mode) { + int index = mode.ordinal() + 1; + if(index >= values().length) { + index = 0; + } + return values()[index]; + } + + public static ConduitDisplayMode previous(ConduitDisplayMode mode) { + int index = mode.ordinal() - 1; + if(index < 0) { + index = values().length - 1; + } + return values()[index]; + } + + public static ConduitDisplayMode getDisplayMode(ItemStack equipped) { + int index = equipped.getItemDamage(); + index = MathHelper.clamp_int(index, 0, ConduitDisplayMode.values().length); + return ConduitDisplayMode.values()[index]; + } + + public static void setDisplayMode(ItemStack equipped, ConduitDisplayMode mode) { + if(mode == null || equipped == null) { + return; + } + int index = mode.ordinal(); + index = MathHelper.clamp_int(index, 0, ConduitDisplayMode.values().length); + equipped.setItemDamage(index); + } + + public ConduitDisplayMode next() { + return next(this); + } + + public ConduitDisplayMode previous() { + return previous(this); + } + +} \ No newline at end of file diff --git a/common/crazypants/enderio/conduit/ConduitRecipes.java b/common/crazypants/enderio/conduit/ConduitRecipes.java index 8f3c7606..68b3050e 100644 --- a/common/crazypants/enderio/conduit/ConduitRecipes.java +++ b/common/crazypants/enderio/conduit/ConduitRecipes.java @@ -2,10 +2,12 @@ package crazypants.enderio.conduit; import static crazypants.enderio.ModObject.blockPainter; import static crazypants.enderio.ModObject.itemConduitFacade; +import static crazypants.enderio.ModObject.itemItemConduit; import static crazypants.enderio.ModObject.itemLiquidConduit; import static crazypants.enderio.ModObject.itemPowerConduit; import static crazypants.enderio.ModObject.itemRedstoneConduit; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; import crazypants.enderio.Config; @@ -25,8 +27,10 @@ public class ConduitRecipes { ItemStack fusedQuartz = new ItemStack(ModObject.blockFusedQuartz.actualId, 1, 0); ItemStack conductiveIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.CONDUCTIVE_IRON.ordinal()); ItemStack energeticGold = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ENERGETIC_ALLOY.ordinal()); - ItemStack phasedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_GOLD.ordinal()); + ItemStack phasedGold = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_GOLD.ordinal()); + ItemStack phasedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_IRON.ordinal()); ItemStack redstoneAlloy = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.REDSTONE_ALLOY.ordinal()); + ItemStack electricalSteel = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal()); //Recipes GameRegistry.addShapedRecipe(new ItemStack(itemConduitFacade.actualId, 1, 0), "bbb", "b b", "bbb", 'b', conduitBinder); @@ -34,15 +38,19 @@ public class ConduitRecipes { int numConduits = Config.numConduitsPerRecipe; GameRegistry.addShapedRecipe(new ItemStack(itemLiquidConduit.actualId, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', fusedQuartz); GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', conductiveIron); - GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, 'f', fusedQuartz, '#', - energeticGold); - GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron); - GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 0), " ", "###", " ", 'b', conduitBinder, 'f', fusedQuartz, '#', - redstoneAlloy); + GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, '#', energeticGold); + GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedGold); + GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 0), " ", "###", " ", 'b', conduitBinder, '#', redstoneAlloy); GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, 1, 1), "lbl", "bcb", "lbl", 'b', conduitBinder, 'c', redstoneConduit, 'l', Block.lever); - GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, 'f', fusedQuartz, '#', - redstoneAlloy); + GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', redstoneAlloy); + + ItemStack itemConduit = new ItemStack(itemItemConduit.actualId, numConduits, 0); + GameRegistry.addShapedRecipe(itemConduit, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron); + + GameRegistry.addShapedRecipe(new ItemStack(itemItemConduit.actualId, 2, 1), "sis", "ehe", "sis", 's', electricalSteel, 'i', itemConduit, 'e', + new ItemStack(Item.emerald), 'h', new ItemStack(Block.hopperBlock)); + MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, new FacadePainterRecipe()); } diff --git a/common/crazypants/enderio/conduit/ConduitUtil.java b/common/crazypants/enderio/conduit/ConduitUtil.java index 52d1e2e4..97b374e4 100644 --- a/common/crazypants/enderio/conduit/ConduitUtil.java +++ b/common/crazypants/enderio/conduit/ConduitUtil.java @@ -18,11 +18,15 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import crazypants.enderio.EnderIO; +import crazypants.enderio.ModObject; import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState; +import crazypants.enderio.conduit.item.IItemConduit; +import crazypants.enderio.conduit.item.ItemConduitNetwork; import crazypants.enderio.conduit.liquid.ILiquidConduit; import crazypants.enderio.conduit.liquid.LiquidConduitNetwork; import crazypants.enderio.conduit.power.IPowerConduit; import crazypants.enderio.conduit.power.PowerConduitNetwork; +import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit; import crazypants.enderio.conduit.redstone.IRedstoneConduit; import crazypants.enderio.conduit.redstone.RedstoneConduitNetwork; @@ -37,6 +41,8 @@ public class ConduitUtil { return new PowerConduitNetwork(); } else if(ILiquidConduit.class.isAssignableFrom(type)) { return new LiquidConduitNetwork(); + } else if(IItemConduit.class.isAssignableFrom(type)) { + return new ItemConduitNetwork(); } FMLCommonHandler.instance().raiseException(new Exception("Could not determine network type for class " + type), "ConduitUtil.createNetworkForType", false); return null; @@ -96,6 +102,54 @@ public class ConduitUtil { return bundle.getFacadeId() > 0 && (isToolEquipped(player) || isConduitEquipped(player)); } + public static ConduitDisplayMode getDisplayMode(EntityPlayer player) { + player = player == null ? EnderIO.proxy.getClientPlayer() : player; + if(player == null) { + return ConduitDisplayMode.ALL; + } + ItemStack equipped = player.getCurrentEquippedItem(); + if(equipped == null) { + return ConduitDisplayMode.ALL; + } + if(equipped.itemID != ModObject.itemYetaWrench.actualId) { + return ConduitDisplayMode.ALL; + } + ConduitDisplayMode result = ConduitDisplayMode.getDisplayMode(equipped); + if(result == null) { + return ConduitDisplayMode.ALL; + } + return result; + } + + public static boolean renderConduit(EntityPlayer player, IConduit con) { + if(player == null || con == null) { + return true; + } + return renderConduit(player, con.getBaseConduitType()); + } + + public static boolean renderConduit(EntityPlayer player, Class conduitType) { + if(player == null || conduitType == null) { + return true; + } + ConduitDisplayMode mode = getDisplayMode(player); + switch (mode) { + case ALL: + return true; + case FLUID: + return conduitType == ILiquidConduit.class; + case ITEM: + return conduitType == IItemConduit.class; + case POWER: + return conduitType == IPowerConduit.class; + case REDSTONE: + return conduitType == IRedstoneConduit.class || conduitType == IInsulatedRedstoneConduit.class; + default: + break; + } + return true; + } + public static boolean isConduitEquipped(EntityPlayer player) { player = player == null ? EnderIO.proxy.getClientPlayer() : player; if(player == null) { diff --git a/common/crazypants/enderio/conduit/IConduit.java b/common/crazypants/enderio/conduit/IConduit.java index c15f58af..8c4d57fc 100644 --- a/common/crazypants/enderio/conduit/IConduit.java +++ b/common/crazypants/enderio/conduit/IConduit.java @@ -43,6 +43,13 @@ public interface IConduit { BlockCoord getLocation(); + // Conections + boolean hasConnections(); + + boolean hasExternalConnections(); + + boolean hasConduitConnections(); + // Conduit Connections boolean canConnectToConduit(ForgeDirection direction, IConduit conduit); @@ -67,8 +74,6 @@ public interface IConduit { boolean containsExternalConnection(ForgeDirection dir); - boolean hasExternalConnections(); - void externalConnectionAdded(ForgeDirection fromDirection); void externalConnectionRemoved(ForgeDirection fromDirection); diff --git a/common/crazypants/enderio/conduit/RaytraceResult.java b/common/crazypants/enderio/conduit/RaytraceResult.java index 2a794b91..1f0a2758 100644 --- a/common/crazypants/enderio/conduit/RaytraceResult.java +++ b/common/crazypants/enderio/conduit/RaytraceResult.java @@ -1,6 +1,9 @@ package crazypants.enderio.conduit; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; @@ -25,6 +28,18 @@ public class RaytraceResult { return closest; } + public static void sort(final Vec3 origin, List toSort) { + if(origin == null || toSort == null) { + Collections.sort(toSort, new Comparator() { + + @Override + public int compare(RaytraceResult o1, RaytraceResult o2) { + return Double.compare(o1.getDistanceTo(origin), o1.getDistanceTo(origin)); + } + }); + } + } + public final CollidableComponent component; public final MovingObjectPosition movingObjectPosition; @@ -33,4 +48,11 @@ public class RaytraceResult { this.movingObjectPosition = movingObjectPosition; } + public double getDistanceTo(Vec3 origin) { + if(movingObjectPosition == null || origin == null) { + return Double.MAX_VALUE; + } + return movingObjectPosition.hitVec.squareDistanceTo(origin); + } + } diff --git a/common/crazypants/enderio/conduit/TileConduitBundle.java b/common/crazypants/enderio/conduit/TileConduitBundle.java index cfce9fff..94578fde 100644 --- a/common/crazypants/enderio/conduit/TileConduitBundle.java +++ b/common/crazypants/enderio/conduit/TileConduitBundle.java @@ -24,11 +24,13 @@ import crazypants.enderio.PacketHandler; import crazypants.enderio.conduit.geom.CollidableCache; import crazypants.enderio.conduit.geom.CollidableComponent; import crazypants.enderio.conduit.geom.ConduitConnectorType; -import crazypants.enderio.conduit.geom.ConduitGeometryUtil; import crazypants.enderio.conduit.geom.Offset; import crazypants.enderio.conduit.geom.Offsets; +import crazypants.enderio.conduit.geom.Offsets.Axis; import crazypants.enderio.conduit.liquid.ILiquidConduit; import crazypants.enderio.conduit.power.IPowerConduit; +import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit; +import crazypants.render.BoundingBox; import crazypants.util.BlockCoord; public class TileConduitBundle extends TileEntity implements IConduitBundle { @@ -42,8 +44,11 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle { private final List cachedCollidables = new ArrayList(); + private final List cachedConnectors = new ArrayList(); + private boolean conduitsDirty = true; private boolean collidablesDirty = true; + private boolean connectorsDirty = true; private int lightOpacity = 0; @@ -308,26 +313,10 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle { @Override public Offset getOffset(Class type, ForgeDirection dir) { - if(getConnectionCount(dir) < 2) { return Offset.NONE; } - - if(dir == ForgeDirection.UNKNOWN) { - if(containsOnlySingleVerticalConnections()) { - return Offsets.get(type, true, false); - } - if(containsOnlySingleHorizontalConnections()) { - return Offsets.get(type, false, true); - } - return Offsets.get(type, true, true); - } - - boolean isVertical = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN; - if(isVertical) { - return Offsets.get(type, false, true); - } - return Offsets.get(type, true, false); + return Offsets.get(type, dir); } @Override @@ -336,6 +325,9 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle { for (IConduit con : conduits) { collidablesDirty = collidablesDirty || con.haveCollidablesChangedSinceLastCall(); } + if(collidablesDirty) { + connectorsDirty = true; + } if(!collidablesDirty && !cachedCollidables.isEmpty()) { return cachedCollidables; } @@ -359,47 +351,105 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle { } private void addConnectors(List result) { + if(conduits.isEmpty()) { return; } - CollidableCache cc = CollidableCache.instance; - if(conduits.size() == 1) { - IConduit con = conduits.get(0); - result.addAll(cc.getCollidables(cc.createKey(con.getCollidableType(), Offset.NONE, ForgeDirection.UNKNOWN, false), con)); - - } else if(containsOnlySingleVerticalConnections()) { - - if(allDirectionsHaveSameConnectionCount()) { - for (IConduit con : conduits) { - Class type = con.getCollidableType(); - result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con)); - } - } else { - // vertical box - result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.VERTICAL), ForgeDirection.UNKNOWN, - ConduitConnectorType.VERTICAL)); - } - - } else if(containsOnlySingleHorizontalConnections()) { - - if(allDirectionsHaveSameConnectionCount()) { - for (IConduit con : conduits) { - Class type = con.getCollidableType(); - result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con)); - } - - } else { - // vertical box - result - .add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.HORIZONTAL), ForgeDirection.UNKNOWN, - ConduitConnectorType.HORIZONTAL)); - } - } else { - result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.BOTH), ForgeDirection.UNKNOWN, - ConduitConnectorType.BOTH)); + for (IConduit con : conduits) { + boolean b = con.haveCollidablesChangedSinceLastCall(); + collidablesDirty = collidablesDirty || b; + connectorsDirty = connectorsDirty || b; } + if(!connectorsDirty && !cachedConnectors.isEmpty()) { + result.addAll(cachedConnectors); + return; + } + + cachedConnectors.clear(); + + List coreBounds = new ArrayList(); + for (IConduit con : conduits) { + addConduitCores(coreBounds, con); + } + cachedConnectors.addAll(coreBounds); + result.addAll(coreBounds); + + List conduitsBounds = new ArrayList(); + for (IConduit con : conduits) { + conduitsBounds.addAll(con.getCollidableComponents()); + addConduitCores(conduitsBounds, con); + } + + Set> collidingTypes = new HashSet>(); + for (CollidableComponent conCC : conduitsBounds) { + for (CollidableComponent innerCC : conduitsBounds) { + if(!InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(innerCC.data) && !InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(conCC.data) + && conCC != innerCC && conCC.bound.intersects(innerCC.bound)) { + collidingTypes.add((Class) conCC.conduitType); + } + } + } + + //TODO: Remove the core geometries covered up by this as no point in rendering these + if(!collidingTypes.isEmpty()) { + List colCores = new ArrayList(); + for (Class c : collidingTypes) { + IConduit con = getConduit(c); + if(con != null) { + addConduitCores(colCores, con); + } + } + + BoundingBox bb = null; + for (CollidableComponent cBB : colCores) { + if(bb == null) { + bb = cBB.bound; + } else { + bb = bb.expandBy(cBB.bound); + } + } + if(bb != null) { + bb = bb.scale(1.05, 1.05, 1.05); + CollidableComponent cc = new CollidableComponent(null, bb, ForgeDirection.UNKNOWN, + ConduitConnectorType.BOTH); + result.add(cc); + cachedConnectors.add(cc); + } + } + + connectorsDirty = false; + + } + + private boolean axisOfConnectionsEqual(Set cons) { + Axis axis = null; + for (ForgeDirection dir : cons) { + if(axis == null) { + axis = Offsets.getAxisForDir(dir); + } else { + if(axis != Offsets.getAxisForDir(dir)) { + return false; + } + } + } + return true; + } + + private void addConduitCores(List result, IConduit con) { + CollidableCache cc = CollidableCache.instance; + Class type = con.getCollidableType(); + if(con.hasConnections()) { + for (ForgeDirection dir : con.getExternalConnections()) { + result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), dir), ForgeDirection.UNKNOWN, false), con)); + } + for (ForgeDirection dir : con.getConduitConnections()) { + result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), dir), ForgeDirection.UNKNOWN, false), con)); + } + } else { + result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con)); + } } private boolean containsOnlySingleVerticalConnections() { diff --git a/common/crazypants/enderio/conduit/geom/CollidableCache.java b/common/crazypants/enderio/conduit/geom/CollidableCache.java index a489c9cc..e069dad2 100644 --- a/common/crazypants/enderio/conduit/geom/CollidableCache.java +++ b/common/crazypants/enderio/conduit/geom/CollidableCache.java @@ -56,24 +56,32 @@ public class CollidableCache { @Override public boolean equals(Object obj) { - if(this == obj) + if(this == obj) { return true; - if(obj == null) + } + if(obj == null) { return false; - if(getClass() != obj.getClass()) + } + if(getClass() != obj.getClass()) { return false; + } CacheKey other = (CacheKey) obj; if(className == null) { - if(other.className != null) + if(other.className != null) { return false; - } else if(!className.equals(other.className)) + } + } else if(!className.equals(other.className)) { return false; - if(dir != other.dir) + } + if(dir != other.dir) { return false; - if(isStub != other.isStub) + } + if(isStub != other.isStub) { return false; - if(offset != other.offset) + } + if(offset != other.offset) { return false; + } return true; } diff --git a/common/crazypants/enderio/conduit/geom/ConduitGeometryUtil.java b/common/crazypants/enderio/conduit/geom/ConduitGeometryUtil.java index ecc8500e..ed097f8b 100644 --- a/common/crazypants/enderio/conduit/geom/ConduitGeometryUtil.java +++ b/common/crazypants/enderio/conduit/geom/ConduitGeometryUtil.java @@ -91,7 +91,7 @@ public class ConduitGeometryUtil { } public Vector3d getTranslation(ForgeDirection dir, Offset offset) { - Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, 0); + Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, offset.zOffset); result.scale(WIDTH); return result; } diff --git a/common/crazypants/enderio/conduit/geom/ConnectionModeGeometry.java b/common/crazypants/enderio/conduit/geom/ConnectionModeGeometry.java new file mode 100644 index 00000000..8a32a44a --- /dev/null +++ b/common/crazypants/enderio/conduit/geom/ConnectionModeGeometry.java @@ -0,0 +1,121 @@ +package crazypants.enderio.conduit.geom; + +import static crazypants.util.ForgeDirectionOffsets.offsetScaled; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; +import crazypants.enderio.conduit.render.ConduitBundleRenderer; +import crazypants.render.BoundingBox; +import crazypants.render.VertexRotation; +import crazypants.render.VertexTransform; +import crazypants.render.VertexTransformComposite; +import crazypants.render.VertexTranslation; +import crazypants.vecmath.Vector3d; +import crazypants.vecmath.Vertex; + +public class ConnectionModeGeometry { + + private static final EnumMap> VERTS = new EnumMap>(ForgeDirection.class); + + static { + + float scale = 0.8f; + BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS; + refBB = refBB.scale(scale, scale, scale); + refBB = refBB.scale(scale, 1, 1); + + double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitBundleRenderer.CONNECTOR_DEPTH; + + ForgeDirection dir; + Vector3d trans; + + VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5)); + VertexTranslation vtrans = new VertexTranslation(0, 0, 0); + VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans); + + dir = ForgeDirection.SOUTH; + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + dir = ForgeDirection.NORTH; + vrot.setAngle(Math.PI + Math.PI / 2); + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + dir = ForgeDirection.EAST; + vrot.setAngle(Math.PI); + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + dir = ForgeDirection.WEST; + vrot.setAngle(0); + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + vrot.setAxis(new Vector3d(0, 0, 1)); + + dir = ForgeDirection.UP; + vrot.setAngle(-Math.PI / 2); + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + dir = ForgeDirection.DOWN; + vrot.setAngle(Math.PI / 2); + trans = offsetScaled(dir, 0.5); + trans.sub(offsetScaled(dir, offset)); + vtrans.set(trans); + VERTS.put(dir, createVerticesForDir(refBB, xform)); + + } + + private static List createVerticesForDir(BoundingBox refBB, VertexTransform xform) { + List result = new ArrayList(24); + for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) { + result.addAll(refBB.getCornersWithUvForFace(face)); + } + for (Vertex v : result) { + xform.apply(v.xyz); + //v.xyz.set(v.x(), v.y() + 1, v.z()); + xform.applyToNormal(v.normal); + + } + return result; + } + + public static void renderModeConnector(ForgeDirection dir, Offset offset, Icon tex) { + List verts = VERTS.get(dir); + if(verts == null) { + return; + } + + Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset); + + float uWidth = tex.getMaxU() - tex.getMinU(); + float uScale = uWidth * 0.64f; + float minU = tex.getMinU() + (uWidth - uScale); + float vScale = tex.getMaxV() - tex.getMinV(); + + Tessellator tes = Tessellator.instance; + for (Vertex v : verts) { + tes.setNormal(v.nx(), v.ny(), v.nz()); + tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale)); + } + + } + +} diff --git a/common/crazypants/enderio/conduit/geom/Offset.java b/common/crazypants/enderio/conduit/geom/Offset.java index be0fc304..b25d05bb 100644 --- a/common/crazypants/enderio/conduit/geom/Offset.java +++ b/common/crazypants/enderio/conduit/geom/Offset.java @@ -1,5 +1,7 @@ package crazypants.enderio.conduit.geom; +import net.minecraftforge.common.ForgeDirection; + /** * Offset vectors are based on Y up. * @@ -7,22 +9,42 @@ package crazypants.enderio.conduit.geom; */ public enum Offset { - NONE(0, 0), - TOP(0, 1), - BOTTOM(0, -1), - LEFT(-1, 0), - RIGHT(1, 0), - TL(-1, 1), - TR(1, 1), - BL(-1, -1), - BR(1, -1); + NONE(0, 0, 0), + UP(ForgeDirection.UP), + DOWN(ForgeDirection.DOWN), + EAST(ForgeDirection.EAST), + WEST(ForgeDirection.WEST), + SOUTH(ForgeDirection.SOUTH), + NORTH(ForgeDirection.NORTH), + EAST_UP(ForgeDirection.EAST, ForgeDirection.UP), + WEST_UP(ForgeDirection.WEST, ForgeDirection.UP), + SOUTH_UP(ForgeDirection.SOUTH, ForgeDirection.UP), + NORTH_UP(ForgeDirection.NORTH, ForgeDirection.UP), + EAST_DOWN(ForgeDirection.EAST, ForgeDirection.DOWN), + WEST_DOWN(ForgeDirection.WEST, ForgeDirection.DOWN), + SOUTH_DOWN(ForgeDirection.SOUTH, ForgeDirection.DOWN), + NORTH_DOWN(ForgeDirection.NORTH, ForgeDirection.DOWN); public final int xOffset; public final int yOffset; + public final int zOffset; - private Offset(int xOffset, int yOffset) { + private Offset(ForgeDirection dir) { + xOffset = dir.offsetX; + yOffset = dir.offsetY; + zOffset = dir.offsetZ; + } + + private Offset(ForgeDirection dir, ForgeDirection yDir) { + xOffset = dir.offsetX; + yOffset = yDir.offsetY; + zOffset = dir.offsetZ; + } + + private Offset(int xOffset, int yOffset, int zOffset) { this.xOffset = xOffset; this.yOffset = yOffset; + this.zOffset = zOffset; } } diff --git a/common/crazypants/enderio/conduit/geom/Offsets.java b/common/crazypants/enderio/conduit/geom/Offsets.java index 0a940d0d..088516a6 100644 --- a/common/crazypants/enderio/conduit/geom/Offsets.java +++ b/common/crazypants/enderio/conduit/geom/Offsets.java @@ -3,7 +3,9 @@ package crazypants.enderio.conduit.geom; import java.util.HashMap; import java.util.Map; +import net.minecraftforge.common.ForgeDirection; import crazypants.enderio.conduit.IConduit; +import crazypants.enderio.conduit.item.IItemConduit; import crazypants.enderio.conduit.liquid.ILiquidConduit; import crazypants.enderio.conduit.power.IPowerConduit; import crazypants.enderio.conduit.redstone.IRedstoneConduit; @@ -13,70 +15,111 @@ public class Offsets { private static Map OFFSETS = new HashMap(); static { - OFFSETS.put(key(IRedstoneConduit.class, true, false), Offset.BOTTOM); - OFFSETS.put(key(IPowerConduit.class, true, false), Offset.TOP); - OFFSETS.put(key(ILiquidConduit.class, true, false), Offset.NONE); + OFFSETS.put(key(IRedstoneConduit.class, Axis.NONE), Offset.UP); + OFFSETS.put(key(IRedstoneConduit.class, Axis.X), Offset.UP); + OFFSETS.put(key(IRedstoneConduit.class, Axis.Y), Offset.NORTH); + OFFSETS.put(key(IRedstoneConduit.class, Axis.Z), Offset.UP); - OFFSETS.put(key(IRedstoneConduit.class, false, true), Offset.LEFT); - OFFSETS.put(key(IPowerConduit.class, false, true), Offset.RIGHT); - OFFSETS.put(key(ILiquidConduit.class, false, true), Offset.NONE); + OFFSETS.put(key(IPowerConduit.class, Axis.NONE), Offset.DOWN); + OFFSETS.put(key(IPowerConduit.class, Axis.X), Offset.DOWN); + OFFSETS.put(key(IPowerConduit.class, Axis.Y), Offset.SOUTH); + OFFSETS.put(key(IPowerConduit.class, Axis.Z), Offset.DOWN); - OFFSETS.put(key(IRedstoneConduit.class, true, true), Offset.BL); - OFFSETS.put(key(IPowerConduit.class, true, true), Offset.TR); - OFFSETS.put(key(ILiquidConduit.class, true, true), Offset.NONE); + OFFSETS.put(key(ILiquidConduit.class, Axis.NONE), Offset.WEST); + OFFSETS.put(key(ILiquidConduit.class, Axis.X), Offset.NORTH); + OFFSETS.put(key(ILiquidConduit.class, Axis.Y), Offset.WEST); + OFFSETS.put(key(ILiquidConduit.class, Axis.Z), Offset.WEST); + + OFFSETS.put(key(IItemConduit.class, Axis.NONE), Offset.EAST); + OFFSETS.put(key(IItemConduit.class, Axis.X), Offset.SOUTH); + OFFSETS.put(key(IItemConduit.class, Axis.Y), Offset.EAST); + OFFSETS.put(key(IItemConduit.class, Axis.Z), Offset.EAST); } - public static Offset get(Class type, boolean horizontal, boolean vertical) { - return OFFSETS.get(key(type, horizontal, vertical)); + public static Offset get(Class type, ForgeDirection dir) { + Offset res = OFFSETS.get(key(type, getAxisForDir(dir))); + if(res == null) { + res = Offset.NONE; + } + return res; } - public static OffsetKey key(Class type, boolean horizontal, boolean vertical) { - return new OffsetKey(type, horizontal, vertical); + public static OffsetKey key(Class type, Axis axis) { + return new OffsetKey(type, axis); + } + + public static Axis getAxisForDir(ForgeDirection dir) { + if(dir == ForgeDirection.UNKNOWN) { + return Axis.NONE; + } + if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) { + return Axis.X; + } + if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) { + return Axis.Y; + } + if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) { + return Axis.Z; + } + return Axis.NONE; + } + + public static enum Axis { + NONE, + X, + Y, + Z } public static class OffsetKey { String typeName; - boolean horizontal; - boolean vertical; + Axis axis; - private OffsetKey(Class type, boolean horizontal, boolean vertical) { + private OffsetKey(Class type, Axis axis) { this.typeName = type.getCanonicalName(); - this.horizontal = horizontal; - this.vertical = vertical; + this.axis = axis; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (horizontal ? 1231 : 1237); + result = prime * result + ((axis == null) ? 0 : axis.hashCode()); result = prime * result + ((typeName == null) ? 0 : typeName.hashCode()); - result = prime * result + (vertical ? 1231 : 1237); return result; } @Override public boolean equals(Object obj) { - if(this == obj) + if(this == obj) { return true; - if(obj == null) + } + if(obj == null) { return false; - if(getClass() != obj.getClass()) + } + if(getClass() != obj.getClass()) { return false; + } OffsetKey other = (OffsetKey) obj; - if(horizontal != other.horizontal) + if(axis != other.axis) { return false; + } if(typeName == null) { - if(other.typeName != null) + if(other.typeName != null) { return false; - } else if(!typeName.equals(other.typeName)) - return false; - if(vertical != other.vertical) + } + } else if(!typeName.equals(other.typeName)) { return false; + } return true; } + @Override + public String toString() { + return "OffsetKey [typeName=" + typeName + ", axis=" + axis + "]"; + } + } } diff --git a/common/crazypants/enderio/conduit/item/IItemConduit.java b/common/crazypants/enderio/conduit/item/IItemConduit.java new file mode 100644 index 00000000..650da0b1 --- /dev/null +++ b/common/crazypants/enderio/conduit/item/IItemConduit.java @@ -0,0 +1,24 @@ +package crazypants.enderio.conduit.item; + +import net.minecraft.inventory.IInventory; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; +import crazypants.enderio.conduit.IConduit; + +public interface IItemConduit extends IConduit { + + Icon getTextureForInputMode(); + + Icon getTextureForOutputMode(); + + Icon getTextureForInOutMode(); + + Icon getEnderIcon(); + + IInventory getExternalInventory(ForgeDirection direction); + + int getMaximumExtracted(int slot); + + void itemsExtracted(int numInserted, int slot); + +} diff --git a/common/crazypants/enderio/conduit/item/ItemConduit.java b/common/crazypants/enderio/conduit/item/ItemConduit.java new file mode 100644 index 00000000..33deaca1 --- /dev/null +++ b/common/crazypants/enderio/conduit/item/ItemConduit.java @@ -0,0 +1,342 @@ +package crazypants.enderio.conduit.item; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import crazypants.enderio.ClientProxy; +import crazypants.enderio.EnderIO; +import crazypants.enderio.ModObject; +import crazypants.enderio.conduit.AbstractConduit; +import crazypants.enderio.conduit.AbstractConduitNetwork; +import crazypants.enderio.conduit.ConduitUtil; +import crazypants.enderio.conduit.ConnectionMode; +import crazypants.enderio.conduit.IConduit; +import crazypants.enderio.conduit.IConduitBundle; +import crazypants.enderio.conduit.RaytraceResult; +import crazypants.enderio.conduit.geom.CollidableComponent; +import crazypants.render.BoundingBox; +import crazypants.render.IconUtil; +import crazypants.util.BlockCoord; +import crazypants.util.ForgeDirectionOffsets; +import crazypants.vecmath.Vector3d; +import crazypants.vecmath.Vector3f; + +public class ItemConduit extends AbstractConduit implements IItemConduit { + + public static final String EXTERNAL_INTERFACE_GEOM = "ExternalInterface"; + + public static final String ICON_KEY = "enderio:itemConduit"; + //public static final String ICON_KEY = "enderio:tesseractPortal"; + + public static final String ICON_CORE_KEY = "enderio:itemConduitCore"; + + public static final String ICON_CORE_ADVANCED_KEY = "enderio:itemConduitCoreAdvanced"; + + public static final String ICON_KEY_INPUT = "enderio:itemConduitInput"; + + public static final String ICON_KEY_OUTPUT = "enderio:itemConduitOutput"; + + public static final String ICON_KEY_IN_OUT = "enderio:itemConduitInOut"; + + public static final String ICON_KEY_ENDER = "enderio:ender_still"; + + static final Map ICONS = new HashMap(); + + public static void initIcons() { + IconUtil.addIconProvider(new IconUtil.IIconProvider() { + + @Override + public void registerIcons(IconRegister register) { + ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY)); + ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY)); + ICONS.put(ICON_CORE_ADVANCED_KEY, register.registerIcon(ICON_CORE_ADVANCED_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, register.registerIcon(ICON_KEY_IN_OUT)); + ICONS.put(ICON_KEY_ENDER, register.registerIcon(ICON_KEY_ENDER)); + } + + @Override + public int getTextureType() { + return 0; + } + + }); + } + + ItemConduitNetwork network; + + int maxExtractedOnTick = 2; + float extractRatePerTick = maxExtractedOnTick / 20f; + long extractedAtLastTick = -1; + + boolean isAdvanced = false; + + public ItemConduit() { + this(false); + } + + public ItemConduit(boolean isAdvanced) { + setAdvanced(isAdvanced); + } + + public void setAdvanced(boolean advanced) { + this.isAdvanced = advanced; + if(isAdvanced) { + maxExtractedOnTick = 2; + extractRatePerTick = maxExtractedOnTick / 20f; + } else { + maxExtractedOnTick = 64; + extractRatePerTick = maxExtractedOnTick / 20f; + } + } + + @Override + public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List all) { + if(ConduitUtil.isToolEquipped(player)) { + if(!getBundle().getEntity().worldObj.isRemote) { + if(res != null && res.component != null) { + ForgeDirection connDir = res.component.dir; + ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); + + if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) { + // Attempt to join networks + BlockCoord loc = getLocation().getLocation(faceHit); + IItemConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IItemConduit.class); + if(neighbour != null) { + if(network != null) { + network.destroyNetwork(); + } + onAddedToBundle(); + return true; + } + } else if(externalConnections.contains(connDir)) { + setConnectionMode(connDir, getNextConnectionMode(connDir)); + return true; + } else if(containsConduitConnection(connDir)) { + conduitConnectionRemoved(connDir); + BlockCoord loc = getLocation().getLocation(connDir); + IItemConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IItemConduit.class); + if(neighbour != null) { + neighbour.conduitConnectionRemoved(connDir.getOpposite()); + } + if(network != null) { + network.destroyNetwork(); + } + return true; + } + } + } + } + return false; + } + + @Override + public int getMaximumExtracted(int slot) { + World world = getBundle().getEntity().worldObj; + if(world == null) { + return 0; + } + long curTick = world.getTotalWorldTime(); + int numTicksSinceExtract = (int) (curTick - extractedAtLastTick); + int result = (int) (numTicksSinceExtract * extractRatePerTick); + result = Math.min(result, maxExtractedOnTick); + return result; + } + + @Override + public void itemsExtracted(int numInserted, int slot) { + World world = getBundle().getEntity().worldObj; + if(world != null) { + extractedAtLastTick = world.getTotalWorldTime(); + } else { + extractedAtLastTick = -1; + } + } + + @Override + public void externalConnectionAdded(ForgeDirection direction) { + super.externalConnectionAdded(direction); + if(network != null) { + TileEntity te = bundle.getEntity(); + network.inventoryAdded(this, direction, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ, + getExternalInventory(direction)); + } + } + + @Override + public IInventory getExternalInventory(ForgeDirection direction) { + World world = getBundle().getWorld(); + if(world == null) { + return null; + } + BlockCoord loc = getLocation().getLocation(direction); + TileEntity te = world.getBlockTileEntity(loc.x, loc.y, loc.z); + if(te instanceof IInventory && !(te instanceof IConduitBundle)) { + return (IInventory) te; + } + return null; + } + + @Override + public void externalConnectionRemoved(ForgeDirection direction) { + super.externalConnectionRemoved(direction); + if(network != null) { + TileEntity te = bundle.getEntity(); + network.inventoryRemoved(this, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ); + } + } + + @Override + public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) { + ConnectionMode oldVal = conectionModes.get(dir); + if(oldVal == mode) { + return; + } + super.setConnectionMode(dir, mode); + if(network != null) { + network.connectionModeChanged(this, mode); + } + } + + @Override + public boolean canConnectToExternal(ForgeDirection direction) { + return getExternalInventory(direction) != null; + } + + @Override + protected ConnectionMode getDefaultConnectionMode() { + return ConnectionMode.INPUT; + } + + @Override + public Class getBaseConduitType() { + return IItemConduit.class; + } + + @Override + public ItemStack createItem() { + ItemStack result = new ItemStack(ModObject.itemItemConduit.actualId, 1, 0); + return result; + } + + @Override + public AbstractConduitNetwork getNetwork() { + return network; + } + + @Override + public boolean setNetwork(AbstractConduitNetwork network) { + this.network = (ItemConduitNetwork) network; + return true; + } + + @Override + public Icon getTextureForInputMode() { + return ICONS.get(ICON_KEY_INPUT); + } + + @Override + public Icon getTextureForOutputMode() { + return ICONS.get(ICON_KEY_OUTPUT); + } + + @Override + public Icon getTextureForInOutMode() { + return ICONS.get(ICON_KEY_IN_OUT); + } + + @Override + public Icon getEnderIcon() { + return ICONS.get(ICON_KEY_ENDER); + } + + @Override + public Icon getTextureForState(CollidableComponent component) { + if(component.dir == ForgeDirection.UNKNOWN) { + return isAdvanced ? ICONS.get(ICON_CORE_ADVANCED_KEY) : ICONS.get(ICON_CORE_KEY); + } + + if(EXTERNAL_INTERFACE_GEOM.equals(component.data)) { + return ICONS.get(ICON_CORE_ADVANCED_KEY); + } + + if(getExternalConnections().contains(component.dir)) { + if(getConectionMode(component.dir) == ConnectionMode.OUTPUT) { + return ICONS.get(ICON_KEY_INPUT); + } + if(getConectionMode(component.dir) == ConnectionMode.INPUT) { + return ICONS.get(ICON_KEY_OUTPUT); + } + if(getConectionMode(component.dir) == ConnectionMode.IN_OUT) { + return ICONS.get(ICON_KEY_IN_OUT); + } + } + return ICONS.get(ICON_KEY); + } + + @Override + public Icon getTransmitionTextureForState(CollidableComponent component) { + return null; + } + + @Override + public List getCollidableComponents() { + if(!isAdvanced) { + return super.getCollidableComponents(); + } + + if(collidables != null && !collidablesDirty) { + return collidables; + } + List result = super.getCollidableComponents(); + + for (ForgeDirection dir : getExternalConnections()) { + if(getConectionMode(dir) != ConnectionMode.DISABLED && getConectionMode(dir) != ConnectionMode.NOT_SET) { // + float scale = 0.1f; + BoundingBox bb = BoundingBox.UNIT_CUBE.scale(scale, scale, scale); + + Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir); + offset.scale(0.5); + offset.scale(scale); + + BoundingBox conectorBounds = ((ClientProxy) EnderIO.proxy).getConduitBundleRenderer().getExternalConnectorBoundsForDirection(dir); + List corners = conectorBounds.getCornersForFace(dir); + + for (Vector3f vec : corners) { + vec.sub(new Vector3f(0.5f, 0.5f, 0.5f)); + vec.sub(new Vector3f(offset)); + + BoundingBox bbb = bb.translate(vec); + result.add(new CollidableComponent(IItemConduit.class, bbb, dir, EXTERNAL_INTERFACE_GEOM)); + } + + } + } + + return result; + } + + @Override + public void writeToNBT(NBTTagCompound nbtRoot) { + super.writeToNBT(nbtRoot); + nbtRoot.setBoolean("isAdvanced", isAdvanced); + } + + @Override + public void readFromNBT(NBTTagCompound nbtRoot) { + super.readFromNBT(nbtRoot); + isAdvanced = nbtRoot.getBoolean("isAdvanced"); + } + +} diff --git a/common/crazypants/enderio/conduit/item/ItemConduitNetwork.java b/common/crazypants/enderio/conduit/item/ItemConduitNetwork.java new file mode 100644 index 00000000..10be7f67 --- /dev/null +++ b/common/crazypants/enderio/conduit/item/ItemConduitNetwork.java @@ -0,0 +1,346 @@ +package crazypants.enderio.conduit.item; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import crazypants.enderio.conduit.AbstractConduitNetwork; +import crazypants.enderio.conduit.ConnectionMode; +import crazypants.enderio.conduit.IConduit; +import crazypants.util.BlockCoord; + +public class ItemConduitNetwork extends AbstractConduitNetwork { + + private long timeAtLastApply; + + private final List inventories = new ArrayList(); + private final Map invMap = new HashMap(); + + private boolean requiresSort = true; + + @Override + public Class getBaseConduitType() { + return IItemConduit.class; + } + + @Override + public void addConduit(IItemConduit con) { + super.addConduit(con); + + TileEntity te = con.getBundle().getEntity(); + if(te != null) { + for (ForgeDirection direction : con.getExternalConnections()) { + IInventory extCon = con.getExternalInventory(direction); + if(extCon != null) { + inventoryAdded(con, direction, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ, extCon); + } + } + } + } + + public void inventoryAdded(IItemConduit itemConduit, ForgeDirection direction, int x, int y, int z, IInventory externalInventory) { + BlockCoord bc = new BlockCoord(x, y, z); + NetworkedInventory inv = new NetworkedInventory(externalInventory, itemConduit, direction, bc); + inventories.add(inv); + invMap.put(bc, inv); + requiresSort = true; + } + + public void inventoryRemoved(ItemConduit itemConduit, int x, int y, int z) { + BlockCoord bc = new BlockCoord(x, y, z); + NetworkedInventory inv = invMap.remove(bc); + if(inv != null) { + inventories.remove(inv); + } + requiresSort = true; + } + + public void connectionModeChanged(ItemConduit itemConduit, ConnectionMode mode) { + requiresSort = true; + } + + private boolean isRemote(ItemConduit itemConduit) { + World world = itemConduit.getBundle().getEntity().worldObj; + if(world != null && world.isRemote) { + return true; + } + return false; + } + + @Override + public void onUpdateEntity(IConduit conduit) { + World world = conduit.getBundle().getEntity().worldObj; + if(world == null) { + return; + } + if(world.isRemote) { + return; + } + long curTime = world.getTotalWorldTime(); + if(curTime != timeAtLastApply) { + timeAtLastApply = curTime; + doTick(); + } + } + + private void doTick() { + for (NetworkedInventory ni : inventories) { + if(requiresSort) { + ni.updateInsertOrder(); + } + ni.onTick(); + } + requiresSort = false; + } + + static int compare(int x, int y) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + + class NetworkedInventory { + + IInventory inv; + ISidedInventory sidedInv; + IItemConduit con; + ForgeDirection conDir; + BlockCoord location; + int inventorySide; + + List sendPriority = new ArrayList(); + + NetworkedInventory(IInventory inv, IItemConduit con, ForgeDirection conDir, BlockCoord location) { + this.inv = inv; + if(inv instanceof ISidedInventory) { + sidedInv = (ISidedInventory) inv; + } + this.con = con; + this.conDir = conDir; + this.location = location; + inventorySide = conDir.getOpposite().ordinal(); + } + + boolean canExtract() { + ConnectionMode mode = con.getConectionMode(conDir); + return mode == ConnectionMode.INPUT || mode == ConnectionMode.IN_OUT; + } + + boolean canInsert() { + ConnectionMode mode = con.getConectionMode(conDir); + return mode == ConnectionMode.OUTPUT || mode == ConnectionMode.IN_OUT; + } + + void onTick() { + if(!canExtract()) { + return; + } + if(sidedInv != null) { + trasnferItemsSided(); + } else { + tranfserItems(); + } + + } + + private void tranfserItems() { + int size = inv.getSizeInventory(); + int numSlots = inv.getSizeInventory(); + ItemStack extractItem = null; + + int slot = -1; + for (int i = 0; i < numSlots && extractItem == null; i++) { + ItemStack item = inv.getStackInSlot(i); + if(item != null) { + extractItem = item.copy(); + slot = i; + } + } + + int maxExtracted = con.getMaximumExtracted(slot); + if(maxExtracted > 0) { + doTranfser(extractItem, slot, maxExtracted); + } + } + + private void trasnferItemsSided() { + + int size = sidedInv.getSizeInventory(); + int[] slotIndices = sidedInv.getAccessibleSlotsFromSide(inventorySide); + ItemStack extractItem = null; + + int slot = -1; + for (int i = 0; i < slotIndices.length && extractItem == null; i++) { + ItemStack item = sidedInv.getStackInSlot(i); + if(item != null) { + extractItem = item.copy(); + slot = i; + if(!sidedInv.canExtractItem(i, extractItem, inventorySide)) { + extractItem = null; + } + } + } + + int maxExtracted = con.getMaximumExtracted(slot); + if(maxExtracted > 0) { + doTranfser(extractItem, slot, maxExtracted); + } + + } + + private void doTranfser(ItemStack extractedItem, int slot, int maxExtract) { + if(extractedItem != null) { + ItemStack toExtract = extractedItem.copy(); + toExtract.stackSize = Math.min(maxExtract, toExtract.stackSize); + int numInserted = insertIntoTargets(toExtract, slot); + + toExtract.stackSize = extractedItem.stackSize - numInserted; + if(toExtract.stackSize > 0) { + inv.setInventorySlotContents(slot, toExtract); + } else { + inv.setInventorySlotContents(slot, null); + } + con.itemsExtracted(numInserted, slot); + } + } + + private int insertIntoTargets(ItemStack toExtract, int slot) { + if(toExtract == null) { + return 0; + } + + int totalToInsert = toExtract.stackSize; + int leftToInsert = totalToInsert; + for (Target target : sendPriority) { + int inserted = target.inv.insertItem(toExtract); + if(inserted > 0) { + toExtract.stackSize -= inserted; + if(toExtract.stackSize > 0) { + inv.setInventorySlotContents(slot, toExtract); + } else { + inv.setInventorySlotContents(slot, null); + } + leftToInsert -= inserted; + } + if(leftToInsert <= 0) { + return totalToInsert; + } + } + return totalToInsert - leftToInsert; + } + + private int insertItem(ItemStack item) { + if(sidedInv != null) { + return doInsertItemSided(item); + } + return doInsertItem(item); + } + + private int doInsertItem(ItemStack item) { + if(!canInsert() || item == null) { + return 0; + + } + int numInserted = 0; + int numToInsert = item.stackSize; + for (int slot = 0; slot < inv.getSizeInventory() && numToInsert > 0; slot++) { + ItemStack contents = inv.getStackInSlot(slot); + ItemStack toInsert = item.copy(); + toInsert.stackSize = Math.min(toInsert.stackSize, inv.getInventoryStackLimit()); + toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert); + int inserted = 0; + if(contents == null) { + inserted = toInsert.stackSize; + } else { + if(contents.isItemEqual(item)) { + int space = inv.getInventoryStackLimit() - contents.stackSize; + space = Math.min(space, contents.getMaxStackSize() - contents.stackSize); + inserted += Math.min(space, toInsert.stackSize); + toInsert.stackSize = contents.stackSize + inserted; + } else { + toInsert.stackSize = 0; + } + } + + if(inserted > 0) { + numInserted += inserted; + numToInsert -= inserted; + inv.setInventorySlotContents(slot, toInsert); + } + } + return numInserted; + + } + + private int doInsertItemSided(ItemStack item) { + + int numInserted = 0; + int numToInsert = item.stackSize; + for (int slot = 0; slot < inv.getSizeInventory() && numToInsert > 0; slot++) { + if(sidedInv.canInsertItem(slot, item, inventorySide)) { + ItemStack contents = inv.getStackInSlot(slot); + ItemStack toInsert = item.copy(); + toInsert.stackSize = Math.min(toInsert.stackSize, inv.getInventoryStackLimit()); + toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert); + int inserted = 0; + if(contents == null) { + inserted = toInsert.stackSize; + } else { + if(contents.isItemEqual(item)) { + int space = inv.getInventoryStackLimit() - contents.stackSize; + space = Math.min(space, contents.getMaxStackSize() - contents.stackSize); + inserted += Math.min(space, toInsert.stackSize); + toInsert.stackSize = contents.stackSize + inserted; + } else { + toInsert.stackSize = 0; + } + } + + if(inserted > 0) { + numInserted += inserted; + numToInsert -= inserted; + inv.setInventorySlotContents(slot, toInsert); + } + } + } + return numInserted; + } + + void updateInsertOrder() { + sendPriority.clear(); + if(!canExtract()) { + return; + } + for (NetworkedInventory other : inventories) { + if(other != this && other.canInsert()) { + sendPriority.add(new Target(other, location.distanceSquared(other.location))); + } + } + Collections.sort(sendPriority); + } + + } + + class Target implements Comparable { + NetworkedInventory inv; + int distance; + + Target(NetworkedInventory inv, int distance) { + this.inv = inv; + this.distance = distance; + } + + @Override + public int compareTo(Target o) { + return compare(distance, o.distance); + } + + } + +} diff --git a/common/crazypants/enderio/conduit/item/ItemConduitRenderer.java b/common/crazypants/enderio/conduit/item/ItemConduitRenderer.java new file mode 100644 index 00000000..2d33834c --- /dev/null +++ b/common/crazypants/enderio/conduit/item/ItemConduitRenderer.java @@ -0,0 +1,91 @@ +package crazypants.enderio.conduit.item; + +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; +import crazypants.enderio.conduit.IConduit; +import crazypants.enderio.conduit.geom.CollidableComponent; +import crazypants.enderio.conduit.render.DefaultConduitRenderer; +import crazypants.render.BoundingBox; +import crazypants.render.CubeRenderer; + +public class ItemConduitRenderer extends DefaultConduitRenderer { + + @Override + public boolean isRendererForConduit(IConduit conduit) { + if(conduit instanceof IItemConduit) { + return true; + } + return false; + } + + // @Override + // 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); + // + // // IItemConduit pc = (IItemConduit) conduit; + // // for (ForgeDirection dir : conduit.getExternalConnections()) { + // // Icon tex = null; + // // if(conduit.getConectionMode(dir) == ConnectionMode.INPUT) { + // // tex = pc.getTextureForInputMode(); + // // } else if(conduit.getConectionMode(dir) == ConnectionMode.OUTPUT) { + // // tex = pc.getTextureForOutputMode(); + // // } else if(conduit.getConectionMode(dir) == ConnectionMode.IN_OUT) { + // // tex = pc.getTextureForInOutMode(); + // // } + // // if(tex != null) { + // // Offset offset = te.getOffset(IItemConduit.class, dir); + // // ConnectionModeGeometry.renderModeConnector(dir, offset, tex); + // // } + // // } + // + // } + + @Override + protected void renderConduit(Icon tex, IConduit conduit, CollidableComponent component, float brightness) { + if(ItemConduit.EXTERNAL_INTERFACE_GEOM.equals(component.data)) { + CubeRenderer.render(component.bound, tex); + } else if(isNSEWUP(component.dir)) { + IItemConduit lc = (IItemConduit) conduit; + + float scaleFactor = 0.6f; + float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor; + float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor; + float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor; + + scaleFactor -= 0.1f; + float xLen2 = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor; + float yLen2 = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor; + float zLen2 = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor; + + BoundingBox[] cubes = toCubes(component.bound); + for (BoundingBox cube : cubes) { + + BoundingBox bb = cube.scale(xLen, yLen, zLen); + drawSection(bb, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), component.dir, false); + bb = cube.scale(xLen2, yLen2, zLen2); + CubeRenderer.render(bb, ((IItemConduit) conduit).getEnderIcon()); + } + + } else { + drawSection(component.bound, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), component.dir, true); + } + + } + + private void renderFluidCenter(CollidableComponent component, IItemConduit conduit) { + + if(component == null || component.dir == ForgeDirection.UNKNOWN) { + return; + } + + BoundingBox bb = component.bound; + float scaleFactor = 0.6f; + float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor; + float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor; + float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor; + bb = bb.scale(xLen, yLen, zLen); + CubeRenderer.render(bb, conduit.getEnderIcon()); + + } +} diff --git a/common/crazypants/enderio/conduit/item/ItemItemConduit.java b/common/crazypants/enderio/conduit/item/ItemItemConduit.java new file mode 100644 index 00000000..63d95bdf --- /dev/null +++ b/common/crazypants/enderio/conduit/item/ItemItemConduit.java @@ -0,0 +1,39 @@ +package crazypants.enderio.conduit.item; + +import net.minecraft.item.ItemStack; +import crazypants.enderio.ModObject; +import crazypants.enderio.conduit.AbstractItemConduit; +import crazypants.enderio.conduit.IConduit; +import crazypants.enderio.conduit.ItemConduitSubtype; + +public class ItemItemConduit extends AbstractItemConduit { + + private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] { + new ItemConduitSubtype(ModObject.itemItemConduit.unlocalisedName, ModObject.itemItemConduit.name, "enderio:itemItemConduit"), + new ItemConduitSubtype(ModObject.itemItemConduit.unlocalisedName + "Advanced", "Advanced Item Conduit", "enderio:itemItemConduitAdvanced"), + }; + + public static ItemItemConduit create() { + ItemItemConduit result = new ItemItemConduit(); + result.init(subtypes); + return result; + } + + protected ItemItemConduit() { + super(ModObject.itemItemConduit); + } + + @Override + public Class getBaseConduitType() { + return IItemConduit.class; + } + + @Override + public IConduit createConduit(ItemStack item) { + if(item.getItemDamage() == 1) { + return new ItemConduit(true); + } + return new ItemConduit(); + } + +} diff --git a/common/crazypants/enderio/conduit/liquid/LiquidConduit.java b/common/crazypants/enderio/conduit/liquid/LiquidConduit.java index 0355f37b..ab0313b3 100644 --- a/common/crazypants/enderio/conduit/liquid/LiquidConduit.java +++ b/common/crazypants/enderio/conduit/liquid/LiquidConduit.java @@ -97,7 +97,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit { if(!getBundle().getEntity().worldObj.isRemote) { - if(res.component != null) { + if(res != null && res.component != null) { ForgeDirection connDir = res.component.dir; ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); diff --git a/common/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java b/common/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java index 76f415f9..85fd127f 100644 --- a/common/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java +++ b/common/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java @@ -94,7 +94,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer { Tessellator tes = Tessellator.instance; tes.setNormal(face.offsetX, face.offsetY, face.offsetZ); - float scaleFactor = 14f / 16f; + float scaleFactor = 13f / 16f; Vector2d uv = new Vector2d(); List edges = RenderUtil.getEdgesForFace(face); for (ForgeDirection edge : edges) { diff --git a/common/crazypants/enderio/conduit/power/PowerConduit.java b/common/crazypants/enderio/conduit/power/PowerConduit.java index 11144921..5ea27d59 100644 --- a/common/crazypants/enderio/conduit/power/PowerConduit.java +++ b/common/crazypants/enderio/conduit/power/PowerConduit.java @@ -101,7 +101,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit { public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List all) { if(ConduitUtil.isToolEquipped(player)) { if(!getBundle().getEntity().worldObj.isRemote) { - if(res.component != null) { + if(res != null && res.component != null) { ForgeDirection connDir = res.component.dir; ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); diff --git a/common/crazypants/enderio/conduit/power/PowerConduitRenderer.java b/common/crazypants/enderio/conduit/power/PowerConduitRenderer.java index 85751882..b13b94b0 100644 --- a/common/crazypants/enderio/conduit/power/PowerConduitRenderer.java +++ b/common/crazypants/enderio/conduit/power/PowerConduitRenderer.java @@ -1,113 +1,22 @@ package crazypants.enderio.conduit.power; -import static crazypants.util.ForgeDirectionOffsets.offsetScaled; - -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; - -import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.Icon; import net.minecraftforge.common.ForgeDirection; import crazypants.enderio.conduit.ConnectionMode; import crazypants.enderio.conduit.IConduit; import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.conduit.geom.ConduitGeometryUtil; +import crazypants.enderio.conduit.geom.ConnectionModeGeometry; import crazypants.enderio.conduit.geom.Offset; import crazypants.enderio.conduit.render.ConduitBundleRenderer; import crazypants.enderio.conduit.render.DefaultConduitRenderer; -import crazypants.render.BoundingBox; -import crazypants.render.VertexRotation; -import crazypants.render.VertexTransform; -import crazypants.render.VertexTransformComposite; -import crazypants.render.VertexTranslation; -import crazypants.vecmath.Vector3d; -import crazypants.vecmath.Vertex; public class PowerConduitRenderer extends DefaultConduitRenderer { - private static final EnumMap> VERTS = new EnumMap>(ForgeDirection.class); - - static { - - float scale = 0.8f; - BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS; - refBB = refBB.scale(scale, scale, scale); - refBB = refBB.scale(scale, 1, 1); - - double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitBundleRenderer.CONNECTOR_DEPTH; - - ForgeDirection dir; - Vector3d trans; - - VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5)); - VertexTranslation vtrans = new VertexTranslation(0, 0, 0); - VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans); - - dir = ForgeDirection.SOUTH; - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - dir = ForgeDirection.NORTH; - vrot.setAngle(Math.PI + Math.PI / 2); - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - dir = ForgeDirection.EAST; - vrot.setAngle(Math.PI); - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - dir = ForgeDirection.WEST; - vrot.setAngle(0); - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - vrot.setAxis(new Vector3d(0, 0, 1)); - - dir = ForgeDirection.UP; - vrot.setAngle(-Math.PI / 2); - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - dir = ForgeDirection.DOWN; - vrot.setAngle(Math.PI / 2); - trans = offsetScaled(dir, 0.5); - trans.sub(offsetScaled(dir, offset)); - vtrans.set(trans); - VERTS.put(dir, createVerticesForDir(refBB, xform)); - - } - @Override public boolean isRendererForConduit(IConduit conduit) { return conduit instanceof IPowerConduit; } - private static List createVerticesForDir(BoundingBox refBB, VertexTransform xform) { - List result = new ArrayList(24); - for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) { - result.addAll(refBB.getCornersWithUvForFace(face)); - } - for (Vertex v : result) { - xform.apply(v.xyz); - //v.xyz.set(v.x(), v.y() + 1, v.z()); - xform.applyToNormal(v.normal); - - } - return result; - } - @Override public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick, float worldLight) { @@ -126,34 +35,10 @@ public class PowerConduitRenderer extends DefaultConduitRenderer { } if(tex != null) { Offset offset = te.getOffset(IPowerConduit.class, dir); - renderModeConnector(pc, dir, offset, tex); + ConnectionModeGeometry.renderModeConnector(dir, offset, tex); } } } - private void renderModeConnector(IPowerConduit pc, ForgeDirection dir, Offset offset, Icon tex) { - List verts = VERTS.get(dir); - if(verts == null) { - return; - } - - Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset); - - // double xOffset = offset.xOffset * ConduitGeometryUtil.WIDTH; - // double yOffset = offset.yOffset * ConduitGeometryUtil.HEIGHT; - - float uWidth = tex.getMaxU() - tex.getMinU(); - float uScale = uWidth * 0.64f; - float minU = tex.getMinU() + (uWidth - uScale); - float vScale = tex.getMaxV() - tex.getMinV(); - - Tessellator tes = Tessellator.instance; - for (Vertex v : verts) { - tes.setNormal(v.nx(), v.ny(), v.nz()); - tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale)); - } - - } - } diff --git a/common/crazypants/enderio/conduit/redstone/IInsulatedRedstoneConduit.java b/common/crazypants/enderio/conduit/redstone/IInsulatedRedstoneConduit.java index 9dce87e1..28258f14 100644 --- a/common/crazypants/enderio/conduit/redstone/IInsulatedRedstoneConduit.java +++ b/common/crazypants/enderio/conduit/redstone/IInsulatedRedstoneConduit.java @@ -10,7 +10,7 @@ public interface IInsulatedRedstoneConduit extends IRedstoneConduit { static final String KEY_INS_CORE_ON_ICON = "enderio:redstoneInsulatedConduitCoreOn"; static final String KEY_COLOR_CONTROLLER = "enderio:white"; - static final String COLOR_CONTROLLER_ID = "ColorController"; + public static final String COLOR_CONTROLLER_ID = "ColorController"; public void onInputsChanged(ForgeDirection side, int[] inputValues); diff --git a/common/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java b/common/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java index b81f769e..68cb425b 100644 --- a/common/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java +++ b/common/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java @@ -83,7 +83,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula return true; } else if(ConduitUtil.isToolEquipped(player)) { - if(res.component != null) { + if(res != null && res.component != null) { ForgeDirection connDir = res.component.dir; ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); @@ -167,7 +167,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula @Override public Class getCollidableType() { - return InsulatedRedstoneConduit.class; + return IInsulatedRedstoneConduit.class; } @Override diff --git a/common/crazypants/enderio/conduit/render/ConduitBundleRenderer.java b/common/crazypants/enderio/conduit/render/ConduitBundleRenderer.java index 1bd79a72..c521bd56 100644 --- a/common/crazypants/enderio/conduit/render/ConduitBundleRenderer.java +++ b/common/crazypants/enderio/conduit/render/ConduitBundleRenderer.java @@ -1,5 +1,7 @@ package crazypants.enderio.conduit.render; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -24,6 +26,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import crazypants.enderio.EnderIO; import crazypants.enderio.ModObject; import crazypants.enderio.conduit.BlockConduitBundle; +import crazypants.enderio.conduit.ConduitDisplayMode; import crazypants.enderio.conduit.ConduitUtil; import crazypants.enderio.conduit.ConnectionMode; import crazypants.enderio.conduit.IConduit; @@ -48,6 +51,12 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements } } + public BoundingBox getExternalConnectorBoundsForDirection(ForgeDirection dir) { + BoundingBox[] bbs = connectorBounds.get(dir); + BoundingBox result = bbs[0]; + return result; + } + @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { IConduitBundle bundle = (IConduitBundle) te; @@ -95,13 +104,25 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements // Conduits Set externals = new HashSet(); + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + + List wireBounds = new ArrayList(); + for (IConduit con : bundle.getConduits()) { - ConduitRenderer renderer = EnderIO.proxy.getRendererForConduit(con); - renderer.renderEntity(this, bundle, con, x, y, z, partialTick, brightness); - Set extCons = con.getExternalConnections(); - for (ForgeDirection dir : extCons) { - if(con.getConectionMode(dir) != ConnectionMode.DISABLED && con.getConectionMode(dir) != ConnectionMode.NOT_SET) { - externals.add(dir); + + if(ConduitUtil.renderConduit(player, con)) { + ConduitRenderer renderer = EnderIO.proxy.getRendererForConduit(con); + renderer.renderEntity(this, bundle, con, x, y, z, partialTick, brightness); + Set extCons = con.getExternalConnections(); + for (ForgeDirection dir : extCons) { + if(con.getConectionMode(dir) != ConnectionMode.DISABLED && con.getConectionMode(dir) != ConnectionMode.NOT_SET) { + externals.add(dir); + } + } + } else if(con != null) { + Collection components = con.getCollidableComponents(); + for (CollidableComponent component : components) { + wireBounds.add(component.bound); } } @@ -111,16 +132,30 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements List connectors = bundle.getConnectors(); for (CollidableComponent component : connectors) { if(component.conduitType != null) { - IConduit con = bundle.getConduit(component.conduitType); - float selfIllum = Math.max(brightness, con.getSelfIlluminationForState(component)); - tessellator.setColorRGBA_F(selfIllum, selfIllum, selfIllum, 1); - CubeRenderer.render(component.bound, con.getTextureForState(component)); - } else { + IConduit conduit = bundle.getConduit(component.conduitType); + if(conduit != null) { + if(ConduitUtil.renderConduit(player, component.conduitType)) { + float selfIllum = Math.max(brightness, conduit.getSelfIlluminationForState(component)); + tessellator.setColorRGBA_F(selfIllum, selfIllum, selfIllum, 1); + CubeRenderer.render(component.bound, conduit.getTextureForState(component)); + } else { + wireBounds.add(component.bound); + } + } + + } else if(ConduitUtil.getDisplayMode(player) == ConduitDisplayMode.ALL) { Icon tex = EnderIO.blockConduitBundle.getConnectorIcon(); CubeRenderer.render(component.bound, tex); } } + //render these after the 'normal' conduits so help with proper blending + for (BoundingBox wireBound : wireBounds) { + Tessellator.instance.setColorRGBA_F(1, 1, 1, 0.25f); + CubeRenderer.render(wireBound, EnderIO.blockConduitFacade.getIcon(0, 0)); + Tessellator.instance.setColorRGBA_F(1, 1, 1, 1f); + } + // External connection terminations for (ForgeDirection dir : externals) { renderExternalConnection(dir); diff --git a/common/crazypants/enderio/conduit/render/RoundedSegmentRenderer.java b/common/crazypants/enderio/conduit/render/RoundedSegmentRenderer.java index d1e177a7..2e274139 100644 --- a/common/crazypants/enderio/conduit/render/RoundedSegmentRenderer.java +++ b/common/crazypants/enderio/conduit/render/RoundedSegmentRenderer.java @@ -8,6 +8,8 @@ import java.util.List; import net.minecraft.client.renderer.Tessellator; import net.minecraftforge.common.ForgeDirection; import crazypants.enderio.conduit.geom.ConduitGeometryUtil; +import crazypants.enderio.conduit.geom.Offsets; +import crazypants.enderio.conduit.geom.Offsets.Axis; import crazypants.render.BoundingBox; import crazypants.vecmath.Matrix4d; import crazypants.vecmath.Vector2f; @@ -173,10 +175,13 @@ public class RoundedSegmentRenderer { private static Vector3d calcOffset(ForgeDirection dir, BoundingBox bounds) { Vector3d res = new Vector3d(); Vector3d center = bounds.getCenter(); - if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) { - res.set(0, center.y - REF_TRANS.y, 0); - } else { - res.set(center.x - REF_TRANS.x, 0, 0); + Axis axis = Offsets.getAxisForDir(dir); + if(axis == Axis.X) { + res.set(0, center.y - REF_TRANS.y, center.z - REF_TRANS.z); + } else if(axis == Axis.Y) { + res.set(center.x - REF_TRANS.x, 0, center.z - REF_TRANS.z); + } else if(axis == Axis.Z) { + res.set(center.x - REF_TRANS.x, center.y - REF_TRANS.y, 0); } return res; } diff --git a/common/crazypants/enderio/gui/IconEIO.java b/common/crazypants/enderio/gui/IconEIO.java index 94baccea..952b4e25 100644 --- a/common/crazypants/enderio/gui/IconEIO.java +++ b/common/crazypants/enderio/gui/IconEIO.java @@ -2,9 +2,6 @@ package crazypants.enderio.gui; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - import crazypants.render.RenderUtil; public final class IconEIO { @@ -23,6 +20,13 @@ 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, 32, 32); + public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(32, 148, 32, 32); + public static final IconEIO WRENCH_OVERLAY_POWER = new IconEIO(0, 148); + public static final IconEIO WRENCH_OVERLAY_REDSTONE = new IconEIO(16, 148); + public static final IconEIO WRENCH_OVERLAY_ITEM = new IconEIO(0, 164); + public static final IconEIO WRENCH_OVERLAY_FLUID = new IconEIO(16, 164); + private static final int TEX_SIZE = 256; private static final double PIX_SIZE = 1d / TEX_SIZE; @@ -30,6 +34,8 @@ public final class IconEIO { public final double maxU; public final double minV; public final double maxV; + public final double width; + public final double height; public static final ResourceLocation TEXTURE = new ResourceLocation("enderio:textures/gui/widgets.png"); @@ -38,22 +44,20 @@ public final class IconEIO { } public IconEIO(int x, int y, int width, int height) { - this((float) (PIX_SIZE * x), (float) (PIX_SIZE * (x + width)), (float) (PIX_SIZE * y), (float) (PIX_SIZE * (y + height))); + this(width, height, (float) (PIX_SIZE * x), (float) (PIX_SIZE * (x + width)), (float) (PIX_SIZE * y), (float) (PIX_SIZE * (y + height))); } - public IconEIO(double minU, double maxU, double minV, double maxV) { + public IconEIO(double width, double height, double minU, double maxU, double minV, double maxV) { + this.width = width; + this.height = height; this.minU = minU; this.maxU = maxU; this.minV = minV; this.maxV = maxV; - // this.minU = maxU; - // this.maxU = minU; - // this.minV = maxV; - // this.maxV = minV; } public void renderIcon(double x, double y) { - renderIcon(x, y, 16, 16, 0, false); + renderIcon(x, y, width, height, 0, false); } public void renderIcon(double x, double y, double width, double height, double zLevel, boolean doDraw) { @@ -61,7 +65,6 @@ public final class IconEIO { Tessellator tessellator = Tessellator.instance; if(doDraw) { RenderUtil.bindTexture(TEXTURE); - GL11.glColor3f(1, 1, 1); tessellator.startDrawingQuads(); } tessellator.addVertexWithUV(x, y + height, zLevel, minU, maxV); diff --git a/common/crazypants/enderio/item/ItemRecipes.java b/common/crazypants/enderio/item/ItemRecipes.java new file mode 100644 index 00000000..42f18c31 --- /dev/null +++ b/common/crazypants/enderio/item/ItemRecipes.java @@ -0,0 +1,20 @@ +package crazypants.enderio.item; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; +import crazypants.enderio.ModObject; +import crazypants.enderio.material.Alloy; +import crazypants.enderio.material.MachinePart; + +public class ItemRecipes { + + public static void addRecipes() { + ItemStack basicGear = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.BASIC_GEAR.ordinal()); + ItemStack electricalSteel = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal()); + ItemStack wrench = new ItemStack(ModObject.itemYetaWrench.actualId, 1, 0); + + // Wrench + GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear); + } + +} diff --git a/common/crazypants/enderio/material/ItemYetaWrench.java b/common/crazypants/enderio/item/ItemYetaWrench.java similarity index 68% rename from common/crazypants/enderio/material/ItemYetaWrench.java rename to common/crazypants/enderio/item/ItemYetaWrench.java index 9f5a480c..01760173 100644 --- a/common/crazypants/enderio/material/ItemYetaWrench.java +++ b/common/crazypants/enderio/item/ItemYetaWrench.java @@ -1,4 +1,4 @@ -package crazypants.enderio.material; +package crazypants.enderio.item; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; @@ -10,14 +10,22 @@ import net.minecraftforge.common.ForgeDirection; import buildcraft.api.tools.IToolWrench; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import crazypants.enderio.Config; import crazypants.enderio.EnderIOTab; import crazypants.enderio.ModObject; +import crazypants.enderio.PacketHandler; +import crazypants.enderio.conduit.ConduitDisplayMode; public class ItemYetaWrench extends Item implements IToolWrench { public static ItemYetaWrench create() { + if(Config.useSneakMouseWheelYetaWrench) { + PacketHandler.instance.addPacketProcessor(new YetaWrenchPacketProcessor()); + TickRegistry.registerTickHandler(new YetaWrenchTickHandler(), Side.CLIENT); + } ItemYetaWrench result = new ItemYetaWrench(); result.init(); return result; @@ -33,6 +41,7 @@ public class ItemYetaWrench extends Item implements IToolWrench { protected void init() { LanguageRegistry.addName(this, ModObject.itemYetaWrench.name); GameRegistry.registerItem(this, ModObject.itemYetaWrench.unlocalisedName); + new YetaWrenchOverlayRenderer(this); } @Override @@ -52,6 +61,23 @@ public class ItemYetaWrench extends Item implements IToolWrench { return false; } + @Override + public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) { + if(!Config.useSneakRightClickYetaWrench) { + return equipped; + } + if(!player.isSneaking()) { + return equipped; + } + ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(equipped); + if(curMode == null) { + curMode = ConduitDisplayMode.ALL; + } + ConduitDisplayMode newMode = curMode.next(); + ConduitDisplayMode.setDisplayMode(equipped, newMode); + return equipped; + } + @Override public boolean canWrench(EntityPlayer player, int x, int y, int z) { return true; diff --git a/common/crazypants/enderio/item/YetaWrenchOverlayRenderer.java b/common/crazypants/enderio/item/YetaWrenchOverlayRenderer.java new file mode 100644 index 00000000..4362d1e1 --- /dev/null +++ b/common/crazypants/enderio/item/YetaWrenchOverlayRenderer.java @@ -0,0 +1,71 @@ +package crazypants.enderio.item; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.EventPriority; +import net.minecraftforge.event.ForgeSubscribe; + +import org.lwjgl.opengl.GL11; + +import crazypants.enderio.conduit.ConduitDisplayMode; +import crazypants.enderio.gui.IconEIO; + +public class YetaWrenchOverlayRenderer { + + private ItemYetaWrench wrench; + + public YetaWrenchOverlayRenderer(ItemYetaWrench wrench) { + this.wrench = wrench; + MinecraftForge.EVENT_BUS.register(this); + } + + @ForgeSubscribe(priority = EventPriority.NORMAL) + public void renderOverlay(RenderGameOverlayEvent event) { + ItemStack equippedWrench = getEquippedWrench(); + if(equippedWrench != null && event.type == ElementType.ALL) { + doRenderOverlay(event, equippedWrench); + } + } + + private ItemStack getEquippedWrench() { + ItemStack equipped = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); + if(equipped != null && equipped.itemID == wrench.itemID) { + return equipped; + } + return null; + } + + private void doRenderOverlay(RenderGameOverlayEvent event, ItemStack equippedWrench) { + ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(equippedWrench); + ScaledResolution res = event.resolution; + + double offsetX = 16; + double offsetY = res.getScaledHeight() - 16; + + if(mode == ConduitDisplayMode.ALL) { + GL11.glColor4f(1, 1, 1, 0.75f); + IconEIO.WRENCH_OVERLAY_ALL_ON.renderIcon(offsetX, offsetY - 32, 32, 32, 0, true); + return; + } + + float c = 0.6f; + GL11.glColor4f(c, c, c, 0.33f); + IconEIO.WRENCH_OVERLAY_ALL_OFF.renderIcon(offsetX, offsetY - 32, 32, 32, 0, true); + GL11.glColor4f(1, 1, 1, 0.75f); + if(mode == ConduitDisplayMode.POWER) { + IconEIO.WRENCH_OVERLAY_POWER.renderIcon(offsetX, offsetY - 32, 16, 16, 0, true); + } else if(mode == ConduitDisplayMode.FLUID) { + IconEIO.WRENCH_OVERLAY_FLUID.renderIcon(offsetX + 16, offsetY - 16, 16, 16, 0, true); + } else if(mode == ConduitDisplayMode.ITEM) { + IconEIO.WRENCH_OVERLAY_ITEM.renderIcon(offsetX, offsetY - 16, 16, 16, 0, true); + } else if(mode == ConduitDisplayMode.REDSTONE) { + IconEIO.WRENCH_OVERLAY_REDSTONE.renderIcon(offsetX + 16, offsetY - 32, 16, 16, 0, true); + } + + } + +} diff --git a/common/crazypants/enderio/item/YetaWrenchPacketProcessor.java b/common/crazypants/enderio/item/YetaWrenchPacketProcessor.java new file mode 100644 index 00000000..544eb191 --- /dev/null +++ b/common/crazypants/enderio/item/YetaWrenchPacketProcessor.java @@ -0,0 +1,67 @@ +package crazypants.enderio.item; + +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet250CustomPayload; +import cpw.mods.fml.common.network.Player; +import crazypants.enderio.IPacketProcessor; +import crazypants.enderio.PacketHandler; +import crazypants.enderio.conduit.ConduitDisplayMode; + +public class YetaWrenchPacketProcessor implements IPacketProcessor { + + public static Packet getSmeltingModePacket(int slot, ConduitDisplayMode mode) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(140); + DataOutputStream dos = new DataOutputStream(bos); + try { + dos.writeInt(PacketHandler.ID_YETA_WRENCH_MODE_PACKET); + dos.writeInt(slot); + dos.writeShort(mode.ordinal()); + } catch (IOException e) { + // never thrown + } + + Packet250CustomPayload pkt = new Packet250CustomPayload(); + pkt.channel = PacketHandler.CHANNEL; + pkt.data = bos.toByteArray(); + pkt.length = bos.size(); + pkt.isChunkDataPacket = true; + return pkt; + + } + + @Override + public boolean canProcessPacket(int packetID) { + return packetID == PacketHandler.ID_YETA_WRENCH_MODE_PACKET; + } + + @Override + public void processPacket(int packetID, INetworkManager manager, DataInputStream data, Player playerIn) throws IOException { + + int slot = -1; + if(!(playerIn instanceof EntityPlayerMP)) { + return; + } + + EntityPlayerMP player = (EntityPlayerMP) playerIn; + slot = data.readInt(); + short ordinal = data.readShort(); + + ItemStack stack = null; + if(slot > -1 && slot < 9) { + stack = player.inventory.getStackInSlot(slot); + } + if(stack == null) { + return; + } + ConduitDisplayMode.setDisplayMode(stack, ConduitDisplayMode.values()[ordinal]); + + } +} diff --git a/common/crazypants/enderio/item/YetaWrenchTickHandler.java b/common/crazypants/enderio/item/YetaWrenchTickHandler.java new file mode 100644 index 00000000..ea56f8b9 --- /dev/null +++ b/common/crazypants/enderio/item/YetaWrenchTickHandler.java @@ -0,0 +1,75 @@ +package crazypants.enderio.item; + +import java.util.EnumSet; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.item.ItemStack; + +import org.lwjgl.input.Mouse; + +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; +import crazypants.enderio.conduit.ConduitDisplayMode; + +public class YetaWrenchTickHandler implements ITickHandler { + protected int slotSelected = -1; + public static int dWheel; + + @Override + public void tickStart(EnumSet type, Object... tickData) { + + dWheel = Mouse.getDWheel() / 120; + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + if(player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemYetaWrench + && player.isSneaking()) { + slotSelected = player.inventory.currentItem; + } else { + slotSelected = -1; + } + + } + + @Override + public void tickEnd(EnumSet type, Object... tickData) { + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + if(player != null) { + if(slotSelected > -1 && dWheel != Mouse.getDWheel()) { + player.inventory.currentItem = slotSelected; + Minecraft.getMinecraft().playerController.updateController(); + + ItemStack stack = player.inventory.getStackInSlot(slotSelected); + ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(stack); + if(curMode == null) { + curMode = ConduitDisplayMode.ALL; + } + + int dif = dWheel - Mouse.getDWheel(); + ConduitDisplayMode newMode = null; + if(dif > 0) { + newMode = curMode.next(); + ConduitDisplayMode.setDisplayMode(stack, newMode); + } else if(dif < 0) { + newMode = curMode.previous(); + ConduitDisplayMode.setDisplayMode(stack, newMode); + } + if(newMode != null) { + player.sendQueue.addToSendQueue(YetaWrenchPacketProcessor.getSmeltingModePacket(slotSelected, newMode)); + } + } + slotSelected = -1; + + } + } + + @Override + public EnumSet ticks() { + return EnumSet.of(TickType.CLIENT); + } + + @Override + public String getLabel() { + return "YetaWrenchTickHandler: Client Tick"; + } + +} diff --git a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java index bf7e3dea..d64dcba0 100644 --- a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java +++ b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java @@ -538,7 +538,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor, nbtRoot.setString("channelUser", channel.user); } } - if (owner != null && !(owner.isEmpty())) { + if(owner != null && !(owner.isEmpty())) { nbtRoot.setString("owner", owner); } } diff --git a/common/crazypants/enderio/material/Alloy.java b/common/crazypants/enderio/material/Alloy.java index 319c0d66..ee4923f5 100644 --- a/common/crazypants/enderio/material/Alloy.java +++ b/common/crazypants/enderio/material/Alloy.java @@ -26,7 +26,11 @@ public enum Alloy { CONDUCTIVE_IRON("Conductive Iron", "conductiveIron", new ItemStack(Item.redstone, 2), - new ItemStack(Item.ingotIron)); + new ItemStack(Item.ingotIron)), + + PHASED_IRON("Phased Iron", "phasedIron", + new ItemStack(Item.ingotIron), + new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal())); public final String unlocalisedName; public final String uiName; diff --git a/common/crazypants/enderio/material/MaterialRecipes.java b/common/crazypants/enderio/material/MaterialRecipes.java index eaa180d5..04cfcee1 100644 --- a/common/crazypants/enderio/material/MaterialRecipes.java +++ b/common/crazypants/enderio/material/MaterialRecipes.java @@ -27,6 +27,7 @@ public class MaterialRecipes { OreDictionary.registerOre("dustGold", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_GOLD.ordinal())); OreDictionary.registerOre("dustCopper", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_COPPER.ordinal())); OreDictionary.registerOre("dustTin", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_TIN.ordinal())); + OreDictionary.registerOre("dustEnderPearl", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal())); } public static void addRecipes() { @@ -36,7 +37,6 @@ public class MaterialRecipes { ItemStack basicGear = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.BASIC_GEAR.ordinal()); ItemStack binderComposite = new ItemStack(ModObject.itemMaterial.actualId, 1, Material.BINDER_COMPOSITE.ordinal()); ItemStack industrialBinder = new ItemStack(ModObject.itemMaterial.actualId, 1, Material.CONDUIT_BINDER.ordinal()); - ItemStack wrench = new ItemStack(ModObject.itemYetaWrench.actualId, 1, 0); ItemStack enderCapacitor = new ItemStack(itemBasicCapacitor.actualId, 1, 2); ItemStack fusedQuartzFrame = new ItemStack(ModObject.itemFusedQuartzFrame.actualId, 1, 0); ItemStack machineChassi = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.MACHINE_CHASSI.ordinal()); @@ -73,16 +73,18 @@ public class MaterialRecipes { MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new FusedQuartzRecipe()); MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new VanillaSmeltingRecipe()); + //Smelting FurnaceRecipes.smelting().addSmelting(ModObject.itemPowderIngot.actualId, PowderIngot.POWDER_IRON.ordinal(), new ItemStack(Item.ingotIron), 0); FurnaceRecipes.smelting().addSmelting(ModObject.itemPowderIngot.actualId, PowderIngot.POWDER_GOLD.ordinal(), new ItemStack(Item.ingotGold), 0); + //Ender Dusts + ItemStack enderDust = new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal()); + GameRegistry.addShapedRecipe(new ItemStack(Item.enderPearl), "eee", "eee", "eee", 'e', enderDust); + // Fused Quartz Frame GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood")); GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick")); - // Wrench - GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear); - // Machine Chassi GameRegistry.addShapedRecipe(machineChassi, "fif", "i i", "fif", 'f', Block.fenceIron, 'i', Item.ingotIron); diff --git a/common/crazypants/enderio/material/PowderIngot.java b/common/crazypants/enderio/material/PowderIngot.java index cc44575d..f1202279 100644 --- a/common/crazypants/enderio/material/PowderIngot.java +++ b/common/crazypants/enderio/material/PowderIngot.java @@ -6,7 +6,8 @@ public enum PowderIngot { POWDER_IRON("powderIron", "Iron Powder", "powderIron"), POWDER_GOLD("powderGold", "Gold Powder", "powderGold"), POWDER_COPPER("powderCopper", "Copper Powder", "powderCopper"), - POWDER_TIN("powderTin", "Tin Powder", "powderTin"); + POWDER_TIN("powderTin", "Tin Powder", "powderTin"), + POWDER_ENDER("powderEnder", "Ender Pearl Powder", "powderEnder"); // POWDER_LEAD("powderLead", "Lead Powder", "powderLead"), // POWDER_SILVER("powderSilver", "Silver Powder", "powderSilver"), // POWDER_BRONZE("powderBronze", "Bronze Powder", "powderBronze"), diff --git a/common/crazypants/render/BoundingBox.java b/common/crazypants/render/BoundingBox.java index 8e0baf8e..d1440ecd 100644 --- a/common/crazypants/render/BoundingBox.java +++ b/common/crazypants/render/BoundingBox.java @@ -57,6 +57,15 @@ public final class BoundingBox { Math.max(maxX, other.maxX), Math.max(maxY, other.maxY), Math.max(maxZ, other.maxZ)); } + public boolean contains(BoundingBox other) { + return minX >= other.minX && minY <= other.minY && minZ <= other.minZ && maxX >= other.maxX && maxY <= other.maxY && maxZ <= other.maxZ; + } + + public boolean intersects(BoundingBox other) { + return other.maxX > this.minX && other.minX < this.maxX ? (other.maxY > this.minY && other.minY < this.maxY ? other.maxZ > this.minZ + && other.minZ < this.maxZ : false) : false; + } + public boolean isValid() { return minX < maxX && minY < maxY && minZ < maxZ; } @@ -83,6 +92,10 @@ public final class BoundingBox { return translate((float) translation.x, (float) translation.y, (float) translation.z); } + public BoundingBox translate(Vector3f vec) { + return translate(vec.x, vec.y, vec.z); + } + public BoundingBox transform(VertexTransform iTransformation) { Vector3d min = new Vector3d(minX, minY, minZ); Vector3d max = new Vector3d(maxX, maxY, maxZ); diff --git a/common/crazypants/vecmath/Vector3d.java b/common/crazypants/vecmath/Vector3d.java index 43a37343..422d121b 100644 --- a/common/crazypants/vecmath/Vector3d.java +++ b/common/crazypants/vecmath/Vector3d.java @@ -104,4 +104,10 @@ public class Vector3d { return "Vector3d(" + x + ", " + y + ", " + z + ")"; } + public void abs() { + x = Math.abs(x); + y = Math.abs(y); + z = Math.abs(z); + } + } diff --git a/resources/assets/enderio/config/SAGMillRecipes_Core.xml b/resources/assets/enderio/config/SAGMillRecipes_Core.xml index 2c7a4ad8..e155424c 100644 --- a/resources/assets/enderio/config/SAGMillRecipes_Core.xml +++ b/resources/assets/enderio/config/SAGMillRecipes_Core.xml @@ -176,6 +176,15 @@ + + + + + + + + + diff --git a/resources/assets/enderio/textures/blocks/ender_still.png b/resources/assets/enderio/textures/blocks/ender_still.png new file mode 100644 index 00000000..a8e67aa3 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/ender_still.png differ diff --git a/resources/assets/enderio/textures/blocks/ender_still.png.mcmeta b/resources/assets/enderio/textures/blocks/ender_still.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/resources/assets/enderio/textures/blocks/ender_still.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/resources/assets/enderio/textures/blocks/itemConduit.png b/resources/assets/enderio/textures/blocks/itemConduit.png new file mode 100644 index 00000000..1bdac435 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduit.png differ diff --git a/resources/assets/enderio/textures/blocks/itemConduitCore.png b/resources/assets/enderio/textures/blocks/itemConduitCore.png new file mode 100644 index 00000000..11c21dbf Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduitCore.png differ diff --git a/resources/assets/enderio/textures/blocks/itemConduitCoreAdvanced.png b/resources/assets/enderio/textures/blocks/itemConduitCoreAdvanced.png new file mode 100644 index 00000000..56539211 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduitCoreAdvanced.png differ diff --git a/resources/assets/enderio/textures/blocks/itemConduitInOut.png b/resources/assets/enderio/textures/blocks/itemConduitInOut.png new file mode 100644 index 00000000..6fda3e5c Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduitInOut.png differ diff --git a/resources/assets/enderio/textures/blocks/itemConduitInput.png b/resources/assets/enderio/textures/blocks/itemConduitInput.png new file mode 100644 index 00000000..b0a5f4d8 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduitInput.png differ diff --git a/resources/assets/enderio/textures/blocks/itemConduitOutput.png b/resources/assets/enderio/textures/blocks/itemConduitOutput.png new file mode 100644 index 00000000..e97ace17 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/itemConduitOutput.png differ diff --git a/resources/assets/enderio/textures/blocks/liquidConduit.png b/resources/assets/enderio/textures/blocks/liquidConduit.png index a16cb250..c1957b8a 100644 Binary files a/resources/assets/enderio/textures/blocks/liquidConduit.png and b/resources/assets/enderio/textures/blocks/liquidConduit.png differ diff --git a/resources/assets/enderio/textures/blocks/liquidConduitCore.png b/resources/assets/enderio/textures/blocks/liquidConduitCore.png index 77767f64..6a1ad198 100644 Binary files a/resources/assets/enderio/textures/blocks/liquidConduitCore.png and b/resources/assets/enderio/textures/blocks/liquidConduitCore.png differ diff --git a/resources/assets/enderio/textures/blocks/machineBack.png b/resources/assets/enderio/textures/blocks/machineBack.png new file mode 100644 index 00000000..2e68b14a Binary files /dev/null and b/resources/assets/enderio/textures/blocks/machineBack.png differ diff --git a/resources/assets/enderio/textures/blocks/machineSide.png b/resources/assets/enderio/textures/blocks/machineSide.png index 04a000f3..5b1a85df 100644 Binary files a/resources/assets/enderio/textures/blocks/machineSide.png and b/resources/assets/enderio/textures/blocks/machineSide.png differ diff --git a/resources/assets/enderio/textures/blocks/machineTop.png b/resources/assets/enderio/textures/blocks/machineTop.png new file mode 100644 index 00000000..64f39372 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/machineTop.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduit.png b/resources/assets/enderio/textures/blocks/powerConduit.png index dd7b511c..af796075 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduit.png and b/resources/assets/enderio/textures/blocks/powerConduit.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitCore.png b/resources/assets/enderio/textures/blocks/powerConduitCore.png index 59b15adf..1a34f41e 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitCore.png and b/resources/assets/enderio/textures/blocks/powerConduitCore.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitCoreEnder.png b/resources/assets/enderio/textures/blocks/powerConduitCoreEnder.png index f0e422b8..b9e9bc3a 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitCoreEnder.png and b/resources/assets/enderio/textures/blocks/powerConduitCoreEnder.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitCoreEnhanced.png b/resources/assets/enderio/textures/blocks/powerConduitCoreEnhanced.png index 3d5e8c69..4e322468 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitCoreEnhanced.png and b/resources/assets/enderio/textures/blocks/powerConduitCoreEnhanced.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitEnder.png b/resources/assets/enderio/textures/blocks/powerConduitEnder.png index 839809e9..f94de74c 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitEnder.png and b/resources/assets/enderio/textures/blocks/powerConduitEnder.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitEnhanced.png b/resources/assets/enderio/textures/blocks/powerConduitEnhanced.png index 567c562a..81335dd7 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitEnhanced.png and b/resources/assets/enderio/textures/blocks/powerConduitEnhanced.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitInput.png b/resources/assets/enderio/textures/blocks/powerConduitInput.png index 21188b78..3202f5ec 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitInput.png and b/resources/assets/enderio/textures/blocks/powerConduitInput.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitInputEnder.png b/resources/assets/enderio/textures/blocks/powerConduitInputEnder.png index 3d470e7f..3202f5ec 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitInputEnder.png and b/resources/assets/enderio/textures/blocks/powerConduitInputEnder.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitInputEnhanced.png b/resources/assets/enderio/textures/blocks/powerConduitInputEnhanced.png index fe5c9929..3202f5ec 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitInputEnhanced.png and b/resources/assets/enderio/textures/blocks/powerConduitInputEnhanced.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitOutput.png b/resources/assets/enderio/textures/blocks/powerConduitOutput.png index db32a1e5..a718dfa1 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitOutput.png and b/resources/assets/enderio/textures/blocks/powerConduitOutput.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitOutputEnder.png b/resources/assets/enderio/textures/blocks/powerConduitOutputEnder.png index 31ff454e..a718dfa1 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitOutputEnder.png and b/resources/assets/enderio/textures/blocks/powerConduitOutputEnder.png differ diff --git a/resources/assets/enderio/textures/blocks/powerConduitOutputEnhanced.png b/resources/assets/enderio/textures/blocks/powerConduitOutputEnhanced.png index e3d3ecb8..a718dfa1 100644 Binary files a/resources/assets/enderio/textures/blocks/powerConduitOutputEnhanced.png and b/resources/assets/enderio/textures/blocks/powerConduitOutputEnhanced.png differ diff --git a/resources/assets/enderio/textures/gui/widgets.png b/resources/assets/enderio/textures/gui/widgets.png index 4f5e94ed..f9f084fe 100644 Binary files a/resources/assets/enderio/textures/gui/widgets.png and b/resources/assets/enderio/textures/gui/widgets.png differ diff --git a/resources/assets/enderio/textures/items/itemItemConduit.png b/resources/assets/enderio/textures/items/itemItemConduit.png new file mode 100644 index 00000000..11c21dbf Binary files /dev/null and b/resources/assets/enderio/textures/items/itemItemConduit.png differ diff --git a/resources/assets/enderio/textures/items/itemItemConduitAdvanced.png b/resources/assets/enderio/textures/items/itemItemConduitAdvanced.png new file mode 100644 index 00000000..56539211 Binary files /dev/null and b/resources/assets/enderio/textures/items/itemItemConduitAdvanced.png differ diff --git a/resources/assets/enderio/textures/items/itemLiquidConduit.png b/resources/assets/enderio/textures/items/itemLiquidConduit.png index 77767f64..6a1ad198 100644 Binary files a/resources/assets/enderio/textures/items/itemLiquidConduit.png and b/resources/assets/enderio/textures/items/itemLiquidConduit.png differ diff --git a/resources/assets/enderio/textures/items/itemPowerConduit.png b/resources/assets/enderio/textures/items/itemPowerConduit.png index 59b15adf..1a34f41e 100644 Binary files a/resources/assets/enderio/textures/items/itemPowerConduit.png and b/resources/assets/enderio/textures/items/itemPowerConduit.png differ diff --git a/resources/assets/enderio/textures/items/itemPowerConduitEnder.png b/resources/assets/enderio/textures/items/itemPowerConduitEnder.png index f0e422b8..b9e9bc3a 100644 Binary files a/resources/assets/enderio/textures/items/itemPowerConduitEnder.png and b/resources/assets/enderio/textures/items/itemPowerConduitEnder.png differ diff --git a/resources/assets/enderio/textures/items/itemPowerConduitEnhanced.png b/resources/assets/enderio/textures/items/itemPowerConduitEnhanced.png index 3d5e8c69..4e322468 100644 Binary files a/resources/assets/enderio/textures/items/itemPowerConduitEnhanced.png and b/resources/assets/enderio/textures/items/itemPowerConduitEnhanced.png differ diff --git a/resources/assets/enderio/textures/items/powderEnder.png b/resources/assets/enderio/textures/items/powderEnder.png new file mode 100644 index 00000000..32ab39c2 Binary files /dev/null and b/resources/assets/enderio/textures/items/powderEnder.png differ