use of net.minecraft.item.ItemArmor in project SpongeCommon by SpongePowered.
the class ArmorTypePropertyStore method getFor.
@Override
protected Optional<ArmorTypeProperty> getFor(ItemStack itemStack) {
if (itemStack.getItem() instanceof ItemArmor) {
final ItemArmor armor = (ItemArmor) itemStack.getItem();
final ItemArmor.ArmorMaterial armorMaterial = armor.getArmorMaterial();
return Optional.of(new ArmorTypeProperty((ArmorType) (Object) armorMaterial));
}
return Optional.empty();
}
use of net.minecraft.item.ItemArmor in project SilentGems by SilentChaos512.
the class EquipmentTooltips method renderForArmor.
private void renderForArmor(RenderTooltipEvent.PostText event, ItemStack stack) {
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fontRenderer = event.getFontRenderer();
ItemArmor itemArmor = (ItemArmor) stack.getItem();
ItemStack currentEquip = StackHelper.empty();
for (ItemStack itemstack : mc.player.getEquipmentAndArmor()) {
Item item = itemstack.getItem();
if (item instanceof ItemArmor && ((ItemArmor) item).armorType == itemArmor.armorType) {
currentEquip = itemstack;
}
}
double scale = 0.75;
int x = (int) (event.getX() / scale);
int y = (int) ((event.getY() - 16) / scale);
int durability = getDurability(stack, 0);
int equippedDurability = getDurability(currentEquip, durability);
float protection = getProtection(stack, 0);
float equippedProtection = getProtection(currentEquip, protection);
float toughness = getToughness(stack, 0);
float equippedToughness = getToughness(currentEquip, toughness);
GlStateManager.pushMatrix();
GlStateManager.color(1f, 1f, 1f, 1f);
GlStateManager.scale(scale, scale, scale);
mc.renderEngine.bindTexture(TEXTURE);
// Durability
x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
// Protection
x = renderStat(mc, fontRenderer, 6, x, y, protection, equippedProtection, StackHelper.isValid(currentEquip));
// Toughness
if (toughness > 0 || equippedToughness > 0)
x = renderStat(mc, fontRenderer, 7, x, y, toughness, equippedToughness, StackHelper.isValid(currentEquip));
lastWidth = (int) (x * scale - event.getX());
GlStateManager.popMatrix();
}
use of net.minecraft.item.ItemArmor in project SpongeForge by SpongePowered.
the class StaticMixinForgeHelper method getProperties.
private static ISpecialArmor.ArmorProperties getProperties(EntityLivingBase base, ItemStack armorStack, DamageSource damageSource, double damage, int index) {
if (armorStack.isEmpty()) {
return null;
}
ISpecialArmor.ArmorProperties prop = null;
if (armorStack.getItem() instanceof ISpecialArmor) {
ISpecialArmor armor = (ISpecialArmor) armorStack.getItem();
prop = armor.getProperties(base, armorStack, damageSource, damage / 25D, index).copy();
} else if (armorStack.getItem() instanceof ItemArmor && !damageSource.isUnblockable()) {
ItemArmor armor = (ItemArmor) armorStack.getItem();
prop = new ISpecialArmor.ArmorProperties(0, armor.damageReduceAmount / 25D, Integer.MAX_VALUE);
}
if (prop != null) {
prop.Slot = index;
return prop;
}
return null;
}
use of net.minecraft.item.ItemArmor in project Cavern2 by kegare.
the class RandomiteHelper method refreshItems.
public static void refreshItems() {
DROP_ITEMS.clear();
Set<String> oreNames = Sets.newTreeSet();
String[] targetNames = { "treeSapling", "sugarcane", "vine", "slimeball", "enderpearl", "bone", "gunpowder", "string", "torch" };
String[] targetPrefixes = { "gem", "ingot", "nugget", "dust", "crop" };
for (String name : targetNames) {
if (OreDictionary.doesOreNameExist(name)) {
oreNames.add(name);
}
}
for (String name : OreDictionary.getOreNames()) {
for (String prefix : targetPrefixes) {
if (name.startsWith(prefix) && Character.isUpperCase(name.charAt(prefix.length()))) {
oreNames.add(name);
}
}
}
for (String name : oreNames) {
for (ItemStack stack : OreDictionary.getOres(name, false)) {
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
NonNullList<ItemStack> list = NonNullList.create();
stack.getItem().getSubItems(CreativeTabs.SEARCH, list);
for (ItemStack subStack : list) {
addItem(subStack, 50);
}
} else {
addItem(stack, 50);
}
}
}
for (Item item : Item.REGISTRY) {
if (item == null || item == Items.AIR || item instanceof ItemBlock) {
continue;
}
if (item instanceof ItemFood) {
NonNullList<ItemStack> list = NonNullList.create();
item.getSubItems(CreativeTabs.SEARCH, list);
for (ItemStack stack : list) {
addItem(stack, 15);
}
} else if (item instanceof ItemTool || item instanceof ItemArmor || item instanceof ItemSword || item instanceof ItemBow) {
addItem(new ItemStack(item), 5);
}
}
addItem(ItemCave.EnumType.MINER_ORB.getItemStack(), 1);
}
use of net.minecraft.item.ItemArmor in project BloodMagic by WayofTime.
the class RenderEntityMimic method doRender.
@Override
public void doRender(EntityMimic mimic, double x, double y, double z, float entityYaw, float partialTicks) {
super.doRender(mimic, x, y, z, entityYaw, partialTicks);
GlStateManager.pushMatrix();
if (mimic.getMimicItemStack() != null) {
GlStateManager.pushMatrix();
if (this.renderOutlines) {
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(mimic));
}
GlStateManager.translate(x, y, z);
ItemStack itemstack = mimic.getMimicItemStack();
Item item = itemstack.getItem();
Minecraft minecraft = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (item == Items.SKULL) {
float f2 = 1.1875F;
GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);
GameProfile gameprofile = null;
if (itemstack.hasTagCompound()) {
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10)) {
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
} else if (nbttagcompound.hasKey("SkullOwner", 8)) {
String s = nbttagcompound.getString("SkullOwner");
if (!StringUtils.isNullOrEmpty(s)) {
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile(null, s));
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, 0);
} else if (!(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) {
GlStateManager.translate(0, 0.5f, 0);
GlStateManager.rotate(-(mimic.prevRotationYawHead + partialTicks * (mimic.rotationYawHead - mimic.prevRotationYawHead)) - 180, 0, 1, 0);
minecraft.getItemRenderer().renderItem(mimic, itemstack, ItemCameraTransforms.TransformType.HEAD);
}
GlStateManager.popMatrix();
if (this.renderOutlines) {
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
}
GlStateManager.popMatrix();
super.doRender(mimic, x, y, z, entityYaw, partialTicks);
}
GlStateManager.popMatrix();
if (!this.renderOutlines) {
this.renderLeash(mimic, x, y, z, entityYaw, partialTicks);
}
}
Aggregations