use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class ArmorHelper method imbueArmor.
public static void imbueArmor(ItemStack armorStack, String id, boolean ignoreLevelRequirement) {
IArmorImbuement imbuement = ImbuementRegistry.instance.getImbuementByID(id);
if (armorStack != null && imbuement != null && armorStack.getItem() instanceof ItemArmor) {
if (!ignoreLevelRequirement && getArmorLevel(armorStack) < getImbueCost(imbuement.getTier()))
return;
for (int i : imbuement.getValidSlots()) {
if (i == ((ItemArmor) armorStack.getItem()).armorType) {
if (!armorStack.hasTagCompound())
armorStack.setTagCompound(new NBTTagCompound());
NBTTagCompound armorProps = (NBTTagCompound) armorStack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
if (armorProps == null)
armorProps = new NBTTagCompound();
String infusionList = armorProps.getString(AMArmor.NBT_KEY_EFFECTS);
if (infusionList == null || infusionList == "")
infusionList = id;
else
infusionList += "|" + id;
armorProps.setString(AMArmor.NBT_KEY_EFFECTS, infusionList);
armorStack.stackTagCompound.setTag(AMArmor.NBT_KEY_AMPROPS, armorProps);
deductXPFromArmor(EntityUtilities.getXPFromLevel(getImbueCost(imbuement.getTier())), armorStack);
break;
}
}
}
}
use of net.minecraft.item.ItemArmor in project ArsMagica2 by Mithion.
the class ArmorHelper method addXPToArmor.
public static void addXPToArmor(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, armorProps.getDouble(AMArmor.NBT_KEY_TOTALXP) + amt);
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 ContainerArmorInfuser method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
Slot slot = (Slot) this.inventorySlots.get(index);
ItemStack stack = slot.getStack();
if (stack == null)
return null;
if (stack.getItem() instanceof ItemArmor) {
ItemArmor armor = (ItemArmor) stack.getItem();
if (index == 0) {
Slot playerSlot = (Slot) inventorySlots.get(armor.armorType + 1);
if (!playerSlot.getHasStack()) {
ItemStack clone = stack.copy();
playerSlot.putStack(clone);
slot.putStack(null);
playerSlot.onSlotChanged();
slot.onSlotChanged();
return clone;
}
} else {
Slot armorSlot = (Slot) this.inventorySlots.get(0);
if (!armorSlot.getHasStack()) {
ItemStack clone = stack.copy();
armorSlot.putStack(clone);
slot.putStack(null);
armorSlot.onSlotChanged();
slot.onSlotChanged();
return clone;
}
}
}
return null;
}
use of net.minecraft.item.ItemArmor in project Armourers-Workshop by RiskyKen.
the class RenderBlockMannequinItems method renderHeadStack.
public void renderHeadStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
Item targetItem = stack.getItem();
if (SkinNBTHelper.stackHasSkinData(stack)) {
SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, targetBiped, extraColours, distance, true);
return;
}
if (targetItem instanceof ItemBlock) {
float blockScale = 0.5F;
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleZ), 0, 0, 1);
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleY), 0, 1, 0);
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleX), 1, 0, 0);
GL11.glTranslatef(0, -4 * scale, 0);
GL11.glScalef(-blockScale, -blockScale, blockScale);
GL11.glRotatef(90F, 0F, 1F, 0F);
rm.itemRenderer.renderItem(fakePlayer, stack, stack.getItemDamage());
} else {
if (targetItem instanceof ItemArmor) {
int passes = targetItem.getRenderPasses(stack.getItemDamage());
for (int i = 0; i < passes; i++) {
ModelBiped armourBiped = ForgeHooksClient.getArmorModel(fakePlayer, stack, 0, renderPlayer.modelArmorChestplate);
if (i == 0) {
bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 0, null));
} else {
bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 0, "overlay"));
}
Color c = new Color(targetItem.getColorFromItemStack(stack, i));
GL11.glColor3f((float) c.getRed() / 255, (float) c.getGreen() / 255, (float) c.getBlue() / 255);
armourBiped.isChild = false;
if (armourBiped == renderPlayer.modelArmorChestplate) {
setRotations(targetBiped.bipedHead, armourBiped.bipedHead);
armourBiped.bipedHead.showModel = true;
armourBiped.bipedHead.render(scale);
resetRotations(targetBiped.bipedHead);
} else {
try {
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleZ), 0, 0, 1);
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleY), 0, 1, 0);
GL11.glRotated(Math.toDegrees(targetBiped.bipedHead.rotateAngleX), 1, 0, 0);
armourBiped.render(null, 0, 0, 0, 0, 0, scale);
} catch (Exception e) {
// ModLogger.log(e);
}
}
}
}
}
}
use of net.minecraft.item.ItemArmor in project Armourers-Workshop by RiskyKen.
the class RenderBlockMannequinItems method renderFeetStack.
public void renderFeetStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
Item targetItem = stack.getItem();
if (SkinNBTHelper.stackHasSkinData(stack)) {
SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, targetBiped, extraColours, distance, true);
return;
}
if (targetItem instanceof ItemArmor) {
int passes = targetItem.getRenderPasses(stack.getItemDamage());
for (int i = 0; i < passes; i++) {
ModelBiped armourBiped = ForgeHooksClient.getArmorModel(fakePlayer, stack, 3, renderPlayer.modelArmorChestplate);
if (i == 0) {
bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 3, null));
} else {
bindTexture(RenderBiped.getArmorResource(fakePlayer, stack, 3, "overlay"));
}
Color c = new Color(targetItem.getColorFromItemStack(stack, i));
GL11.glColor3f((float) c.getRed() / 255, (float) c.getGreen() / 255, (float) c.getBlue() / 255);
armourBiped.isChild = false;
if (armourBiped == renderPlayer.modelArmorChestplate) {
setRotations(targetBiped.bipedLeftLeg, armourBiped.bipedLeftLeg);
setRotations(targetBiped.bipedRightLeg, armourBiped.bipedRightLeg);
armourBiped.bipedLeftLeg.showModel = true;
armourBiped.bipedRightLeg.showModel = true;
armourBiped.bipedLeftLeg.render(scale);
armourBiped.bipedRightLeg.render(scale);
resetRotations(armourBiped.bipedLeftLeg);
resetRotations(armourBiped.bipedRightLeg);
} else {
try {
armourBiped.render(fakePlayer, 0, 0, 0, 0, 0, scale);
} catch (Exception e) {
// ModLogger.log(e);
}
}
}
}
}
Aggregations