use of net.minecraft.inventory.EntityEquipmentSlot in project pnc-repressurized by TeamPneumatic.
the class SlotPneumaticArmor method isItemValid.
/**
* Check if the stack is a valid item for this slot. Always true beside for
* the armor slots.
*/
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
Item item = par1ItemStack.getItem();
// 0 & 1 are main & off hands
EntityEquipmentSlot eq = EntityEquipmentSlot.values()[armorType + 2];
return item.isValidArmor(par1ItemStack, eq, player);
}
use of net.minecraft.inventory.EntityEquipmentSlot in project Almura by AlmuraDev.
the class UIUserPanel method updateArmor.
private void updateArmor() {
int maxArmor = 0;
int currentDamage = 0;
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) {
continue;
}
final ItemStack stack = this.client.player.getItemStackFromSlot(slot);
if (stack.getItem() instanceof ItemArmor) {
maxArmor += ((ItemArmor) stack.getItem()).getArmorMaterial().getDurability(slot);
currentDamage += stack.getItem().getDamage(stack);
}
}
this.updateBarProperties(this.armorBar, maxArmor - currentDamage, maxArmor);
}
use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.
the class ToolHelper method addExampleRecipe.
public static void addExampleRecipe(Item item, EnumMaterialTier[] tiers, String[] lines, Object... extraParams) {
// New ingredient-based recipes
ConfigOptionToolClass config = item instanceof ITool ? ((ITool) item).getConfig() : null;
for (EnumMaterialTier tier : tiers) {
// Only add recipes for valid tiers
if (config != null && !config.validTiers.contains(tier))
continue;
// Head parts for tier
List<ItemStack> heads = new ArrayList<>();
for (ToolPart part : ToolPartRegistry.getMains()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getTier() == tier && StackHelper.isValid(part.getCraftingStack()))
heads.add(part.getCraftingStack());
IngredientSL headIngredient = IngredientSL.from(heads.toArray(new ItemStack[0]));
// Rods for tier
List<ItemStack> rods = new ArrayList<>();
for (ToolPart part : ToolPartRegistry.getRods()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getCompatibleTiers().contains(tier))
rods.add(part.getCraftingStack());
IngredientSL rodIngredient = IngredientSL.from(rods.toArray(new ItemStack[0]));
// Armor frames
List<ItemStack> frames = new ArrayList<>();
if (item instanceof ItemGemArmor) {
EntityEquipmentSlot slot = ((ItemGemArmor) item).armorType;
for (ToolPart part : ToolPartRegistry.getValues()) if (part instanceof ArmorPartFrame && ((ArmorPartFrame) part).getSlot() == slot && part.getTier() == tier && !part.isBlacklisted(part.getCraftingStack()))
frames.add(part.getCraftingStack());
}
IngredientSL frameIngredient = IngredientSL.from(frames.toArray(new ItemStack[0]));
ResourceLocation recipeName = new ResourceLocation(item.getRegistryName().toString() + "_" + tier.name().toLowerCase() + "_example");
ItemStack result = new ItemStack(item);
NBTTagCompound tags = new NBTTagCompound();
tags.setInteger(NBT_EXAMPLE_TOOL_TIER, tier.ordinal());
result.setTagCompound(tags);
// Super ugly, but I've got never better at the moment.
List<Object> params = new ArrayList<>();
for (String line : lines) params.add(line);
if (recipeContainsKey(lines, "h")) {
params.add('h');
params.add(headIngredient);
}
if (recipeContainsKey(lines, "r")) {
params.add('r');
params.add(rodIngredient);
}
if (recipeContainsKey(lines, "a")) {
params.add('a');
params.add(frameIngredient);
}
for (Object obj : extraParams) params.add(obj);
EXAMPLE_RECIPES.add(SilentGems.registry.recipes.makeShaped(recipeName.getResourcePath(), result, params.toArray()));
}
}
use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.
the class EquipmentTooltips method getToughness.
private float getToughness(ItemStack stack, float defaultValue) {
if (StackHelper.isEmpty(stack))
return defaultValue;
ItemArmor itemArmor = (ItemArmor) stack.getItem();
EntityEquipmentSlot slot = itemArmor.armorType;
UUID uuid = ItemArmor.ARMOR_MODIFIERS[slot.getIndex()];
Multimap<String, AttributeModifier> multimap = stack.getAttributeModifiers(slot);
for (Entry<String, AttributeModifier> entry : multimap.entries()) {
String key = entry.getKey();
AttributeModifier mod = entry.getValue();
if (key.equals(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()) && mod.getID().equals(uuid)) {
return (float) mod.getAmount();
}
}
return 0f;
}
use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.
the class EquipmentTooltips method getProtection.
private float getProtection(ItemStack stack, float defaultValue) {
if (StackHelper.isEmpty(stack))
return defaultValue;
ItemArmor itemArmor = (ItemArmor) stack.getItem();
EntityEquipmentSlot slot = itemArmor.armorType;
UUID uuid = ItemArmor.ARMOR_MODIFIERS[slot.getIndex()];
Multimap<String, AttributeModifier> multimap = stack.getAttributeModifiers(slot);
for (Entry<String, AttributeModifier> entry : multimap.entries()) {
String key = entry.getKey();
AttributeModifier mod = entry.getValue();
if (key.equals(SharedMonsterAttributes.ARMOR.getName()) && mod.getID().equals(uuid)) {
return (float) mod.getAmount();
}
}
return 0f;
}
Aggregations