Search in sources :

Example 26 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class LockColorRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
    ItemStack lock = InventoryUtils.findItem(crafting, BetterStorageItems.lock);
    List<ItemStack> dyes = InventoryUtils.findDyes(crafting);
    ItemStack result = lock.copy();
    // Apply color.
    if (dyes.size() > 0) {
        int color = DyeUtils.getColorFromDyes(dyes);
        if (dyes.size() >= 8)
            ItemBetterStorage.setFullColor(result, color);
        else
            ItemBetterStorage.setColor(result, color);
    }
    return result;
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 27 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class LockRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
    int id = ItemBetterStorage.getID(crafting.getStackInSlot(4));
    ItemStack result = getRecipeOutput().copy();
    ItemBetterStorage.setID(result, id);
    return result;
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 28 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class PresentRecipe method createRecipeInput.

private static ItemStack[] createRecipeInput() {
    ItemStack box = new ItemStack(BetterStorageTiles.cardboardBox);
    ItemStack wool1 = new ItemStack(Blocks.wool, 1, 14);
    ItemStack wool2 = new ItemStack(Blocks.wool, 1, 0);
    return new ItemStack[] { wool1, wool2, wool1, wool1, box, wool1, wool1, wool2, wool1 };
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 29 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class PresentRecipe method checkWoolColor.

private static int checkWoolColor(InventoryCrafting crafting, int... slots) {
    int color = -1;
    for (int i = 0; i < slots.length; i++) {
        int slot = slots[i];
        ItemStack stack = crafting.getStackInSlot(slot);
        int woolColor;
        if (stack == null)
            return -1;
        else if (stack.getItem() == Item.getItemFromBlock(Blocks.wool))
            woolColor = stack.getItemDamage();
        else if (stack.getItem() == Item.getItemFromBlock(Blocks.gold_block))
            woolColor = 16;
        else
            return -1;
        if (i <= 0)
            color = woolColor;
        else if (woolColor != color)
            return -1;
    }
    return color;
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 30 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class PresentRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
    int colorInner = checkWoolColor(crafting, 0);
    int colorOuter = checkWoolColor(crafting, 1);
    int leftRight = checkWoolColor(crafting, 3);
    boolean skojanzaMode = (leftRight == colorOuter);
    ItemStack box = crafting.getStackInSlot(4);
    ItemStack present = new ItemStack(BetterStorageTiles.present);
    NBTTagCompound compound = (NBTTagCompound) box.getTagCompound().copy();
    compound.setByte(TileEntityPresent.TAG_COLOR_INNER, (byte) colorInner);
    compound.setByte(TileEntityPresent.TAG_COLOR_OUTER, (byte) colorOuter);
    compound.setBoolean(TileEntityPresent.TAG_SKOJANZA_MODE, skojanzaMode);
    int color = StackUtils.get(box, -1, "display", "color");
    if (color >= 0)
        compound.setInteger("color", color);
    present.setTagCompound(compound);
    StackUtils.remove(present, "display", "color");
    return present;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2512 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)250 ArrayList (java.util.ArrayList)244 EntityItem (net.minecraft.entity.item.EntityItem)170 Slot (net.minecraft.inventory.Slot)164 TileEntity (net.minecraft.tileentity.TileEntity)155 EntityPlayer (net.minecraft.entity.player.EntityPlayer)153 Block (net.minecraft.block.Block)148 Item (net.minecraft.item.Item)118 BlockPos (net.minecraft.util.math.BlockPos)83 NBTTagList (net.minecraft.nbt.NBTTagList)74 IInventory (net.minecraft.inventory.IInventory)73 IBlockState (net.minecraft.block.state.IBlockState)70 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)67 FluidStack (net.minecraftforge.fluids.FluidStack)63 ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)63 World (net.minecraft.world.World)56 List (java.util.List)55 ResourceLocation (net.minecraft.util.ResourceLocation)50 Entity (net.minecraft.entity.Entity)47