net.minecraft.recipe.ShapedRecipe Java Examples

The following examples show how to use net.minecraft.recipe.ShapedRecipe. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShapedCompressingRecipeSerializer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public T read(Identifier identifier_1, JsonObject jsonObject_1) {
    String string_1 = JsonHelper.getString(jsonObject_1, "group", "");
    Map<String, Ingredient> map_1 = ShapedCompressingRecipe.getComponents(JsonHelper.getObject(jsonObject_1, "key"));
    String[] strings_1 = ShapedCompressingRecipe.combinePattern(ShapedCompressingRecipe.getPattern(JsonHelper.getArray(jsonObject_1, "pattern")));
    int int_1 = strings_1[0].length();
    int int_2 = strings_1.length;
    DefaultedList<Ingredient> defaultedList_1 = ShapedCompressingRecipe.getIngredients(strings_1, map_1, int_1, int_2);
    ItemStack itemStack_1 = ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject_1, "result"));
    return factory.create(identifier_1, string_1, int_1, int_2, defaultedList_1, itemStack_1);
}
 
Example #2
Source File: RecipeBook_1_12.java    From multiconnect with MIT License 5 votes vote down vote up
private void placeRecipe(Recipe<C> recipe, List<Slot> slots, int placeCount, IntList inputItemIds, List<PlaceRecipeC2SPacket_1_12.Transaction> transactionsToMatrix) {
    int width = container.getCraftingWidth();
    int height = container.getCraftingHeight();

    if (recipe instanceof ShapedRecipe) {
        ShapedRecipe shaped = (ShapedRecipe) recipe;
        width = shaped.getWidth();
        height = shaped.getHeight();
    }

    int serverSlot = 1;
    Iterator<Integer> inputItemItr = inputItemIds.iterator();

    // :thonkjang: probably meant to swap craftingWidth and craftingHeight here, but oh well because width = height
    for (int y = 0; y < container.getCraftingWidth() && y != height; y++) {
        for (int x = 0; x < container.getCraftingHeight(); x++) {
            if (x == width || !inputItemItr.hasNext()) {
                serverSlot += container.getCraftingWidth() - x;
                break;
            }

            Slot slot = slots.get(serverSlot);

            ItemStack stackNeeded = RecipeFinder.getStackFromId(inputItemItr.next());
            if (!stackNeeded.isEmpty()) {
                for (int i = 0; i < placeCount; i++) {
                    PlaceRecipeC2SPacket_1_12.Transaction transaction = findAndMoveToCraftMatrix(serverSlot, slot, stackNeeded);
                    if (transaction != null) {
                        transactionsToMatrix.add(transaction);
                    }
                }
            }
            serverSlot++;
        }

        if (!inputItemItr.hasNext()) {
            break;
        }
    }
}
 
Example #3
Source File: InfusionRecipeSerializer.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public InfusionRecipe read(Identifier ID, JsonObject json) {
	InfusionRecipe.InfusionRecipeFormat recipe = new Gson().fromJson(json, InfusionRecipe.InfusionRecipeFormat.class);
	return new InfusionRecipe(ID, fromJson(recipe.target), fromJson(recipe.input), ShapedRecipe.getItemStack(recipe.output));
}