Search in sources :

Example 1 with Pattern

use of slimeknights.tconstruct.library.recipe.partbuilder.Pattern in project TinkersConstruct by SlimeKnights.

the class LayoutIconTest method pattern_getValue_hasSamePattern.

/* Pattern */
@Test
void pattern_getValue_hasSamePattern() {
    Pattern pattern = new Pattern("test:the_pattern");
    LayoutIcon itemIcon = LayoutIcon.ofPattern(pattern);
    Pattern contained = itemIcon.getValue(Pattern.class);
    assertThat(contained).isNotNull();
    assertThat(contained).isEqualTo(pattern);
    assertThat(itemIcon.getValue(ItemStack.class)).isNull();
}
Also used : Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern) BaseMcTest(slimeknights.tconstruct.test.BaseMcTest) Test(org.junit.jupiter.api.Test)

Example 2 with Pattern

use of slimeknights.tconstruct.library.recipe.partbuilder.Pattern in project TinkersConstruct by SlimeKnights.

the class LayoutIconTest method pattern_jsonDeserialize.

@Test
void pattern_jsonDeserialize() {
    JsonObject json = new JsonObject();
    json.addProperty("pattern", "test:json_pattern");
    LayoutIcon parsed = LayoutIcon.SERIALIZER.deserialize(json, LayoutIcon.class, mock(JsonDeserializationContext.class));
    Pattern contained = parsed.getValue(Pattern.class);
    assertThat(contained).isNotNull();
    assertThat(contained).isEqualTo(new Pattern("test:json_pattern"));
}
Also used : Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) JsonObject(com.google.gson.JsonObject) BaseMcTest(slimeknights.tconstruct.test.BaseMcTest) Test(org.junit.jupiter.api.Test)

Example 3 with Pattern

use of slimeknights.tconstruct.library.recipe.partbuilder.Pattern in project Materialis by RCXcrafter.

the class MaterialisToolSlotLayouts method addLayouts.

@Override
protected void addLayouts() {
    // wrench
    defineModifiable(MaterialisResources.WRENCH).sortIndex(SORT_HARVEST).addInputItem(MaterialisResources.WRENCH_HEAD, 39, 35).addInputItem(TinkerToolParts.toolHandle, 21, 53).build();
    defineModifiable(TinkerTools.sledgeHammer).sortIndex(SORT_HARVEST + SORT_LARGE).addInputItem(TinkerToolParts.hammerHead, 44, 29).addInputItem(TinkerToolParts.toughHandle, 21, 52).addInputSlot(new Pattern(Objects.requireNonNull(TinkerToolParts.largePlate.asItem().getRegistryName())), TinkerToolParts.largePlate.asItem().getDescriptionId(), 50, 48, Ingredient.of(TinkerToolParts.largePlate, MaterialisResources.WRENCH_HEAD)).addInputSlot(new Pattern(Objects.requireNonNull(TinkerToolParts.largePlate.asItem().getRegistryName())), TinkerToolParts.largePlate.asItem().getDescriptionId(), 25, 20, Ingredient.of(TinkerToolParts.largePlate, MaterialisResources.WRENCH_HEAD)).build();
}
Also used : Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern)

Example 4 with Pattern

use of slimeknights.tconstruct.library.recipe.partbuilder.Pattern in project TinkersConstruct by SlimeKnights.

the class PartBuilderCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout layout, IDisplayPartBuilderRecipe recipe, IIngredients ingredients) {
    IGuiItemStackGroup items = layout.getItemStacks();
    items.init(0, true, 24, 15);
    items.init(1, true, 3, 15);
    items.init(2, false, 95, 14);
    items.set(ingredients);
    IGuiIngredientGroup<Pattern> patterns = layout.getIngredientsGroup(JEIPlugin.PATTERN_TYPE);
    patterns.init(0, true, 46, 16);
    patterns.set(ingredients);
}
Also used : Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern) IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup)

Example 5 with Pattern

use of slimeknights.tconstruct.library.recipe.partbuilder.Pattern in project TinkersConstruct by SlimeKnights.

the class PartBuilderScreen method drawRecipesItems.

/**
 * Draw slot icons for all patterns
 */
private void drawRecipesItems(PoseStack matrices, int left, int top) {
    // use block texture list
    assert this.minecraft != null;
    RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
    Function<ResourceLocation, TextureAtlasSprite> spriteGetter = this.minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS);
    // iterate all recipes
    List<Pattern> list = this.tile.getSortedButtons();
    int max = Math.min(this.recipeIndexOffset + 12, this.getPartRecipeCount());
    for (int i = this.recipeIndexOffset; i < max; ++i) {
        int relative = i - this.recipeIndexOffset;
        int x = left + relative % 4 * 18 + 1;
        int y = top + (relative / 4) * 18 + 1;
        // get the sprite for the pattern and draw
        Pattern pattern = list.get(i);
        TextureAtlasSprite sprite = spriteGetter.apply(pattern.getTexture());
        blit(matrices, x, y, 100, 16, 16, sprite);
    }
}
Also used : Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.resources.ResourceLocation)

Aggregations

Pattern (slimeknights.tconstruct.library.recipe.partbuilder.Pattern)11 Test (org.junit.jupiter.api.Test)6 BaseMcTest (slimeknights.tconstruct.test.BaseMcTest)6 FriendlyByteBuf (net.minecraft.network.FriendlyByteBuf)3 ResourceLocation (net.minecraft.resources.ResourceLocation)3 JsonObject (com.google.gson.JsonObject)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 Ingredient (net.minecraft.world.item.crafting.Ingredient)2 JsonDeserializationContext (com.google.gson.JsonDeserializationContext)1 IGuiItemStackGroup (mezz.jei.api.gui.ingredient.IGuiItemStackGroup)1 Slot (net.minecraft.world.inventory.Slot)1 ItemStack (net.minecraft.world.item.ItemStack)1 ModifierEntry (slimeknights.tconstruct.library.modifiers.ModifierEntry)1 IInventoryModifier (slimeknights.tconstruct.library.tools.capability.ToolInventoryCapability.IInventoryModifier)1