Started incomplete work on the multimeter screen
This commit is contained in:
parent
4887997646
commit
47834c5e15
7 changed files with 75 additions and 87 deletions
14
src/main/java/resonantinduction/api/IInformation.java
Normal file
14
src/main/java/resonantinduction/api/IInformation.java
Normal file
|
@ -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<String> info);
|
||||
}
|
|
@ -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<String, Icon> loadedIconMap = new HashMap<String, Icon>();
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BatteryNetwork extends Network<BatteryNetwork, TileBattery>
|
|||
* 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Loading…
Reference in a new issue