Search in sources :

Example 11 with ArmorItem

use of net.minecraft.item.ArmorItem in project FrostedHeart by TeamMoegMC.

the class ClientRegistryEvents method onModelBake.

@SubscribeEvent
public static void onModelBake(ModelBakeEvent event) {
    for (ResourceLocation location : event.getModelRegistry().keySet()) {
        // Now find all armors
        ResourceLocation item = new ResourceLocation(location.getNamespace(), location.getPath());
        if (ForgeRegistries.ITEMS.getValue(item) instanceof ArmorItem) {
            ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(item, "inventory");
            IBakedModel model = event.getModelRegistry().get(itemModelResourceLocation);
            if (model == null) {
                FHLogger.warn("Did not find the expected vanilla baked model for " + item + " in registry");
            } else if (model instanceof LiningModel) {
                FHLogger.warn("Tried to replace " + item + " twice");
            } else {
                // Replace the model with our IBakedModel
                LiningModel customModel = new LiningModel(model);
                event.getModelRegistry().put(itemModelResourceLocation, customModel);
            }
        }
    }
}
Also used : LiningModel(com.teammoeg.frostedheart.client.model.LiningModel) ArmorItem(net.minecraft.item.ArmorItem) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 12 with ArmorItem

use of net.minecraft.item.ArmorItem in project FrostedHeart by TeamMoegMC.

the class LiningItemOverrideList method getOverrideModel.

@Override
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
    String s = ItemNBTHelper.getString(stack, "inner_cover");
    EquipmentSlotType slotType = ((ArmorItem) stack.getItem()).getEquipmentSlot();
    if (s.length() > 0 && slotType != null) {
        String liningType = new ResourceLocation(s).getPath();
        String slotName = "feet";
        if (slotType.getName().equals("feet")) {
            slotName = "feet";
        } else if (slotType.getName().equals("legs")) {
            slotName = "legs";
        } else if (slotType.getName().equals("chest")) {
            slotName = "torso";
        } else if (slotType.getName().equals("head")) {
            slotName = "helmet";
        }
        ResourceLocation textureLocation = FHMain.rl("item/lining_overlay/" + liningType + "_" + slotName);
        return new LiningFinalizedModel(originalModel, textureLocation);
    }
    return originalModel;
}
Also used : ArmorItem(net.minecraft.item.ArmorItem) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 13 with ArmorItem

use of net.minecraft.item.ArmorItem in project Vampirism by TeamLapen.

the class MinionInventory method damageArmor.

