Search in sources :

Example 56 with ItemStack

use of net.minecraft.item.ItemStack in project BluePower by Qmunity.

the class CanvasBagRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
    ItemStack bag = null;
    for (int slot = 0; slot < inventoryCrafting.getSizeInventory(); slot++) {
        if (inventoryCrafting.getStackInSlot(slot) != null && inventoryCrafting.getStackInSlot(slot).getItem() instanceof ItemCanvasBag) {
            bag = inventoryCrafting.getStackInSlot(slot);
        }
    }
    if (bag != null) {
        bag = bag.copy();
        bag.setItemDamage(this.getRecipeOutput().getItemDamage());
        return bag;
    }
    return this.getRecipeOutput();
}
Also used : ItemCanvasBag(com.bluepowermod.item.ItemCanvasBag) ItemStack(net.minecraft.item.ItemStack)

Example 57 with ItemStack

use of net.minecraft.item.ItemStack in project BluePower by Qmunity.

the class CoreRecipes method registerCanvasBagRecipes.

private static void registerCanvasBagRecipes(ItemStack is) {
    RecipeSorter.register(Refs.MODID + ":canvasBag", CanvasBagRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
    for (int damage = Refs.oreDictDyes.length - 1; damage >= 0; damage--) {
        ItemStack input = is.copy();
        input.setItemDamage(damage);
        for (int dye = 0; dye < Refs.oreDictDyes.length; dye++) {
            if (dye != input.getItemDamage()) {
                ItemStack output = is.copy();
                output.setItemDamage(dye);
                GameRegistry.addRecipe(new CanvasBagRecipe(output, input, Refs.oreDictDyes[dye]));
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 58 with ItemStack

use of net.minecraft.item.ItemStack in project BluePower by Qmunity.

the class TubeLogic method retrieveStack.

public boolean retrieveStack(TileEntity target, ForgeDirection dirToRetrieveInto, ItemStack filter, TubeColor color) {
    if (tube.getWorld() == null)
        return false;
    TubeStack stack = new TubeStack(filter, null, color);
    stack.setTarget(target, dirToRetrieveInto);
    Pair<ForgeDirection, TileEntity> result = getHeadingForItem(stack, false);
    if (result == null)
        return false;
    int fuzzySetting = 0;
    if (target instanceof IFuzzyRetrieving) {
        fuzzySetting = ((IFuzzyRetrieving) target).getFuzzySetting();
    }
    ItemStack extractedItem = null;
    if (result.getValue() instanceof TileManager) {
        // Exception for managers, the result can only end up as a manager if the pulling inventory was
        // a manager.
        TileEntity managedInventory = ((TileManager) result.getValue()).getTileCache(((TileManager) result.getValue()).getFacingDirection());
        extractedItem = IOHelper.extract(managedInventory, result.getKey().getOpposite(), filter, false, false, fuzzySetting);
    } else if (filter != null) {
        extractedItem = IOHelper.extract(result.getValue(), result.getKey().getOpposite(), filter, !(target instanceof TileManager), false, fuzzySetting);
    } else {
        extractedItem = IOHelper.extract(result.getValue(), result.getKey().getOpposite(), false);
    }
    if (extractedItem == null)
        throw new IllegalArgumentException("This isn't possible!");
    stack = new TubeStack(extractedItem, result.getKey().getOpposite(), color);
    stack.setTarget(target, dirToRetrieveInto);
    PneumaticTube tube = MultipartCompatibility.getPart(this.tube.getWorld(), result.getValue().xCoord - result.getKey().offsetX, result.getValue().yCoord - result.getKey().offsetY, result.getValue().zCoord - result.getKey().offsetZ, PneumaticTube.class);
    if (tube == null)
        throw new IllegalArgumentException("wieeeeerd!");
    return tube.getLogic().injectStack(stack, result.getKey().getOpposite(), false);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticTube(com.bluepowermod.api.tube.IPneumaticTube) IFuzzyRetrieving(com.bluepowermod.tile.IFuzzyRetrieving) MessageRedirectTubeStack(com.bluepowermod.network.message.MessageRedirectTubeStack) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack) TileManager(com.bluepowermod.tile.tier3.TileManager)

Example 59 with ItemStack

use of net.minecraft.item.ItemStack in project BluePower by Qmunity.

the class TileAlloyFurnace method decrStackSize.

@Override
public ItemStack decrStackSize(int var1, int var2) {
    ItemStack tInventory = getStackInSlot(var1);
    if (tInventory == null) {
        return null;
    }
    ItemStack ret = null;
    if (tInventory.stackSize < var2) {
        ret = tInventory;
        inventory = null;
    } else {
        ret = tInventory.splitStack(var2);
        if (tInventory.stackSize <= 0) {
            if (var1 == 0) {
                fuelInventory = null;
            } else if (var1 == 1) {
                outputInventory = null;
            } else {
                inventory[var1 - 2] = null;
            }
        }
    }
    return ret;
}
Also used : ItemStack(net.minecraft.item.ItemStack)

Example 60 with ItemStack

use of net.minecraft.item.ItemStack in project LogisticsPipes by RS485.

the class LogisticsSolderingTileEntity method tryCraft.

private boolean tryCraft() {
    ItemIdentifierStack content = inv.getIDStackInSlot(10);
    ICraftingResultHandler handler = getHandlerForRecipe();
    ItemStack toAdd = getTagetForRecipe(false);
    if (handler != null) {
        handler.handleCrafting(toAdd);
    }
    if (content != null) {
        if (!content.getItem().equals(toAdd)) {
            return false;
        }
        if (content.getStackSize() + toAdd.stackSize > content.getItem().getMaxStackSize()) {
            return false;
        }
        toAdd.stackSize += content.getStackSize();
    }
    //dummy
    getTagetForRecipe(true);
    inv.setInventorySlotContents(10, toAdd);
    inv.decrStackSize(9, 1);
    inv.markDirty();
    super.markDirty();
    updateInventory();
    return true;
}
Also used : ICraftingResultHandler(logisticspipes.interfaces.ICraftingResultHandler) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)9052 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)941 ArrayList (java.util.ArrayList)733 TileEntity (net.minecraft.tileentity.TileEntity)555 BlockPos (net.minecraft.util.math.BlockPos)551 EntityPlayer (net.minecraft.entity.player.EntityPlayer)526 IBlockState (net.minecraft.block.state.IBlockState)505 Block (net.minecraft.block.Block)494 Item (net.minecraft.item.Item)465 Slot (net.minecraft.inventory.Slot)448 EntityItem (net.minecraft.entity.item.EntityItem)423 Nonnull (javax.annotation.Nonnull)356 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)330 FluidStack (net.minecraftforge.fluids.FluidStack)289 NBTTagList (net.minecraft.nbt.NBTTagList)280 World (net.minecraft.world.World)277 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)269 ResourceLocation (net.minecraft.util.ResourceLocation)260 List (java.util.List)223 EnumFacing (net.minecraft.util.EnumFacing)208