use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.
the class AMIngameGUI method renderGameOverlay.
public void renderGameOverlay() {
ItemStack ci = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
boolean drawAMHud = !AMCore.config.showHudMinimally() || (ci != null && (ci.getItem() == ItemsCommonProxy.spellBook || ci.getItem() == ItemsCommonProxy.spell || ci.getItem() == ItemsCommonProxy.arcaneSpellbook || ci.getItem() instanceof IBoundItem));
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight();
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_TEXTURE_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (drawAMHud)
RenderBuffs(i, j);
mc.renderEngine.bindTexture(items);
if (drawAMHud)
RenderContingency(i, j);
if (drawAMHud)
RenderArsMagicaGUIItems(i, j, mc.fontRenderer);
if (drawAMHud)
RenderAffinity(i, j);
RenderArmorStatus(i, j, mc, mc.fontRenderer);
if (drawAMHud)
RenderMagicXP(i, j);
ItemStack item = mc.thePlayer.getCurrentEquippedItem();
if (item != null && item.getItem() instanceof ItemSpellBook) {
RenderSpellBookUI(i, j, mc.fontRenderer, mc.thePlayer.getCurrentEquippedItem());
}
GL11.glPopAttrib();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glColor4f(1, 1, 1, 1);
}
use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderManaBar.
private void RenderManaBar(int i, int j, FontRenderer fontRenderer) {
int barWidth = i / 8;
AMVector2 fatigue_hud = getShiftedVector(AMCore.config.getBurnoutHudPosition(), i, j);
AMVector2 mana_hud = getShiftedVector(AMCore.config.getManaHudPosition(), i, j);
float green = 0.5f;
float blue = 1.0f;
float red = 0.126f;
ExtendedProperties props = ExtendedProperties.For(mc.thePlayer);
// mana bar
float mana = props.getCurrentMana();
float bonusMana = props.getBonusCurrentMana();
float maxMana = props.getMaxMana();
float fatigueBarWidth = barWidth;
float fatigue = props.getCurrentFatigue();
float maxFatigue = props.getMaxFatigue();
if (mana + bonusMana > maxMana)
mana = maxMana;
float progressScaled = (mana / (maxMana + 0.01f));
if (AMCore.config.showHudBars()) {
// handle flashing of mana bar
float flashTimer = AMGuiHelper.instance.getFlashTimer(MANA_BAR_FLASH_SLOT);
if (flashTimer > 0) {
green = 0.0f;
float redShift = 1.0f - red;
float halfFlash = AMGuiHelper.instance.flashDuration / 2;
if (flashTimer > halfFlash) {
float pct = (flashTimer - halfFlash) / halfFlash;
red += redShift - (redShift * pct);
} else {
float pct = flashTimer / halfFlash;
red += (redShift * pct);
}
GL11.glColor3f(red, green, blue);
} else {
if (bonusMana > 0)
GL11.glColor3f(0.2f, 0.9f, 0.6f);
}
ItemStack curItem = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
if (curItem != null && (curItem.getItem() == ItemsCommonProxy.spell || curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook)) {
ItemStack spellStack = curItem.getItem() == ItemsCommonProxy.spell ? curItem : ((ItemSpellBook) curItem.getItem()).GetActiveItemStack(curItem);
if (spellStack != null) {
int[] parts = SpellUtils.instance.getShapeGroupParts(spellStack);
int sx = mana_hud.iX - 2 * parts.length / 2;
int sy = mana_hud.iY - 2 * parts.length / 2;
for (int p : parts) {
IIcon icon = SpellIconManager.instance.getIcon(SkillManager.instance.getSkillName(SkillManager.instance.getSkill(p)));
if (icon != null) {
DrawIconAtXY(icon, "items", sx, sy, false);
sx += 3;
sy += 3;
}
}
}
}
DrawPartialIconAtXY(AMGuiIcons.manaLevel, progressScaled, 1, mana_hud.iX + 16, mana_hud.iY + 1f, (int) (barWidth * 0.97f), 40, false);
DrawIconAtXY(AMGuiIcons.manaBar, "items", mana_hud.iX + 15, mana_hud.iY + 3, barWidth, 50, false);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
progressScaled = (fatigue / (maxFatigue + 0.01f));
DrawIconAtXY(AMGuiIcons.fatigueIcon, "items", fatigue_hud.iX + barWidth, fatigue_hud.iY, false);
DrawPartialIconAtXY(AMGuiIcons.fatigueLevel, progressScaled, 1, fatigue_hud.iX, fatigue_hud.iY + 3f, fatigueBarWidth, 40, false);
DrawIconAtXY(AMGuiIcons.fatigueBar, "items", fatigue_hud.iX, fatigue_hud.iY + 4, barWidth, 48, false);
green = 0.5f;
blue = 1.0f;
red = 0.126f;
// magic level
int manaBarColor = Math.round(red * 255);
manaBarColor = (manaBarColor << 8) + Math.round(green * 255);
manaBarColor = (manaBarColor << 8) + Math.round(blue * 255);
String magicLevel = (new StringBuilder()).append("").append(ExtendedProperties.For(mc.thePlayer).getMagicLevel()).toString();
AMVector2 magicLevelPos = getShiftedVector(AMCore.config.getLevelPosition(), i, j);
magicLevelPos.iX -= Minecraft.getMinecraft().fontRenderer.getStringWidth(magicLevel) / 2;
fontRenderer.drawStringWithShadow(magicLevel, magicLevelPos.iX, magicLevelPos.iY, manaBarColor);
if (flashTimer > 0) {
GL11.glColor3f(1.0f, 1.0f, 1.0f);
}
}
if (AMCore.config.getShowNumerics()) {
String manaStr = StatCollector.translateToLocal("am2.gui.mana") + ": " + (int) (mana + bonusMana) + "/" + (int) maxMana;
String burnoutStr = StatCollector.translateToLocal("am2.gui.burnout") + ": " + (int) props.getCurrentFatigue() + "/" + (int) props.getMaxFatigue();
AMVector2 manaNumericPos = getShiftedVector(AMCore.config.getManaNumericPosition(), i, j);
AMVector2 burnoutNumericPos = getShiftedVector(AMCore.config.getBurnoutNumericPosition(), i, j);
fontRenderer.drawString(manaStr, manaNumericPos.iX, manaNumericPos.iY, bonusMana > 0 ? 0xeae31c : 0x2080FF);
fontRenderer.drawString(burnoutStr, burnoutNumericPos.iX + 25 - fontRenderer.getStringWidth(burnoutStr), burnoutNumericPos.iY, 0xFF2020);
}
}
use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.
the class ClientProxy method setMouseDWheel.
@Override
public boolean setMouseDWheel(int dwheel) {
if (dwheel == 0)
return false;
ItemStack stack = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
if (stack == null)
return false;
boolean store = checkForTKMove(stack);
if (!store && stack.getItem() instanceof ItemSpellBook) {
store = Minecraft.getMinecraft().thePlayer.isSneaking();
}
if (store) {
clientTickHandler.setDWheel(dwheel / 120, Minecraft.getMinecraft().thePlayer.inventory.currentItem, Minecraft.getMinecraft().thePlayer.isUsingItem());
return true;
} else {
clientTickHandler.setDWheel(0, -1, false);
}
return false;
}
use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.
the class ClientGuiManager method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te == null && ID != ArsMagicaGuiIdList.GUI_SPELL_BOOK && ID != ArsMagicaGuiIdList.GUI_KEYSTONE && ID != ArsMagicaGuiIdList.GUI_ESSENCE_BAG && ID != ArsMagicaGuiIdList.GUI_RUNE_BAG && ID != ArsMagicaGuiIdList.GUI_RIFT && ID != ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION) {
return null;
}
switch(ID) {
case ArsMagicaGuiIdList.GUI_ESSENCE_REFINER:
if (!(te instanceof TileEntityEssenceRefiner)) {
return null;
}
return new GuiEssenceRefiner(player.inventory, (TileEntityEssenceRefiner) te);
case ArsMagicaGuiIdList.GUI_SPELL_BOOK:
ItemStack bookStack = player.getCurrentEquippedItem();
if (bookStack == null || bookStack.getItem() == null || !(bookStack.getItem() instanceof ItemSpellBook)) {
return null;
}
ItemSpellBook item = (ItemSpellBook) bookStack.getItem();
return new GuiSpellBook(player.inventory, player.getCurrentEquippedItem(), item.ConvertToInventory(bookStack));
case ArsMagicaGuiIdList.GUI_CALEFACTOR:
if (!(te instanceof TileEntityCalefactor)) {
return null;
}
return new GuiCalefactor(player, (TileEntityCalefactor) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_LOCKABLE:
if (!(te instanceof IKeystoneLockable)) {
return null;
}
return new GuiKeystoneLockable(player.inventory, (IKeystoneLockable) te);
case ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER:
if (!(te instanceof TileEntityAstralBarrier)) {
return null;
}
return new GuiAstralBarrier(player.inventory, (TileEntityAstralBarrier) te);
case ArsMagicaGuiIdList.GUI_SEER_STONE:
if (!(te instanceof TileEntitySeerStone)) {
return null;
}
return new GuiSeerStone(player.inventory, (TileEntitySeerStone) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_CHEST:
if (!(te instanceof TileEntityKeystoneChest)) {
return null;
}
return new GuiKeystoneChest(player.inventory, (TileEntityKeystoneChest) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE:
ItemStack keystoneStack = player.getCurrentEquippedItem();
if (keystoneStack == null || keystoneStack.getItem() == null || !(keystoneStack.getItem() instanceof ItemKeystone)) {
return null;
}
ItemKeystone keystone = (ItemKeystone) keystoneStack.getItem();
int runeBagSlot = InventoryUtilities.getInventorySlotIndexFor(player.inventory, ItemsCommonProxy.runeBag);
ItemStack runeBag = null;
if (runeBagSlot > -1)
runeBag = player.inventory.getStackInSlot(runeBagSlot);
return new GuiKeystone(player.inventory, player.getCurrentEquippedItem(), runeBag, keystone.ConvertToInventory(keystoneStack), runeBag == null ? null : ItemsCommonProxy.runeBag.ConvertToInventory(runeBag), runeBagSlot);
case ArsMagicaGuiIdList.GUI_ESSENCE_BAG:
ItemStack bagStack = player.getCurrentEquippedItem();
if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemEssenceBag)) {
return null;
}
ItemEssenceBag bag = (ItemEssenceBag) bagStack.getItem();
return new GuiEssenceBag(player.inventory, player.getCurrentEquippedItem(), bag.ConvertToInventory(bagStack));
case ArsMagicaGuiIdList.GUI_RUNE_BAG:
bagStack = player.getCurrentEquippedItem();
if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemRuneBag)) {
return null;
}
ItemRuneBag runebag = (ItemRuneBag) bagStack.getItem();
return new GuiRuneBag(player.inventory, player.getCurrentEquippedItem(), runebag.ConvertToInventory(bagStack));
case ArsMagicaGuiIdList.GUI_ARCANE_RECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneReconstructor)) {
return null;
}
return new GuiArcaneReconstructor(player.inventory, (TileEntityArcaneReconstructor) te);
case ArsMagicaGuiIdList.GUI_SUMMONER:
if (!(te instanceof TileEntitySummoner)) {
return null;
}
return new GuiSummoner(player.inventory, (TileEntitySummoner) te);
case ArsMagicaGuiIdList.GUI_INSCRIPTION_TABLE:
if (!(te instanceof TileEntityInscriptionTable)) {
return null;
}
return new GuiInscriptionTable(player.inventory, (TileEntityInscriptionTable) te);
case ArsMagicaGuiIdList.GUI_MAGICIANS_WORKBENCH:
if (!(te instanceof TileEntityMagiciansWorkbench)) {
return null;
}
return new GuiMagiciansWorkbench(player.inventory, (TileEntityMagiciansWorkbench) te);
case ArsMagicaGuiIdList.GUI_RIFT:
return new GuiRiftStorage(player.inventory, RiftStorage.For(player));
case ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION:
return new GuiSpellCustomization(player);
case ArsMagicaGuiIdList.GUI_CRYSTAL_MARKER:
if (!(te instanceof TileEntityCrystalMarker)) {
return null;
}
return new GuiCrystalMarker(player, (TileEntityCrystalMarker) te);
case ArsMagicaGuiIdList.GUI_OBELISK:
if (!(te instanceof TileEntityObelisk)) {
return null;
}
return new GuiObelisk((TileEntityObelisk) te, player);
case ArsMagicaGuiIdList.GUI_FLICKER_HABITAT:
if (!(te instanceof TileEntityFlickerHabitat)) {
return null;
}
return new GuiFlickerHabitat(player, (TileEntityFlickerHabitat) te);
case ArsMagicaGuiIdList.GUI_ARMOR_INFUSION:
if (!(te instanceof TileEntityArmorImbuer)) {
return null;
}
return new GuiArmorImbuer(player, (TileEntityArmorImbuer) te);
case ArsMagicaGuiIdList.GUI_ARCANE_DECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneDeconstructor)) {
return null;
}
return new GuiArcaneDeconstructor(player.inventory, (TileEntityArcaneDeconstructor) te);
case ArsMagicaGuiIdList.GUI_INERT_SPAWNER:
if (!(te instanceof TileEntityInertSpawner)) {
return null;
}
return new GuiInertSpawner(player, (TileEntityInertSpawner) te);
case ArsMagicaGuiIdList.GUI_SPELL_SEALED_DOOR:
if (!(te instanceof TileEntitySpellSealedDoor)) {
return null;
}
return new GuiSpellSealedDoor(player.inventory, (TileEntitySpellSealedDoor) te);
}
return null;
}
use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.
the class ClientTickHandler method checkMouseDWheel.
private void checkMouseDWheel() {
if (this.mouseWheelValue != 0 && this.currentSlot > -1) {
Minecraft.getMinecraft().thePlayer.inventory.currentItem = this.currentSlot;
ItemStack stack = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
if (checkForTKMove(stack)) {
ExtendedProperties props = ExtendedProperties.For(Minecraft.getMinecraft().thePlayer);
if (this.mouseWheelValue > 0 && props.TK_Distance < 10) {
props.TK_Distance += 0.5f;
} else if (this.mouseWheelValue < 0 && props.TK_Distance > 0.3) {
props.TK_Distance -= 0.5f;
}
LogHelper.debug("TK Distance: %.2f", props.TK_Distance);
props.syncTKDistance();
} else if (stack.getItem() instanceof ItemSpellBook && Minecraft.getMinecraft().thePlayer.isSneaking()) {
ItemSpellBook isb = (ItemSpellBook) stack.getItem();
if (this.mouseWheelValue != 0) {
byte subID = 0;
if (this.mouseWheelValue < 0) {
isb.SetNextSlot(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem());
subID = ItemSpellBook.ID_NEXT_SPELL;
} else {
isb.SetPrevSlot(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem());
subID = ItemSpellBook.ID_PREV_SPELL;
}
// send packet to server
AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SPELLBOOK_CHANGE_ACTIVE_SLOT, new AMDataWriter().add(subID).add(Minecraft.getMinecraft().thePlayer.getEntityId()).add(Minecraft.getMinecraft().thePlayer.inventory.currentItem).generate());
}
}
this.currentSlot = -1;
this.mouseWheelValue = 0;
}
}
Aggregations