Search in sources :

Example 6 with IPlankType

use of binnie.extratrees.wood.planks.IPlankType in project Binnie by ForestryMC.

the class BlockMultiFence method getDisplayName.

@Override
public String getDisplayName(ItemStack itemStack) {
    int meta = TileEntityMetadata.getItemDamage(itemStack);
    IPlankType typeFirst = this.getDescription(meta).getPlankType();
    IPlankType typeSecond = this.getDescription(meta).getSecondaryPlankType();
    boolean twoTypes = typeFirst != typeSecond;
    FenceType fenceType = this.getDescription(meta).getFenceType();
    return I18N.localise("extratrees.block.multifence" + (twoTypes ? "2" : "") + ".grammar", fenceType.getPrefix(), typeFirst.getDesignMaterialName(), typeSecond.getDesignMaterialName());
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType)

Example 7 with IPlankType

use of binnie.extratrees.wood.planks.IPlankType in project Binnie by ForestryMC.

the class MultiFenceRecipeSizeWrapper method getIngredients.

@Override
public void getIngredients(IIngredients ingredients) {
    int typeCount = pattern.getTypeCount();
    List<List<ItemStack>> types = NonNullList.create();
    if (this.plankType != null) {
        types.add(Collections.singletonList(plankType.getStack(false)));
    } else {
        List<ItemStack> planks = new ArrayList<>(WoodManager.getAllPlankStacks().values());
        Collections.shuffle(planks);
        types.add(planks);
    }
    if (typeCount > 1) {
        if (plankTypeSecond != null) {
            types.add(Collections.singletonList(plankTypeSecond.getStack(false)));
        } else {
            List<ItemStack> planks;
            if (plankType != null) {
                planks = new ArrayList<>(WoodManager.getAllPlankStacks(plankType));
            } else {
                planks = new ArrayList<>(WoodManager.getAllPlankStacks().values());
            }
            Collections.shuffle(planks);
            types.add(planks);
        }
    } else {
        types.add(types.get(0));
    }
    List<List<ItemStack>> itemInputs = NonNullList.withSize(9, NonNullList.create());
    for (int p = 0; p < 3; p++) {
        String recipePattern = this.recipePattern[p];
        for (int index = 0; index < 3; index++) {
            char c = recipePattern.charAt(index);
            if (c == '0') {
                itemInputs.set(p * 3 + index, types.get(0));
            } else if (c == '1') {
                itemInputs.set(p * 3 + index, types.get(1));
            } else {
                itemInputs.set(p * 3 + index, NonNullList.withSize(1, ItemStack.EMPTY));
            }
        }
    }
    List<List<ItemStack>> itemOutputs = new ArrayList<>();
    int size = typeCount > 1 || plankType == null ? types.get(1).size() : 1;
    List<ItemStack> outputs = new ArrayList<>();
    itemOutputs.add(outputs);
    for (int i = 0; i < size; i++) {
        IPlankType plankType = this.plankType;
        if (plankType == null) {
            ItemStack item = types.get(0).get(i);
            plankType = WoodManager.getPlankType(item);
        }
        IPlankType plankTypeSecond = this.plankTypeSecond;
        if (plankTypeSecond == null) {
            ItemStack itemSecond = types.get(1).get(i);
            plankTypeSecond = WoodManager.getPlankType(itemSecond);
        }
        outputs.add(pattern.createFence(plankType, plankTypeSecond));
    }
    ingredients.setOutputLists(ItemStack.class, itemOutputs);
    ingredients.setInputLists(ItemStack.class, itemInputs);
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ArrayList(java.util.ArrayList) List(java.util.List) NonNullList(net.minecraft.util.NonNullList) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IPlankType

use of binnie.extratrees.wood.planks.IPlankType in project Binnie by ForestryMC.

the class MultiFenceRecipeRegistryPlugin method getRecipeCategoryUids.

@Override
public <V> List<String> getRecipeCategoryUids(IFocus<V> focus) {
    V ingredient = focus.getValue();
    if (!(ingredient instanceof ItemStack)) {
        return Collections.emptyList();
    }
    ItemStack itemStack = (ItemStack) ingredient;
    FenceDescription desc;
    switch(focus.getMode()) {
        case INPUT:
            desc = WoodManager.getFenceDescription(itemStack);
            IPlankType plankType = WoodManager.getPlankType(itemStack);
            if (plankType != null || desc != null && (!desc.getFenceType().isEmbossed() || !desc.getFenceType().isEmbossed())) {
                return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
            }
            return Collections.emptyList();
        case OUTPUT:
            desc = WoodManager.getFenceDescription(itemStack);
            if (desc != null) {
                return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
            }
            return Collections.emptyList();
        default:
            return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
    }
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) FenceDescription(binnie.extratrees.blocks.decor.FenceDescription) ItemStack(net.minecraft.item.ItemStack)

Example 9 with IPlankType

use of binnie.extratrees.wood.planks.IPlankType in project Binnie by ForestryMC.

the class MultiFenceRecipeRegistryPlugin method getRecipes.

private List<IRecipeWrapper> getRecipes(IFocus<ItemStack> focus) {
    ItemStack ingredient = focus.getValue();
    List<IRecipeWrapper> recipes = new ArrayList<>();
    if (focus.getMode() == Mode.INPUT) {
        IPlankType plankType = WoodManager.getPlankType(ingredient);
        if (plankType != null) {
            for (MultiFenceRecipePattern pattern : MultiFenceRecipePattern.VALUES) {
                recipes.add(new MultiFenceRecipeSizeWrapper(pattern, plankType));
            }
            for (int size = 0; size < 3; size++) {
                for (final boolean solid : new boolean[] { false, true }) {
                    recipes.add(new MultiFenceRecipeEmbeddedWrapper(plankType, new FenceType(size, solid, false)));
                }
            }
        } else {
            FenceDescription desc = WoodManager.getFenceDescription(ingredient);
            if (desc != null) {
                if (!desc.getFenceType().isEmbossed()) {
                    recipes.add(new MultiFenceRecipeEmbeddedWrapper(desc));
                }
                if (!desc.getFenceType().isSolid()) {
                    recipes.add(new MultiFenceRecipeSolidWrapper(desc));
                }
            }
        }
    } else {
        FenceDescription desc = WoodManager.getFenceDescription(ingredient);
        if (desc != null) {
            int size = desc.getFenceType().getSize();
            recipes.add(new MultiFenceRecipeSizeWrapper(MultiFenceRecipePattern.VALUES[size * 2], desc.getPlankType(), desc.getSecondaryPlankType()));
            recipes.add(new MultiFenceRecipeSizeWrapper(MultiFenceRecipePattern.VALUES[size * 2 + 1], desc.getPlankType(), desc.getSecondaryPlankType()));
            if (desc.getFenceType().isEmbossed()) {
                recipes.add(new MultiFenceRecipeEmbeddedWrapper(desc));
            }
            if (desc.getFenceType().isSolid()) {
                recipes.add(new MultiFenceRecipeSolidWrapper(desc));
            }
        }
    }
    return recipes;
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ArrayList(java.util.ArrayList) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) FenceType(binnie.extratrees.blocks.decor.FenceType) FenceDescription(binnie.extratrees.blocks.decor.FenceDescription) MultiFenceRecipePattern(binnie.extratrees.blocks.decor.MultiFenceRecipePattern) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IPlankType (binnie.extratrees.wood.planks.IPlankType)9 ItemStack (net.minecraft.item.ItemStack)8 ArrayList (java.util.ArrayList)5 FenceType (binnie.extratrees.blocks.decor.FenceType)4 List (java.util.List)3 FenceDescription (binnie.extratrees.blocks.decor.FenceDescription)2 IPoint (binnie.core.api.gui.IPoint)1 ControlText (binnie.core.gui.controls.ControlText)1 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)1 Area (binnie.core.gui.geometry.Area)1 Point (binnie.core.gui.geometry.Point)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 MultiFenceRecipePattern (binnie.extratrees.blocks.decor.MultiFenceRecipePattern)1 IRecipeWrapper (mezz.jei.api.recipe.IRecipeWrapper)1 NonNullList (net.minecraft.util.NonNullList)1