use of net.minecraft.item.ItemArmor in project PneumaticCraft by MineMaarten.
the class TileEntityAerialInterface method canInsertItem.
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
if (i < 4)
return true;
EntityPlayer player = getPlayer();
if (player == null)
return false;
if (getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_AERIAL_INTERFACE) {
if (!dispenserUpgradeInserted || i >= 40 && i <= 43) {
return i < 40 || itemstack != null && itemstack.getItem() instanceof ItemArmor && ((ItemArmor) itemstack.getItem()).armorType == 43 - i;
} else {
if (i == 4 + player.inventory.getSizeInventory() && getFoodValue(itemstack) > 0) {
int foodValue = getFoodValue(itemstack);
int curFoodLevel = player.getFoodStats().getFoodLevel();
int feedMode = this.feedMode;
if (feedMode == 2) {
feedMode = player.getMaxHealth() - player.getHealth() > 0 ? 1 : 0;
}
switch(feedMode) {
case 0:
return 20 - curFoodLevel >= foodValue * itemstack.stackSize;
case 1:
return 20 - curFoodLevel >= foodValue * (itemstack.stackSize - 1) + 1;
}
}
return false;
}
} else {
return false;
}
}
use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class ArmorHelper method getInfusionsOnArmor.
public static IArmorImbuement[] getInfusionsOnArmor(ItemStack stack) {
if (stack == null || !stack.hasTagCompound() || !(stack.getItem() instanceof ItemArmor))
return new IArmorImbuement[0];
NBTTagCompound armorProps = (NBTTagCompound) stack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
if (armorProps != null) {
String infusionList = armorProps.getString(AMArmor.NBT_KEY_EFFECTS);
if (infusionList != null && infusionList != "") {
String[] ids = infusionList.split(AMArmor.INFUSION_DELIMITER);
IArmorImbuement[] infusions = new IArmorImbuement[ids.length];
for (int i = 0; i < ids.length; ++i) {
infusions[i] = ImbuementRegistry.instance.getImbuementByID(ids[i]);
}
return infusions;
}
}
return new IArmorImbuement[0];
}
use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class ArmorHelper method deductXPFromArmor.
public static void deductXPFromArmor(float amt, ItemStack armor) {
if (armor != null && armor.getItem() instanceof ItemArmor) {
if (!armor.hasTagCompound())
armor.setTagCompound(new NBTTagCompound());
NBTTagCompound armorProps = (NBTTagCompound) armor.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
if (armorProps == null)
armorProps = new NBTTagCompound();
armorProps.setDouble(AMArmor.NBT_KEY_TOTALXP, Math.max(armorProps.getDouble(AMArmor.NBT_KEY_TOTALXP) - amt, 0));
armorProps.setInteger(AMArmor.NBT_KEY_ARMORLEVEL, EntityUtilities.getLevelFromXP((float) armorProps.getDouble(AMArmor.NBT_KEY_TOTALXP)));
armor.stackTagCompound.setTag(AMArmor.NBT_KEY_AMPROPS, armorProps);
}
}
use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class GuiArmorImbuer method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
ItemStack stack = tileEntity.getStackInSlot(0);
int startX = l + 22;
int stepX = 52;
int startY = i1 + 23;
int stepY = 45;
int drawX = startX;
int drawY = startY;
ArrayList<String> hoverLines = new ArrayList<String>();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
GL11.glColor3f(0, 0, 0);
drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
GL11.glColor3f(1, 1, 1);
hoveredID = null;
if (stack != null) {
int armorType = -1;
if (stack.getItem() instanceof ItemArmor) {
armorType = ((ItemArmor) stack.getItem()).armorType;
}
mc.renderEngine.bindTexture(background_bw);
for (ImbuementTiers tier : ImbuementTiers.values()) {
IArmorImbuement[] infusions = ImbuementRegistry.instance.getImbuementsForTier(tier, armorType);
for (IArmorImbuement infusion : infusions) {
drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
if (i >= drawX && i <= drawX + spriteWidth) {
if (j >= drawY && j <= drawY + spriteHeight) {
hoverLines.add(StatCollector.translateToLocal("am2.tooltip." + infusion.getID()));
}
}
drawX += stepX;
}
drawY += stepY;
drawX = startX;
}
drawX = startX;
drawY = startY;
int highestSelectedTier = 0;
mc.renderEngine.bindTexture(background);
for (ImbuementTiers tier : ImbuementTiers.values()) {
IArmorImbuement[] infusions = ImbuementRegistry.instance.getImbuementsForTier(tier, armorType);
IArmorImbuement[] existingInfusions = ArmorHelper.getInfusionsOnArmor(stack);
IArmorImbuement tierInfusion = null;
for (IArmorImbuement infusion : existingInfusions) {
if (infusion == null)
continue;
if (infusion.getTier() == tier) {
tierInfusion = infusion;
if (tier.ordinal() >= highestSelectedTier)
highestSelectedTier = tier.ordinal() + 1;
break;
}
}
for (IArmorImbuement infusion : infusions) {
if ((tierInfusion == null && infusion.getTier().ordinal() <= highestSelectedTier)) {
if (tileEntity.isCreativeAllowed() || ArmorHelper.getArmorLevel(stack) >= ArmorHelper.getImbueCost(tier)) {
drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
if (i >= drawX && i <= drawX + spriteWidth) {
if (j >= drawY && j <= drawY + spriteHeight) {
hoveredID = infusion.getID();
}
}
}
} else if (tierInfusion == infusion) {
drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
}
drawX += stepX;
}
drawY += stepY;
drawX = startX;
}
}
mc.renderEngine.bindTexture(foreground);
drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
if (hoverLines.size() > 0)
AMGuiHelper.instance.drawHoveringText(hoverLines, i, j, fontRendererObj, width, height);
}
use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class AMClientEventHandler method onItemTooltip.
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
ItemStack stack = event.itemStack;
if (stack != null && stack.getItem() instanceof ItemArmor) {
double xp = 0;
int armorLevel = 0;
String[] effects = new String[0];
if (stack.hasTagCompound()) {
NBTTagCompound armorCompound = (NBTTagCompound) stack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
if (armorCompound != null) {
xp = armorCompound.getDouble(AMArmor.NBT_KEY_TOTALXP);
armorLevel = armorCompound.getInteger(AMArmor.NBT_KEY_ARMORLEVEL);
String effectsList = armorCompound.getString(AMArmor.NBT_KEY_EFFECTS);
if (effectsList != null && effectsList != "") {
effects = effectsList.split(AMArmor.INFUSION_DELIMITER);
}
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
event.toolTip.add(StatCollector.translateToLocalFormatted("am2.tooltip.armorxp", String.format("%.2f", xp)));
event.toolTip.add(String.format(StatCollector.translateToLocal("am2.tooltip.armorlevel"), armorLevel));
for (String s : effects) {
event.toolTip.add(StatCollector.translateToLocal("am2.tooltip." + s));
}
} else {
event.toolTip.add(StatCollector.translateToLocal("am2.tooltip.shiftForDetails"));
}
} else if (stack.getItem() instanceof ItemBlock) {
if (((ItemBlock) stack.getItem()).field_150939_a == BlocksCommonProxy.manaBattery) {
if (stack.hasTagCompound()) {
float batteryCharge = stack.stackTagCompound.getFloat("mana_battery_charge");
PowerTypes powerType = PowerTypes.getByID(stack.stackTagCompound.getInteger("mana_battery_powertype"));
if (batteryCharge != 0) {
// TODO localize this tooltip
event.toolTip.add(String.format("\u00A7r\u00A79Contains \u00A75%.2f %s%s \u00A79etherium", batteryCharge, powerType.chatColor(), powerType.name()));
}
}
}
}
}
Aggregations