Package net.minecraft.inventory

Examples of net.minecraft.inventory.InventoryCrafting


    public IInventory craftResult;
    private World worldObj;

    public WorkbenchContainer(InventoryPlayer inventoryplayer, World world)
    {
        craftMatrix = new InventoryCrafting(this, 3, 3);
        craftResult = new InventoryCraftResult();
        worldObj = world;
        this.addSlotToContainer(new SlotCrafting(inventoryplayer.player, craftMatrix, craftResult, 0, 124, 35));
        for (int i = 0; i < 3; i++)
        {
View Full Code Here


    return -1;
  }
 
  private ItemStack findMatchingRecipe()
  {
    InventoryCrafting craft = new RemoteInventoryCrafting();
    for(int i = 0; i < 9; i++)
    {
      craft.setInventorySlotContents(i, (_inventory[i] == null ? null : _inventory[i].copy()));
    }
   
    return CraftingManager.getInstance().findMatchingRecipe(craft, worldObj);
  }
View Full Code Here

  boolean craft(boolean fullCheck) {
    if(fullCheck && !isFull())
      return false;

    InventoryCrafting craft = new InventoryCrafting(new Container() {
      @Override
      public boolean canInteractWith(EntityPlayer p_75145_1_) {
        return false;
      }
    }, 3, 3);
    for(int i = 0; i < 9; i++) {
      ItemStack stack = getStackInSlot(i);

      if(stack == null || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11)
        continue;

      craft.setInventorySlotContents(i, stack.copy());
    }

    List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
    for(IRecipe recipe : recipes)
      if(recipe.matches(craft, worldObj)) {
View Full Code Here

      {
        return false;
      }
    };
   
    InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3);
    ArrayList recipeList = (ArrayList)CraftingManager.getInstance().getRecipeList();

    for(int i = 1; i < 9; i++)
    {
      tempCrafting.setInventorySlotContents(i, null);
    }

    ArrayList registeredOres = OreDictionary.getOres("logWood");
   
    for(int i = 0; i < registeredOres.size(); i++)
    {
      ItemStack logEntry = (ItemStack)registeredOres.get(i);

      if(logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE)
      {
        for(int j = 0; j < 16; j++)
        {
          ItemStack log = new ItemStack(logEntry.getItem(), 1, j);
          tempCrafting.setInventorySlotContents(0, log);
          ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);

          if(resultEntry != null)
          {
            RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(Mekanism.Sawdust), 1));
          }
        }
      }
      else {
        ItemStack log = StackUtils.size(logEntry, 1);
        tempCrafting.setInventorySlotContents(0, log);
        ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);

        if(resultEntry != null)
        {
          RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(Mekanism.Sawdust), 1));
View Full Code Here

    return overridden;
  }
 
  public static VanillaStationCrafting findVanillaRecipe(InventoryCraftingStation inv) {
    World world = ((inv.entity != null) ? inv.entity.getWorldObj() : WorldUtils.getLocalWorld());
    InventoryCrafting crafting = new InventoryCrafting(null, 3, 3);
    ReflectionUtils.set(InventoryCrafting.class, crafting, "field_70466_a", "stackList", inv.crafting);
    IRecipe recipe = findRecipe(crafting, world);
    if (recipe == null) return null;
    return new VanillaStationCrafting(world, recipe, inv.crafting, recipe.getCraftingResult(crafting));
  }
View Full Code Here

    public VanillaRecipeInput(World world, IRecipe recipe, ItemStack[] input, int slot) {
      this.world = world;
      this.recipe = recipe;
      this.slot = slot;
     
      crafting = new InventoryCrafting(new FakeContainer(), 3, 3);
      for (int i = 0; i < input.length; i++)
        crafting.setInventorySlotContents(i, ItemStack.copyItemStack(input[i]));
     
      expectedOutput = recipe.getCraftingResult(crafting).copy();
    }
View Full Code Here

  @Override
  protected void setupInventoryContainer() {
    inv = ((inventory instanceof InventoryCraftingStation)
        ? (InventoryCraftingStation)inventory
        : ((InventoryCraftingStation)((InventoryTileEntity)inventory).inventory));
    craftMatrix = new InventoryCrafting(this, 3, 3);
   
    ReflectionUtils.set(InventoryCrafting.class, craftMatrix, "field_70466_a", "stackList", inv.crafting);
    slotCrafting = new CustomSlotCrafting(player, null, null, 0, 0, 0);
   
    // Crafting
View Full Code Here

    private boolean updateCachedRecipeOutput() {

      if (cachedRecipeOutput != null)
        return true;

      InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
      for (int i = 0; i < crafting.getSizeInventory(); i++) {
        crafting.setInventorySlotContents(i, matrix.getStackInSlot(i));
      }

      cachedRecipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, cachedWorld);
      return cachedRecipeOutput != null;
    }
View Full Code Here

      return recipeOutput != null && cachedRecipeOutput.isItemEqual(recipeOutput);
    }

    @Override
    public final void readFromNBT(NBTTagCompound nbttagcompound) {
      matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
      matrix.readFromNBT(nbttagcompound);
      sanitizeMatrix();
      lastUsed = nbttagcompound.getLong("LastUsed");
      locked = nbttagcompound.getBoolean("Locked");
    }
View Full Code Here

    // because it makes Oak Wood Planks using the same recipe.
    // Strategy:
    // Create a fake crafting inventory using items we have in stock
    // in place of the ones in the saved crafting inventory.
    // Check that the recipe it makes is the same as the currentRecipe.
    InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
    ItemStack[] stockCopy = StackUtils.condenseStacks(stock);

    for (int slot = 0; slot < currentCrafting.getSizeInventory(); slot++) {
      ItemStack recipeStack = currentCrafting.getStackInSlot(slot);
      if (recipeStack == null)
        continue;

      // Use crafting equivalent (not oredict) items first
      for (ItemStack stockStack : stockCopy) {
        if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
          ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
          stockStack.stackSize--;
          crafting.setInventorySlotContents(slot, stack);
          break;
        }
      }

      // Use oredict items if crafting equivalent items aren't available
      if (crafting.getStackInSlot(slot) == null) {
        for (ItemStack stockStack : stockCopy) {
          if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
            ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
            stockStack.stackSize--;
            crafting.setInventorySlotContents(slot, stack);
            break;
          }
        }
      }
    }
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.