From 47834c5e15a0c95eb5c2cbe0968f20eb86bc8adb Mon Sep 17 00:00:00 2001 From: Calclavia Date: Wed, 29 Jan 2014 12:54:20 +0800 Subject: [PATCH] Started incomplete work on the multimeter screen --- .../resonantinduction/api/IInformation.java | 14 +++ .../core/ResonantInduction.java | 33 +++++++ .../core/render/RenderItemOverlayTile.java | 83 +----------------- .../electrical/battery/BatteryNetwork.java | 2 +- .../electrical/multimeter/PartMultimeter.java | 8 +- .../multimeter/RenderMultimeter.java | 22 ++++- .../textures/blocks/multimeter_screen.png | Bin 0 -> 2839 bytes 7 files changed, 75 insertions(+), 87 deletions(-) create mode 100644 src/main/java/resonantinduction/api/IInformation.java create mode 100644 src/main/resources/assets/resonantinduction/textures/blocks/multimeter_screen.png diff --git a/src/main/java/resonantinduction/api/IInformation.java b/src/main/java/resonantinduction/api/IInformation.java new file mode 100644 index 000000000..f1c8789e2 --- /dev/null +++ b/src/main/java/resonantinduction/api/IInformation.java @@ -0,0 +1,14 @@ +package resonantinduction.api; + +import java.util.List; + +/** + * Provides extra information for the display units (multimeter) to display. + * + * @author Calclavia + * + */ +public interface IInformation +{ + public void getInformation(List info); +} diff --git a/src/main/java/resonantinduction/core/ResonantInduction.java b/src/main/java/resonantinduction/core/ResonantInduction.java index 7ffef62cf..8f7693b0a 100644 --- a/src/main/java/resonantinduction/core/ResonantInduction.java +++ b/src/main/java/resonantinduction/core/ResonantInduction.java @@ -1,11 +1,15 @@ package resonantinduction.core; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.logging.Logger; import net.minecraft.block.Block; +import net.minecraft.util.Icon; +import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -39,6 +43,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * The core module of Resonant Induction @@ -95,6 +101,7 @@ public class ResonantInduction Settings.load(); // Register Forge Events + MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE); MinecraftForge.EVENT_BUS.register(new FluidEventHandler()); @@ -136,4 +143,30 @@ public class ResonantInduction ResourceGenerator.generateOreResources(); } + public static final HashMap loadedIconMap = new HashMap(); + + public void registerIcon(String name, TextureStitchEvent.Pre event) + { + loadedIconMap.put(name, event.map.registerIcon(name)); + } + + @ForgeSubscribe + @SideOnly(Side.CLIENT) + public void preTextureHook(TextureStitchEvent.Pre event) + { + if (event.map.textureType == 0) + { + registerIcon(Reference.PREFIX + "mixture_flow", event); + registerIcon(Reference.PREFIX + "molten_flow", event); + registerIcon(Reference.PREFIX + "multimeter_screen", event); + } + } + + @ForgeSubscribe + @SideOnly(Side.CLIENT) + public void postTextureHook(TextureStitchEvent.Post event) + { + for (Fluid fluid : fluidMaterial) + fluid.setIcons(loadedIconMap.get(Reference.PREFIX + "molten_flow")); + } } diff --git a/src/main/java/resonantinduction/core/render/RenderItemOverlayTile.java b/src/main/java/resonantinduction/core/render/RenderItemOverlayTile.java index b8166163d..2b0bf8905 100644 --- a/src/main/java/resonantinduction/core/render/RenderItemOverlayTile.java +++ b/src/main/java/resonantinduction/core/render/RenderItemOverlayTile.java @@ -1,7 +1,6 @@ package resonantinduction.core.render; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.entity.RenderItem; @@ -22,6 +21,7 @@ import org.lwjgl.opengl.GL11; import universalelectricity.api.vector.Vector3; import calclavia.lib.render.RenderUtility; import calclavia.lib.utility.WorldUtility; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -155,8 +155,8 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer GL11.glPopMatrix(); } - this.renderText(renderText, side, 0.02f, x, y - 0.35f, z); - this.renderText(amount, side, 0.02f, x, y - 0.15f, z); + RenderUtility.renderText(renderText, side, 0.02f, x, y - 0.35f, z); + RenderUtility.renderText(amount, side, 0.02f, x, y - 0.15f, z); } } @@ -176,83 +176,6 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale); } - private void renderText(String text, int side, float maxScale, double x, double y, double z) - { - GL11.glPushMatrix(); - - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - - float displayWidth = 1 - (2 / 16); - float displayHeight = 1 - (2 / 16); - GL11.glTranslated(x, y, z); - - switch (side) - { - case 3: - GL11.glTranslatef(0, 1, 0); - GL11.glRotatef(0, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 2: - GL11.glTranslatef(1, 1, 1); - GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 5: - GL11.glTranslatef(0, 1, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 4: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(-90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - } - - // Find Center - GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); - - FontRenderer fontRenderer = this.getFontRenderer(); - - int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - float scaler = 0.8f; - float scaleX = (displayWidth / requiredWidth); - float scaleY = (displayHeight / requiredHeight); - float scale = scaleX * scaler; - - if (maxScale > 0) - { - scale = Math.min(scale, maxScale); - } - - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); - - int offsetX; - int offsetY; - int realHeight = (int) Math.floor(displayHeight / scale); - int realWidth = (int) Math.floor(displayWidth / scale); - - offsetX = (realWidth - requiredWidth) / 2; - offsetY = (realHeight - requiredHeight) / 2; - - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); - - GL11.glPopMatrix(); - } - private void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle) { if (itemStack != null) diff --git a/src/main/java/resonantinduction/electrical/battery/BatteryNetwork.java b/src/main/java/resonantinduction/electrical/battery/BatteryNetwork.java index 0ce9de730..e0203e7af 100644 --- a/src/main/java/resonantinduction/electrical/battery/BatteryNetwork.java +++ b/src/main/java/resonantinduction/electrical/battery/BatteryNetwork.java @@ -21,7 +21,7 @@ public class BatteryNetwork extends Network * Apply energy loss. */ double percentageLoss = Math.max(0, (1 - ((double) (getConnectors().size() * 6) / 100d))); - long energyLoss = (long) (percentageLoss * 10); + long energyLoss = (long) (percentageLoss * 100); totalEnergy -= energyLoss; int amountOfNodes = this.getConnectors().size() - exclusion.length; diff --git a/src/main/java/resonantinduction/electrical/multimeter/PartMultimeter.java b/src/main/java/resonantinduction/electrical/multimeter/PartMultimeter.java index eb3d49a15..9977bd79b 100644 --- a/src/main/java/resonantinduction/electrical/multimeter/PartMultimeter.java +++ b/src/main/java/resonantinduction/electrical/multimeter/PartMultimeter.java @@ -48,7 +48,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @author Calclavia * */ -public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFacePart, JNormalOcclusion, IRedstonePart +public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcclusion, IPacketReceiver { public static Cuboid6[][] bounds = new Cuboid6[6][2]; @@ -377,19 +377,19 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac } } - @Override +// @Override public boolean canConnectRedstone(int arg0) { return true; } - @Override + //@Override public int strongPowerLevel(int arg0) { return redstoneOn ? 14 : 0; } - @Override + //@Override public int weakPowerLevel(int arg0) { return redstoneOn ? 14 : 0; diff --git a/src/main/java/resonantinduction/electrical/multimeter/RenderMultimeter.java b/src/main/java/resonantinduction/electrical/multimeter/RenderMultimeter.java index 2a33314e1..dc978dc24 100644 --- a/src/main/java/resonantinduction/electrical/multimeter/RenderMultimeter.java +++ b/src/main/java/resonantinduction/electrical/multimeter/RenderMultimeter.java @@ -7,6 +7,7 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.opengl.GL11; +import calclavia.lib.render.RenderUtility; import resonantinduction.core.Reference; import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay.Unit; @@ -26,8 +27,25 @@ public class RenderMultimeter public static final ModelMultimeter MODEL = new ModelMultimeter(); public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "multimeter.png"); - @SuppressWarnings("incomplete-switch") - public static void render(PartMultimeter tileEntity, double x, double y, double z) + public static void render(PartMultimeter part, double x, double y, double z) + { + GL11.glPushMatrix(); + RenderUtility.rotateFaceBlockToSide(part.getDirection()); + + /** + * The more space we have, the more information we render. + * + * 1x1: Show storage + * 1x2: Show storage + capacity + * 3x3: Show graph behind + */ + + + GL11.glPopMatrix(); + + } + + public static void renderOld(PartMultimeter tileEntity, double x, double y, double z) { ForgeDirection direction = tileEntity.getDirection(); diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/multimeter_screen.png b/src/main/resources/assets/resonantinduction/textures/blocks/multimeter_screen.png new file mode 100644 index 0000000000000000000000000000000000000000..d3a665e7ad9feaed5730affd36ac7bbafb7dde68 GIT binary patch literal 2839 zcmV+y3+VKTP)pPPiaF#P*7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