use of am2.api.math.AMVector2 in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderSpellBookUI.
private void RenderSpellBookUI(int i, int j, FontRenderer fontrenderer, ItemStack bookStack) {
mc.renderEngine.bindTexture(spellbook_ui);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
AMVector2 spellbookVec = getShiftedVector(AMCore.config.getSpellBookPosition(), i, j);
int spellUI_x = spellbookVec.iX;
int spellUI_y = spellbookVec.iY;
int spellUI_width = 148;
int spellUI_height = 22;
float activeSpellSize = 15f;
int bookActiveSlot = ((ItemSpellBook) bookStack.getItem()).GetActiveSlot(bookStack);
float x = spellUI_x + bookActiveSlot * 12.9f;
float y = spellUI_y;
this.zLevel = -5;
drawTexturedModalRect_Classic(spellUI_x, spellUI_y, 0, 0, 106, 15, spellUI_width, spellUI_height);
ItemStack[] activeScrolls = ((ItemSpellBook) bookStack.getItem()).getActiveScrollInventory(bookStack);
mc.renderEngine.bindTexture(items);
this.zLevel = 0;
for (int n = 0; n < 8; ++n) {
float IIconX = spellUI_x + 1.5f + n * 12.9f;
ItemStack stackItem = activeScrolls[n];
if (stackItem == null) {
continue;
}
int d = 12;
DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 0), "items", IIconX, spellUI_y + 1.5f, d, d, false);
DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 1), "items", IIconX, spellUI_y + 1.5f, d, d, false);
}
mc.renderEngine.bindTexture(spellbook_ui);
this.zLevel = 1000;
drawTexturedModalRect_Classic(x, y, 148, 0, activeSpellSize, activeSpellSize, 20, 20);
this.zLevel = 0;
mc.renderEngine.bindTexture(mc_gui);
}
use of am2.api.math.AMVector2 in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderArmorStatus.
private void RenderArmorStatus(int i, int j, Minecraft mc, FontRenderer fontRenderer) {
if (!AMCore.config.showArmorUI())
return;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
for (int slot = 0; slot < 4; ++slot) {
if (ArmorHelper.PlayerHasArmorInSlot(mc.thePlayer, 3 - slot)) {
AMVector2 position = getArmorSlotPosition(slot, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());
int blackoutTimer = AMGuiHelper.instance.getBlackoutTimer(3 - slot);
int blackoutMaxTimer = AMGuiHelper.instance.getBlackoutTimerMax(3 - slot);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
ItemStack armor = mc.thePlayer.inventory.armorInventory[3 - slot];
float lineweight = 4f;
// durability
if (armor.isItemDamaged() && armor.getMaxDamage() > 0) {
float pct = 1 - (float) armor.getItemDamage() / (float) armor.getMaxDamage();
AMGuiHelper.line2d(position.iX, position.iY + 10, position.iX + 10, position.iY + 10, this.zLevel + 100, lineweight, 0);
int color = (int) (255.0f * (1 - pct)) << 16 | (int) (255.0f * pct) << 8;
AMGuiHelper.line2d(position.iX, position.iY + 10, position.iX + (10 * pct), position.iY + 10, this.zLevel + 101, lineweight, color);
}
// cooldown
if (blackoutMaxTimer > 0) {
float pct = (float) (blackoutMaxTimer - blackoutTimer) / (float) blackoutMaxTimer;
AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + 10, position.iY + 11, this.zLevel + 100, lineweight, 0);
AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + (10 * pct), position.iY + 11, this.zLevel + 101, lineweight, 0xFF0000);
} else {
AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + 10, position.iY + 11, this.zLevel + 101, lineweight, 0x0000FF);
}
IIcon icon = mc.thePlayer.inventory.armorInventory[3 - slot].getIconIndex();
if (icon != null) {
AMGuiHelper.DrawIconAtXY(icon, position.iX, position.iY, this.zLevel, 10, 10, true);
} else {
AMGuiHelper.DrawItemAtXY(mc.thePlayer.inventory.armorInventory[3 - slot], position.iX, position.iY, this.zLevel, 0.63f);
}
}
}
GL11.glColor3f(1.0f, 1.0f, 1.0f);
}
use of am2.api.math.AMVector2 in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderContingency.
public void RenderContingency(int i, int j) {
AMVector2 contingencyPos = getShiftedVector(AMCore.config.getContingencyPosition(), i, j);
IIcon icon = null;
ContingencyTypes type = ExtendedProperties.For(Minecraft.getMinecraft().thePlayer).getContingencyType();
switch(type) {
case DAMAGE_TAKEN:
icon = SpellIconManager.instance.getIcon("Contingency_Damage");
break;
case FALL:
icon = SpellIconManager.instance.getIcon("Contingency_Fall");
break;
case HEALTH_LOW:
icon = SpellIconManager.instance.getIcon("Contingency_Health");
break;
case ON_FIRE:
icon = SpellIconManager.instance.getIcon("Contingency_Fire");
break;
case DEATH:
icon = SpellIconManager.instance.getIcon("Contingency_Death");
break;
case NONE:
default:
return;
}
DrawIconAtXY(icon, "items", contingencyPos.iX, contingencyPos.iY, 16, 16, true);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
}
use of am2.api.math.AMVector2 in project ArsMagica2 by Mithion.
the class ShrinkHandler method onEntityLiving.
@SubscribeEvent
public void onEntityLiving(LivingEvent event) {
if (!(event.entityLiving instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink")))
return;
ExtendedProperties exProps = null;
try {
exProps = ExtendedProperties.For(player);
} catch (Throwable t) {
return;
}
if (exProps.originalSize == null) {
exProps.originalSize = new AMVector2(player.width, player.height);
}
boolean shrunk = exProps.getIsShrunk();
if (!player.worldObj.isRemote && shrunk && !player.isPotionActive(BuffList.shrink)) {
exProps.setIsShrunk(false);
shrunk = false;
player.yOffset = (float) exProps.getOriginalSize().y * 0.9f;
} else if (!player.worldObj.isRemote && !shrunk && player.isPotionActive(BuffList.shrink)) {
exProps.setIsShrunk(true);
shrunk = true;
player.yOffset = 0.0F;
}
float shrinkPct = exProps.getShrinkPct();
if (shrunk && shrinkPct < 1f) {
shrinkPct = Math.min(1f, shrinkPct + 0.005f);
} else if (!shrunk && shrinkPct > 0f) {
shrinkPct = Math.max(0f, shrinkPct - 0.005f);
}
exProps.setShrinkPct(shrinkPct);
if (exProps.getShrinkPct() > 0f) {
if (// shrink hasn't yet been applied
exProps.shrinkAmount == 0f || // width has changed through other means
exProps.getOriginalSize().x * 0.5 != player.width || exProps.getOriginalSize().y * 0.5 != player.height) {
// height has changed through other means
exProps.setOriginalSize(new AMVector2(player.width, player.height));
exProps.shrinkAmount = 0.5f;
EntityUtilities.setSize(player, player.width * exProps.shrinkAmount, player.height * exProps.shrinkAmount);
player.eyeHeight = player.getDefaultEyeHeight() * exProps.shrinkAmount;
player.yOffset = 0.0f;
}
} else {
if (exProps.shrinkAmount != 0f) {
AMVector2 size = ExtendedProperties.For(player).getOriginalSize();
EntityUtilities.setSize(player, (float) (size.x), (float) (size.y));
exProps.shrinkAmount = 0f;
player.eyeHeight = player.getDefaultEyeHeight();
player.yOffset = 0.0f;
if (exProps.getIsFlipped()) {
event.entityLiving.moveEntity(0, -1, 0);
}
}
}
// update Y offset
if (player.worldObj.isRemote && exProps.getPrevShrinkPct() != exProps.getShrinkPct()) {
// Vanilla player is 1.8f height with 1.62f yOffset => 0.9f
player.yOffset = (float) exProps.getOriginalSize().y * 0.9f * (1f - 0.5f * exProps.getShrinkPct());
}
}
Aggregations