public void slotChangedCraftingGrid() { if (!initialized) { return; } World world = myTile.getWorld(); if (ServerHelper.isServerWorld(world)) { EntityPlayerMP playerMP = (EntityPlayerMP) player; ItemStack stack = ItemStack.EMPTY; IRecipe recipe = CraftingManager.findMatchingRecipe(craftMatrix, world); if (recipe != null && CrafterRecipe.validRecipe(recipe)) { craftResult.setRecipeUsed(recipe); stack = recipe.getCraftingResult(craftMatrix); } myTile.markRecipeChanges(); craftResult.setInventorySlotContents(0, stack); playerMP.connection.sendPacket(new SPacketSetSlot(this.windowId, inventorySlots.size() - 1, stack)); } else { calcCraftingGridClient(); } }
public void setRecipe() { for (int i = 0; i < 9; i++) { craftMatrix.setInventorySlotContents(i, inventory[i + SLOT_CRAFTING_START]); } IRecipe newRecipe = CraftingManager.findMatchingRecipe(craftMatrix, world); ItemStack stack = ItemStack.EMPTY; if (newRecipe != null) { stack = newRecipe.getCraftingResult(craftMatrix); craftRecipe = CrafterRecipe.getRecipe(newRecipe, this); if (craftRecipe == null) { newRecipe = null; stack = ItemStack.EMPTY; usingTank = false; } } else { craftRecipe = null; usingTank = false; } if (craftRecipe == null) { if (isActive) { processOff(); } } inventory[SLOT_CRAFTING_START + 9] = stack; craftResult.setRecipeUsed(newRecipe); craftResult.setInventorySlotContents(0, inventory[SLOT_CRAFTING_START + 9]); clearRecipeChanges(); }
public static CrafterRecipe getRecipe(IRecipe recipe, TileCrafter tile) { CrafterRecipe wrapper = new CrafterRecipe(recipe, tile); return wrapper.valid ? wrapper : null; }
public void calcCraftingGridClient() { ItemStack stack = ItemStack.EMPTY; IRecipe recipe = CraftingManager.findMatchingRecipe(craftMatrix, myTile.getWorld()); if (recipe != null && CrafterRecipe.validRecipe(recipe)) { craftResult.setRecipeUsed(recipe); stack = recipe.getCraftingResult(craftMatrix); } craftResult.setInventorySlotContents(0, stack); }