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();
}
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);
}
}
}
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;
}
Aggregations