-
-
Save izzyaxel/1bf5db34c24dc879455b53e0ad198e43 to your computer and use it in GitHub Desktop.
Y U Do Dis Thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AAExtendedPlayer implements IExtendedEntityProperties | |
{ | |
public static final String EEPName = "Arcane Artificing"; | |
EntityPlayer player; | |
~ | |
private double ulayAlpha; | |
private double olayAlpha; | |
private int focusTime; | |
private static String ULAYALPHANAME = "UnderlayAlpha"; | |
private static String OLAYALPHANAME = "OverlayAlpha"; | |
private static String FOCUSTIMENAME = "FocusTime"; | |
~ | |
public static AAExtendedPlayer getIEEP(EntityPlayer player) | |
{ | |
return (AAExtendedPlayer)player.getExtendedProperties(EEPName); | |
} | |
@Override | |
public void init(Entity entity, World world) | |
{ | |
~ | |
this.ulayAlpha = AAReference.ULAYDEFOCUS; | |
this.olayAlpha = AAReference.OLAYDEFOCUS; | |
this.focusTime = 0; | |
} | |
@Override | |
public void saveNBTData(NBTTagCompound compound) | |
{ | |
NBTTagCompound properties = new NBTTagCompound(); | |
compound.setTag(EEPName, properties); | |
~ | |
properties.setDouble(ULAYALPHANAME, this.ulayAlpha); | |
properties.setDouble(OLAYALPHANAME, this.olayAlpha); | |
properties.setInteger(FOCUSTIMENAME, this.focusTime); | |
} | |
@Override | |
public void loadNBTData(NBTTagCompound compound) | |
{ | |
NBTTagCompound properties = (NBTTagCompound)compound.getTag(EEPName); | |
~ | |
this.ulayAlpha = properties.getDouble(ULAYALPHANAME); | |
this.olayAlpha = properties.getDouble(OLAYALPHANAME); | |
this.focusTime = properties.getInteger(FOCUSTIMENAME); | |
} | |
public void copyIEEP(AAExtendedPlayer epOrig) | |
{ | |
~ | |
this.ulayAlpha = AAReference.ULAYDEFOCUS; | |
this.olayAlpha = AAReference.OLAYDEFOCUS; | |
this.focusTime = 0; | |
} | |
/**Mana************************************************************************************************************/ | |
~ | |
//Focus the HUD | |
public void focusHUD() | |
{ | |
this.ulayAlpha = 1; | |
this.olayAlpha = 1; | |
this.focusTime = AAReference.HUDFOCUSTIME; | |
} | |
//Defocus the HUD | |
public void defocusHUD() | |
{ | |
this.ulayAlpha = AAReference.ULAYDEFOCUS; | |
this.olayAlpha = AAReference.OLAYDEFOCUS; | |
} | |
//Get current alpha value for underlay | |
public double getUnderlayAlpha() | |
{ | |
return this.ulayAlpha; | |
} | |
//Get current alpha value for overlay | |
public double getOverlayAlpha() | |
{ | |
return this.olayAlpha; | |
} | |
public int getFocusTime() | |
{ | |
return this.focusTime; | |
} | |
//Decrease the amount of time left before the HUD goes transparent, and fade out | |
public void decrementFocusTime() | |
{ | |
this.focusTime--; | |
if(this.focusTime < 0) | |
{ | |
this.focusTime = 0; | |
this.defocusHUD(); | |
} | |
if(this.focusTime <= AAReference.HUDFADETIME) | |
{ | |
this.ulayAlpha = ((this.focusTime / AAReference.HUDFADETIME) * 1d) + ((1d - (this.focusTime / AAReference.HUDFADETIME)) * AAReference.ULAYDEFOCUS); | |
this.olayAlpha = ((this.focusTime / AAReference.HUDFADETIME) * 1d) + ((1d - (this.focusTime / AAReference.HUDFADETIME)) * AAReference.OLAYDEFOCUS); | |
} | |
} | |
~ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ManaHUD extends Gui | |
{ | |
final ResourceLocation manaHUD = new ResourceLocation(AAReference.MODID, "textures/gui/hud/manaHUD.png"); | |
final ResourceLocation manaHUDUnderlay = new ResourceLocation(AAReference.MODID, "textures/gui/hud/manaHUDUnderlays.png"); | |
final Minecraft mc = Minecraft.getMinecraft(); | |
final Tessellator tess = Tessellator.instance; | |
final float adj = 0.00390625F; | |
private final static ManaHUD INSTANCE = new ManaHUD(); | |
public static ManaHUD getManaHUD() | |
{ | |
return INSTANCE; | |
} | |
@SubscribeEvent() | |
public void onRender(RenderGameOverlayEvent.Post event) | |
{ | |
if(!event.isCancelable() && event.type == RenderGameOverlayEvent.ElementType.ALL && ArcaneArtificing.proxy.getClientPlayer() != null) | |
{ | |
AAExtendedPlayer props = AAExtendedPlayer.getIEEP(ArcaneArtificing.proxy.getClientPlayer()); | |
if(props != null && props.hasLearnedAboutmana()) | |
{ | |
System.out.print("OL: " + props.getOverlayAlpha() + " UL: " + props.getUnderlayAlpha() + "\r"); | |
double scale = 0.6; | |
switch(mc.gameSettings.guiScale) | |
{ | |
case 0: | |
scale = 0.5; | |
break; | |
case 1: | |
scale = 1.6; | |
break; | |
case 2: | |
scale = 0.9; | |
break; | |
case 3: | |
scale = 0.8; | |
break; | |
default: | |
break; | |
} | |
int xOffset = 4, yOffset = 4, border = 4, iconWidth = 32; | |
//Underlays | |
GL11.glPushMatrix(); | |
GL11.glDisable(GL11.GL_LIGHTING); | |
GL11.glEnable(GL11.GL_BLEND); | |
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | |
GL11.glScaled(scale, scale, scale); | |
GL11.glColor4d(1.0, 1.0, 1.0, props.getUnderlayAlpha()); | |
this.mc.renderEngine.bindTexture(this.manaHUDUnderlay); | |
//System.out.print("W: " + props.getWhiteMana() + "/" + props.getMaxManaW() + " U: " + props.getBlueMana() + "/" + props.getMaxManaU() + " B: " + props.getBlackMana()+ "/" + props.getMaxManaB() + " G: " + props.getGreenMana()+ "/" + props.getMaxManaG() + " R: " + props.getRedMana()+ "/" + props.getMaxManaR() + "\r"); | |
//White | |
AAVector2 lerpWVertsUL = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset, yOffset), new AAVector2(xOffset, yOffset + iconWidth), ((float)props.getWhiteMana() / props.getMaxManaW())); | |
AAVector2 lerpWVertsUR = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset + iconWidth, yOffset), new AAVector2(xOffset + iconWidth, yOffset + iconWidth), ((float)props.getWhiteMana() / props.getMaxManaW())); | |
AAVector2 lerpWUVsUL = AAVector2.lerpVertsAndUVs(new AAVector2(0, 0), new AAVector2(0, 32 * this.adj), ((float)props.getWhiteMana() / props.getMaxManaW())); | |
AAVector2 lerpWUVsUR = AAVector2.lerpVertsAndUVs(new AAVector2(32 * this.adj, 0), new AAVector2(32 * this.adj, 32 * this.adj), ((float)props.getWhiteMana() / props.getMaxManaW())); | |
//Blue | |
AAVector2 lerpUVertsUL = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset, yOffset + iconWidth + border), new AAVector2(xOffset, yOffset + (iconWidth * 2) + border), ((float)props.getBlueMana() / props.getMaxManaU())); | |
AAVector2 lerpUVertsUR = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset + iconWidth, yOffset + iconWidth + border), new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 2) + border), ((float)props.getBlueMana() / props.getMaxManaU())); | |
AAVector2 lerpUUVsUL = AAVector2.lerpVertsAndUVs(new AAVector2(32 * this.adj, 0), new AAVector2(32 * this.adj, 32 * this.adj), ((float)props.getBlueMana() / props.getMaxManaU())); | |
AAVector2 lerpUUVsUR = AAVector2.lerpVertsAndUVs(new AAVector2(64 * this.adj, 0), new AAVector2(64 * this.adj, 32 * this.adj), ((float)props.getBlueMana() / props.getMaxManaU())); | |
//Black | |
AAVector2 lerpBVertsUL = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset, yOffset + (iconWidth * 2) + (border * 2)), new AAVector2(xOffset, yOffset + (iconWidth * 3) + (border * 2)), ((float)props.getBlackMana() / props.getMaxManaB())); | |
AAVector2 lerpBVertsUR = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 2) + (border * 2)), new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 3) + (border * 2)), ((float)props.getBlackMana() / props.getMaxManaB())); | |
AAVector2 lerpBUVsUL = AAVector2.lerpVertsAndUVs(new AAVector2(64 * this.adj, 0), new AAVector2(64 * this.adj, 32 * this.adj), ((float)props.getBlackMana() / props.getMaxManaB())); | |
AAVector2 lerpBUVsUR = AAVector2.lerpVertsAndUVs(new AAVector2(96 * this.adj, 0), new AAVector2(96 * this.adj, 32 * this.adj), ((float)props.getBlackMana() / props.getMaxManaB())); | |
//Green | |
AAVector2 lerpGVertsUL = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset, yOffset + (iconWidth * 3) + (border * 3)), new AAVector2(xOffset, yOffset + (iconWidth * 4) + (border * 3)), ((float)props.getGreenMana() / props.getMaxManaG())); | |
AAVector2 lerpGVertsUR = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 3) + (border * 3)), new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 4) + (border * 3)), ((float)props.getGreenMana() / props.getMaxManaG())); | |
AAVector2 lerpGUVsUL = AAVector2.lerpVertsAndUVs(new AAVector2(96 * this.adj, 0), new AAVector2(96 * this.adj, 32 * this.adj), ((float)props.getGreenMana() / props.getMaxManaG())); | |
AAVector2 lerpGUVsUR = AAVector2.lerpVertsAndUVs(new AAVector2(128 * this.adj, 0), new AAVector2(128 * this.adj, 32 * this.adj), ((float)props.getGreenMana() / props.getMaxManaG())); | |
//Red | |
AAVector2 lerpRVertsUL = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset, yOffset + (iconWidth * 4) + (border * 4)), new AAVector2(xOffset, yOffset + (iconWidth * 5) + (border * 4)), ((float)props.getRedMana() / props.getMaxManaR())); | |
AAVector2 lerpRVertsUR = AAVector2.lerpVertsAndUVs(new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 4) + (border * 4)), new AAVector2(xOffset + iconWidth, yOffset + (iconWidth * 5) + (border * 4)), ((float)props.getRedMana() / props.getMaxManaR())); | |
AAVector2 lerpRUVsUL = AAVector2.lerpVertsAndUVs(new AAVector2(128 * this.adj, 0), new AAVector2(128 * this.adj, 32 * this.adj), ((float)props.getRedMana() / props.getMaxManaR())); | |
AAVector2 lerpRUVsUR = AAVector2.lerpVertsAndUVs(new AAVector2(160 * this.adj, 0), new AAVector2(160 * this.adj, 32 * this.adj), ((float)props.getRedMana() / props.getMaxManaR())); | |
//White | |
this.tess.startDrawingQuads(); | |
this.tess.addVertexWithUV(xOffset, yOffset + iconWidth, this.zLevel, 0 * this.adj, 32 * this.adj); | |
this.tess.addVertexWithUV(xOffset + iconWidth, yOffset + iconWidth, this.zLevel, 32 * this.adj, 32 * this.adj); | |
this.tess.addVertexWithUV(lerpWVertsUR.x, lerpWVertsUR.y, this.zLevel, lerpWUVsUR.x, lerpWUVsUR.y); | |
this.tess.addVertexWithUV(lerpWVertsUL.x, lerpWVertsUL.y, this.zLevel, lerpWUVsUL.x, lerpWUVsUL.y); | |
this.tess.draw(); | |
//Blue | |
this.tess.startDrawingQuads(); | |
this.tess.addVertexWithUV(xOffset, yOffset + border + (iconWidth * 2), this.zLevel, 32 * adj, 32 * adj); | |
this.tess.addVertexWithUV(xOffset + iconWidth, yOffset + border + (iconWidth * 2), this.zLevel, 64 * adj, 32 * adj); | |
this.tess.addVertexWithUV(lerpUVertsUR.x, lerpUVertsUR.y, this.zLevel, lerpUUVsUR.x, lerpUUVsUR.y); | |
this.tess.addVertexWithUV(lerpUVertsUL.x, lerpUVertsUL.y, this.zLevel, lerpUUVsUL.x, lerpUUVsUL.y); | |
this.tess.draw(); | |
//Black | |
this.tess.startDrawingQuads(); | |
this.tess.addVertexWithUV(xOffset, yOffset + (border * 2) + (iconWidth * 3), this.zLevel, 64 * adj, 32 * adj); | |
this.tess.addVertexWithUV(xOffset + iconWidth, yOffset + (border * 2) + (iconWidth * 3), this.zLevel, 96 * adj, 32 * adj); | |
this.tess.addVertexWithUV(lerpBVertsUR.x, lerpBVertsUR.y, this.zLevel, lerpBUVsUR.x, lerpBUVsUR.y); | |
this.tess.addVertexWithUV(lerpBVertsUL.x, lerpBVertsUL.y, this.zLevel, lerpBUVsUL.x, lerpBUVsUL.y); | |
this.tess.draw(); | |
//Green | |
this.tess.startDrawingQuads(); | |
this.tess.addVertexWithUV(xOffset, yOffset + (border * 3) + (iconWidth * 4), this.zLevel, 96 * adj, 32 * adj); | |
this.tess.addVertexWithUV(xOffset + iconWidth, yOffset + (border * 3) + (iconWidth * 4), this.zLevel, 128 * adj, 32 * adj); | |
this.tess.addVertexWithUV(lerpGVertsUR.x, lerpGVertsUR.y, this.zLevel, lerpGUVsUR.x, lerpGUVsUR.y); | |
this.tess.addVertexWithUV(lerpGVertsUL.x, lerpGVertsUL.y, this.zLevel, lerpGUVsUL.x, lerpGUVsUL.y); | |
this.tess.draw(); | |
//Red | |
this.tess.startDrawingQuads(); | |
this.tess.addVertexWithUV(xOffset, yOffset + (border * 4) + (iconWidth * 5), this.zLevel, 128 * adj, 32 * adj); | |
this.tess.addVertexWithUV(xOffset + iconWidth, yOffset + (border * 4) + (iconWidth * 5), this.zLevel, 160 * adj, 32 * adj); | |
this.tess.addVertexWithUV(lerpRVertsUR.x, lerpRVertsUR.y, this.zLevel, lerpRUVsUR.x, lerpRUVsUR.y); | |
this.tess.addVertexWithUV(lerpRVertsUL.x, lerpRVertsUL.y, this.zLevel, lerpRUVsUL.x, lerpRUVsUL.y); | |
this.tess.draw(); | |
GL11.glPopMatrix(); | |
//Icons | |
GL11.glPushMatrix(); | |
GL11.glDisable(GL11.GL_LIGHTING); | |
GL11.glEnable(GL11.GL_BLEND); | |
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | |
GL11.glScaled(scale, scale, scale); | |
GL11.glColor4d(1.0, 1.0, 1.0, props.getOverlayAlpha()); | |
this.mc.renderEngine.bindTexture(this.manaHUD); | |
//White | |
this.drawTexturedModalRect(xOffset, yOffset, 0, 0, iconWidth, iconWidth); | |
//Blue | |
this.drawTexturedModalRect(xOffset, yOffset + iconWidth + border, 32, 0, iconWidth, iconWidth); | |
//Black | |
this.drawTexturedModalRect(xOffset, yOffset + (iconWidth * 2) + (border * 2), 64, 0, iconWidth, iconWidth); | |
//Green | |
this.drawTexturedModalRect(xOffset, yOffset + (iconWidth * 3) + (border * 3), 96, 0, iconWidth, iconWidth); | |
//Red | |
this.drawTexturedModalRect(xOffset, yOffset + (iconWidth * 4) + (border * 4), 128, 0, iconWidth, iconWidth); | |
GL11.glPopMatrix(); | |
if(props.getFocusTime() >= 0) | |
{ | |
props.decrementFocusTime(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment