Skip to content

Commit

Permalink
Working on setting a fixed size for all components
Browse files Browse the repository at this point in the history
  • Loading branch information
frodare committed Feb 9, 2017
1 parent c8a4921 commit 888c7ee
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
23 changes: 22 additions & 1 deletion java/net/torocraft/torohealthmod/display/EntityDisplay.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package net.torocraft.torohealthmod.display;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.torocraft.torohealthmod.ToroHealthMod;

public class EntityDisplay implements ToroHealthDisplay {

private static final ResourceLocation TEXTURE = new ResourceLocation(ToroHealthMod.MODID, "textures/gui/entityStatus.png");
private static final int RENDER_HEIGHT = 20;
private static final int WIDTH = 40;
private static final int HEIGHT = 40;

private final Minecraft mc;
private final Gui gui;

private int x = 50;
private int y = 50;
Expand All @@ -26,6 +34,11 @@ public class EntityDisplay implements ToroHealthDisplay {
private float prevPrevYahHead;
private int scale = 1;

public EntityDisplay(Minecraft mc, Gui gui) {
this.mc = mc;
this.gui = gui;
}

@Override
public void setPosition(int x, int y) {
this.x = x;
Expand All @@ -46,6 +59,9 @@ public void draw() {
glDraw();
popEntityRotations();
popEntityLeasedTo();

mc.renderEngine.bindTexture(TEXTURE);
Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, WIDTH, HEIGHT, 200.0f, 200.0f);
} catch (Throwable ignore) {

}
Expand All @@ -56,6 +72,9 @@ private void updateScale() {
}

private void glDraw() {



GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();

Expand All @@ -74,6 +93,8 @@ private void glDraw() {
rendermanager.setRenderShadow(false);
rendermanager.doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
rendermanager.setRenderShadow(true);



GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
Expand Down
8 changes: 7 additions & 1 deletion java/net/torocraft/torohealthmod/display/HeartsDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class HeartsDisplay implements ToroHealthDisplay {

private static final ResourceLocation TEXTURE = new ResourceLocation(ToroHealthMod.MODID, "textures/gui/entityStatus.png");
private static final int WIDTH = 84;
private static final int WIDTH = 100;
private static final int HEIGHT = 34;

private final Minecraft mc;
Expand Down Expand Up @@ -40,9 +40,15 @@ public void draw() {


resetToOrigin();



mc.renderEngine.bindTexture(TEXTURE);
Gui.drawModalRectWithCustomSizedTexture(x, y , 0.0f, 0.0f, WIDTH, HEIGHT, 200.0f, 200.0f);

x += 2;
y += 2;

drawName();
drawHearts();
drawArmor();
Expand Down
4 changes: 2 additions & 2 deletions java/net/torocraft/torohealthmod/display/NumericDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class NumericDisplay implements ToroHealthDisplay {

private final Minecraft mc;
private final Gui gui;
private int x = 100;
private int y = 140;
private int x = 220;
private int y = 100;
private EntityLivingBase entity;

public NumericDisplay(Minecraft mc, Gui gui) {
Expand Down
7 changes: 6 additions & 1 deletion java/net/torocraft/torohealthmod/gui/GuiEntityStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public GuiEntityStatus() {

public GuiEntityStatus(Minecraft mc) {
this.mc = mc;
entityDisplay = new EntityDisplay();
entityDisplay = new EntityDisplay(mc, this);
heartsDisplay = new HeartsDisplay(mc, this);
numericDisplay = new NumericDisplay(mc, this);

entityDisplay.setPosition(50, 50);

heartsDisplay.setPosition(100, 150);
numericDisplay.setPosition(210, 150);
}

@SubscribeEvent
Expand Down

0 comments on commit 888c7ee

Please sign in to comment.