Search in sources :

Example 1 with ItemMekanismShield

use of mekanism.tools.common.item.ItemMekanismShield in project Mekanism by mekanism.

the class MekBannerShieldRecipe method matches.

@Override
public boolean matches(CraftingInventory inv, @Nonnull World world) {
    ItemStack shieldStack = ItemStack.EMPTY;
    ItemStack bannerStack = ItemStack.EMPTY;
    for (int i = 0; i < inv.getContainerSize(); ++i) {
        ItemStack stackInSlot = inv.getItem(i);
        if (!stackInSlot.isEmpty()) {
            if (stackInSlot.getItem() instanceof BannerItem) {
                if (!bannerStack.isEmpty()) {
                    return false;
                }
                bannerStack = stackInSlot;
            } else {
                if (!(stackInSlot.getItem() instanceof ItemMekanismShield) || !shieldStack.isEmpty() || stackInSlot.getTagElement(NBTConstants.BLOCK_ENTITY_TAG) != null) {
                    return false;
                }
                shieldStack = stackInSlot;
            }
        }
    }
    return !shieldStack.isEmpty() && !bannerStack.isEmpty();
}
Also used : BannerItem(net.minecraft.item.BannerItem) ItemMekanismShield(mekanism.tools.common.item.ItemMekanismShield) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemMekanismShield

use of mekanism.tools.common.item.ItemMekanismShield in project Mekanism by mekanism.

the class ToolsItemModelProvider method registerModels.

@Override
protected void registerModels() {
    // Shields
    addShieldModel(ToolsItems.BRONZE_SHIELD, Mekanism.rl("block/block_bronze"));
    addShieldModel(ToolsItems.LAPIS_LAZULI_SHIELD, mcLoc("block/lapis_block"));
    addShieldModel(ToolsItems.OSMIUM_SHIELD, Mekanism.rl("block/block_osmium"));
    addShieldModel(ToolsItems.REFINED_GLOWSTONE_SHIELD, Mekanism.rl("block/block_refined_glowstone"));
    addShieldModel(ToolsItems.REFINED_OBSIDIAN_SHIELD, Mekanism.rl("block/block_refined_obsidian"));
    addShieldModel(ToolsItems.STEEL_SHIELD, Mekanism.rl("block/block_steel"));
    // Armor items are generated textures, all other tools module items are handheld
    for (IItemProvider itemProvider : ToolsItems.ITEMS.getAllItems()) {
        Item item = itemProvider.getItem();
        if (item instanceof ItemMekanismShield) {
            // Skip shields, we manually handle them above
            continue;
        }
        ResourceLocation texture;
        if (isVanilla(itemProvider)) {
            texture = itemTexture(itemProvider);
        } else {
            String name = itemProvider.getName();
            int index = name.lastIndexOf('_');
            texture = modLoc("item/" + name.substring(0, index) + '/' + name.substring(index + 1));
        }
        if (item instanceof ArmorItem) {
            generated(itemProvider, texture);
        } else {
            handheld(itemProvider, texture);
        }
    }
}
Also used : Item(net.minecraft.item.Item) ArmorItem(net.minecraft.item.ArmorItem) ArmorItem(net.minecraft.item.ArmorItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemMekanismShield(mekanism.tools.common.item.ItemMekanismShield) IItemProvider(mekanism.api.providers.IItemProvider)

Example 3 with ItemMekanismShield

use of mekanism.tools.common.item.ItemMekanismShield in project Mekanism by mekanism.

the class MekBannerShieldRecipe method assemble.

@Nonnull
@Override
public ItemStack assemble(CraftingInventory inv) {
    ItemStack bannerStack = ItemStack.EMPTY;
    ItemStack shieldStack = ItemStack.EMPTY;
    for (int i = 0; i < inv.getContainerSize(); ++i) {
        ItemStack stackInSlot = inv.getItem(i);
        if (!stackInSlot.isEmpty()) {
            if (stackInSlot.getItem() instanceof BannerItem) {
                bannerStack = stackInSlot;
            } else if (stackInSlot.getItem() instanceof ItemMekanismShield) {
                shieldStack = stackInSlot.copy();
            }
        }
    }
    if (shieldStack.isEmpty()) {
        return ItemStack.EMPTY;
    }
    CompoundNBT blockEntityTag = bannerStack.getTagElement(NBTConstants.BLOCK_ENTITY_TAG);
    CompoundNBT tag = blockEntityTag == null ? new CompoundNBT() : blockEntityTag.copy();
    tag.putInt(NBTConstants.BASE, ((BannerItem) bannerStack.getItem()).getColor().getId());
    shieldStack.addTagElement(NBTConstants.BLOCK_ENTITY_TAG, tag);
    return shieldStack;
}
Also used : BannerItem(net.minecraft.item.BannerItem) CompoundNBT(net.minecraft.nbt.CompoundNBT) ItemMekanismShield(mekanism.tools.common.item.ItemMekanismShield) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

ItemMekanismShield (mekanism.tools.common.item.ItemMekanismShield)3 BannerItem (net.minecraft.item.BannerItem)2 ItemStack (net.minecraft.item.ItemStack)2 Nonnull (javax.annotation.Nonnull)1 IItemProvider (mekanism.api.providers.IItemProvider)1 ArmorItem (net.minecraft.item.ArmorItem)1 Item (net.minecraft.item.Item)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ResourceLocation (net.minecraft.util.ResourceLocation)1