Package net.minecraft.inventory

Examples of net.minecraft.inventory.InventoryCrafting


    public boolean isTransmutationResult(BlockTuple block, World w, int x, int y, int z) {
        return getBlockTransformation(w, x, y, z).values().contains(block);
    }

    public ItemStack getBlockCraftingResult(World w, ItemStack itemStack) {
        InventoryCrafting blockCraftInventory = new InventoryCrafting(new Container() {
            @Override
            public boolean canInteractWith(EntityPlayer entityPlayer) {
                return false;
            }
        }, 3, 3);

        for (int i = 0; i < 9; i++) {
            blockCraftInventory.setInventorySlotContents(i, itemStack);
        }

        return CraftingManager.getInstance().findMatchingRecipe(blockCraftInventory, w);
    }
View Full Code Here


    return false;
  }

  public boolean doesRecipeExist(ICraftingPatternMAC pattern)
  {
    InventoryCrafting inv = new InventoryCrafting(new ContainerWorkbench(new InventoryPlayer(null), gridTE.getWorld(), 0, 0, 0)
    {
      public void onCraftMatrixChanged(IInventory par1IInventory)
      {
      }
    }, 3, 3);
    for (int i = 0; i < pattern.getCraftingMatrix().length; i++)
    {
      inv.setInventorySlotContents(i, pattern.getCraftingMatrix()[i]);
    }
    ItemStack thing = CraftingManager.getInstance().findMatchingRecipe(inv, gridTE.getWorld());
    return ItemStack.areItemStacksEqual(thing, pattern.getOutput());
  }
View Full Code Here

    }
    return true;
  }

  public void doCraft(CraftRecipe recipe, EntityPlayer player, ItemStack craftedItem) {
    InventoryCrafting craftMatrix = generateTemporaryCraftingGridFor( recipe, player, true );
    if( craftMatrix == null )
      return;

    craftedItem.onCrafting( device.getWorld(), player, craftedItem.stackSize );
    GameRegistry.onItemCrafted( player, craftedItem, craftMatrix );
View Full Code Here

   * Whether if automation can craft the current recipe in the crafting grid.
   */
  private boolean canCraft() {
    if( !hasRecipe() )
      return false;
    InventoryCrafting grid = InventoryUtils.simulateCraftingInventory( null, subGrid );
    ItemStack result = CraftingManager.getInstance().findMatchingRecipe( grid, worldObj );
    return InventoryUtils.similarStacks( outputInv.getStackInSlot( 0 ), result, true );
  }
View Full Code Here

  public static boolean matchesIngredient(CraftRecipe recipe, int ingredientIndex, ItemStack otherStack, World world) {
    try {
      IRecipe iRecipe = recipe.getRecipePointer().getIRecipe();

      InventoryCrafting craftingGrid = simulateGrid( recipe, ingredientIndex, otherStack );

      if( !iRecipe.matches( craftingGrid, world ) )
        return false;

      ItemStack nominalResult = recipe.getResult();
View Full Code Here

    }
    return null;
  }

  public static InventoryCrafting simulateGrid(CraftRecipe recipe, int ingredientIndex, ItemStack otherItem) {
    InventoryCrafting craftingGrid = InventoryUtils.simulateCraftingInventory( recipe.getIngredients() );
    craftingGrid.setInventorySlotContents( ingredientIndex, otherItem );
    return craftingGrid;
  }
View Full Code Here

   */
  public static CraftRecipe generateRecipe(ItemStack[] ingredients, World world) {
    if( ingredients == null || ingredients.length != 9 )
      return null;

    InventoryCrafting craftGrid = InventoryUtils.simulateCraftingInventory( ingredients );
    if( craftGrid == null )
      return null;

    RecipePointer pointer = getRecipeFrom( craftGrid, world );
    if( pointer == null )
View Full Code Here

    if( recipe == null )
      return null;
    if( device.getWorld().isRemote )
      return getStack(); // Client-side, only show.

    InventoryCrafting grid = handler.generateTemporaryCraftingGridFor( recipe, player, false );
    ItemStack craftedItem = handler.getRecipeResult( recipe, grid );
    return Utils.copyOf( craftedItem );
  }
View Full Code Here

    CraftRecipe recipe = RecipeUtils.getRecipe( gridContents, player.worldObj );

    Slot outputSlot = (Slot) inventorySlots.get( 0 );
    ItemStack item = null;
    if( recipe != null ) {
      InventoryCrafting grid = InventoryUtils.simulateCraftingInventory( gridContents );
      item = recipe.getRecipePointer().getOutputFrom( grid );
    }
    outputSlot.putStack( item );

    int notify = item == null ? 1 : 0;
View Full Code Here

    craftingGrid.writeToNBT(craftingRoot);
    nbtRoot.setTag("craftingGrid", craftingRoot);
  }

  public void updateCraftingOutput() {
    InventoryCrafting inv = new InventoryCrafting(new Container() {

      @Override
      public boolean canInteractWith(EntityPlayer var1) {
        return false;
      }
    }, 3, 3);

    for (int i = 0; i < 9; i++) {
      inv.setInventorySlotContents(i, craftingGrid.getStackInSlot(i));
    }
    ItemStack matches = CraftingManager.getInstance().findMatchingRecipe(inv, worldObj);
    craftingGrid.setInventorySlotContents(9, matches);
    markDirty();
View Full Code Here

TOP

Related Classes of net.minecraft.inventory.InventoryCrafting

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.