public void damageArmor(DamageSource source, float damage, MinionEntity<?> entity) {
    if (damage > 0) {
        damage = damage / 6.0F;
        if (damage < 1.0F && damage >= 0.5f) {
            damage = 1.0F;
        }
        if (damage >= 1) {
            for (int i = 0; i < this.inventoryArmor.size(); ++i) {
                ItemStack itemstack = this.inventoryArmor.get(i);
                if ((!source.isFire() || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
                    final int i_final = i;
                    itemstack.hurtAndBreak((int) damage, entity, (e) -> {
                        e.broadcastBreakEvent(EquipmentSlotType.byTypeAndIndex(EquipmentSlotType.Group.ARMOR, i_final));
                    });
                }
            }
        }
    }
}
Also used : ArmorItem(net.minecraft.item.ArmorItem) ItemStack(net.minecraft.item.ItemStack)

Example 14 with ArmorItem

use of net.minecraft.item.ArmorItem in project NinjaGear by InfinityRaider.

the class AnvilHandler method onAnvilUse.

@SubscribeEvent
@SuppressWarnings("unused")
public void onAnvilUse(AnvilUpdateEvent event) {
    // Fetch input stacks
    ItemStack left = event.getLeft();
    ItemStack right = event.getRight();
    // Verify imbuing conditions
    if (left == null || right == null || left.isEmpty() || right.isEmpty()) {
        // Do nothing if either slot is empty
        return;
    }
    if (!(left.getItem() instanceof ArmorItem)) {
        // Do nothing if the left slot does not contain an armor piece
        return;
    }
    if (!(right.getItem() instanceof ArmorItem)) {
        // Do nothing if the right slot does not contain an armor piece
        return;
    }
    if ((left.getItem() instanceof ItemNinjaArmor) && (right.getItem() instanceof ItemNinjaArmor)) {
        // Do nothing if both slots contain ninja armor
        return;
    }
    if (!(left.getItem() instanceof ItemNinjaArmor) && !(right.getItem() instanceof ItemNinjaArmor)) {
        // Do nothing if neither slot contains ninja armor
        return;
    }
    if (((ArmorItem) left.getItem()).getEquipmentSlot() != ((ArmorItem) right.getItem()).getEquipmentSlot()) {
        // Do nothing if the slots contain armor pieces for different body parts
        return;
    }
    // Fetch the input ItemStack
    ItemStack input = (left.getItem() instanceof ItemNinjaArmor) ? right : left;
    // Check if the input stack is imbued already
    if (CapabilityNinjaArmor.isNinjaArmor(input)) {
        // Do nothing if the input stack is already imbued
        return;
    }
    // Copy the input ItemStack
    ItemStack output = input.copy();
    // Activate the ninja armor status on the capability
    output.getCapability(CapabilityNinjaArmor.CAPABILITY).ifPresent(cap -> cap.setNinjaArmor(true));
    // Set the name
    String inputName = event.getName();
    if (inputName == null || inputName.isEmpty()) {
        output.clearCustomName();
    } else {
        output.setDisplayName(new StringTextComponent(inputName));
    }
    // Set the output
    event.setOutput(output);
    // Set the cost
    event.setCost(NinjaGear.instance.getConfig().getImbueCost());
}
Also used : ArmorItem(net.minecraft.item.ArmorItem) ItemNinjaArmor(com.infinityraider.ninjagear.item.ItemNinjaArmor) StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 15 with ArmorItem

use of net.minecraft.item.ArmorItem in project Fabric-Course-118 by Kaupenjoe.

the class ModArmorItem method hasCorrectArmorOn.

private boolean hasCorrectArmorOn(ArmorMaterial material, PlayerEntity player) {
    ArmorItem boots = ((ArmorItem) player.getInventory().getArmorStack(0).getItem());
    ArmorItem leggings = ((ArmorItem) player.getInventory().getArmorStack(1).getItem());
    ArmorItem breastplate = ((ArmorItem) player.getInventory().getArmorStack(2).getItem());
    ArmorItem helmet = ((ArmorItem) player.getInventory().getArmorStack(3).getItem());
    return helmet.getMaterial() == material && breastplate.getMaterial() == material && leggings.getMaterial() == material && boots.getMaterial() == material;
}
Also used : ArmorItem(net.minecraft.item.ArmorItem)

Aggregations

ArmorItem (net.minecraft.item.ArmorItem)28 ItemStack (net.minecraft.item.ItemStack)16 ResourceLocation (net.minecraft.util.ResourceLocation)7 Item (net.minecraft.item.Item)6 Inject (org.spongepowered.asm.mixin.injection.Inject)6 ArrayList (java.util.ArrayList)4 Color (java.awt.Color)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2 PlayerInventory (net.minecraft.entity.player.PlayerInventory)2 ElytraItem (net.minecraft.item.ElytraItem)2 ToolItem (net.minecraft.item.ToolItem)2 TranslatableText (net.minecraft.text.TranslatableText)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 Ability (online.kingdomkeys.kingdomkeys.ability.Ability)2 IKeychain (online.kingdomkeys.kingdomkeys.api.item.IKeychain)2 IPlayerCapabilities (online.kingdomkeys.kingdomkeys.capability.IPlayerCapabilities)2 KKAccessoryItem (online.kingdomkeys.kingdomkeys.item.KKAccessoryItem)2 KKPotionItem (online.kingdomkeys.kingdomkeys.item.KKPotionItem)2 KeybladeItem (online.kingdomkeys.kingdomkeys.item.KeybladeItem)2