Search in sources :

Example 1 with IPlankType

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

the class MultiFenceRecipeEmbeddedWrapper method getIngredients.

@Override
public void getIngredients(IIngredients ingredients) {
    List<ItemStack> fences = new ArrayList<>();
    List<ItemStack> planks = new ArrayList<>();
    List<ItemStack> outputFences = new ArrayList<>();
    if (plankType != null) {
        if (plankTypeSecondary == null) {
            for (Entry<IPlankType, ItemStack> secondary : WoodManager.getAllPlankStacks().entrySet()) {
                IPlankType plankTypeSecondary = secondary.getKey();
                if (plankType != plankTypeSecondary) {
                    planks.add(plankType.getStack(false));
                    fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), false), 1));
                    outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), true), 2));
                }
            }
        } else {
            planks.add(plankType.getStack(false));
            fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), false), 1));
            outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), true), 2));
        }
    } else {
        for (IPlankType plankTypeSecondary : WoodManager.getAllPlankTypes()) {
            for (IPlankType plankType : WoodManager.getAllPlankTypes()) {
                if (plankType != plankTypeSecondary) {
                    planks.add(plankType.getStack(false));
                    fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), false), 1));
                    outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), fenceType.isSolid(), true), 2));
                }
            }
        }
    }
    List<List<ItemStack>> itemInputs = new ArrayList<>();
    itemInputs.add(fences);
    itemInputs.add(planks);
    itemInputs.add(fences);
    List<List<ItemStack>> itemOutputs = new ArrayList<>();
    itemOutputs.add(outputFences);
    ingredients.setOutputLists(ItemStack.class, itemOutputs);
    ingredients.setInputLists(ItemStack.class, itemInputs);
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ArrayList(java.util.ArrayList) FenceType(binnie.extratrees.blocks.decor.FenceType) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IPlankType

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

the class PagePlanksOverview method onValueChanged.

@Override
public void onValueChanged(final ItemStack species) {
    this.deleteAllChildren();
    final WindowAbstractDatabase database = Window.get(this);
    IPoint size = getSize();
    new ControlText(this, new Area(0, 0, size.xPos(), 24), species.getDisplayName(), TextJustification.MIDDLE_CENTER);
    new ControlText(this, new Area(12, 24, size.xPos() - 24, 24), I18N.localise(DatabaseConstants.EXTRATREES_KEY + ".planks.use"), TextJustification.MIDDLE_LEFT);
    final IPlankType type = WoodManager.getPlankType(species);
    int x = 12;
    if (type != null) {
        final ItemStack fence = WoodManager.getFence(type, new FenceType(0), 1);
        final ItemStack gate = WoodManager.getGate(type);
        final ItemStack door = WoodManager.getDoor(type);
        if (!fence.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(fence);
            x += 22;
        }
        if (!gate.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(gate);
            x += 22;
        }
        if (!door.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(door);
            x += 22;
        }
    }
    final ControlText controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.MIDDLE_CENTER);
    final ControlText controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.BOTTOM_RIGHT);
    String desc = "";
    if (type != null) {
        desc = type.getDescription();
    }
    StringBuilder descBody = new StringBuilder("§o");
    String descSig = "";
    if (desc == null || desc.length() == 0) {
        descBody.append(I18N.localise(DatabaseConstants.KEY + ".nodescription"));
    } else {
        final String[] descStrings = desc.split("\\|");
        descBody.append(descStrings[0]);
        for (int i = 1; i < descStrings.length - 1; ++i) {
            descBody.append(' ').append(descStrings[i]);
        }
        if (descStrings.length > 1) {
            descSig += descStrings[descStrings.length - 1];
        }
    }
    controlDescription.setValue(descBody + "§r");
    controlSignature.setValue(descSig + "§r");
    final int descHeight = CraftGUI.RENDER.textHeight(controlDescription.getValue(), controlDescription.getSize().xPos());
    controlSignature.setPosition(new Point(controlSignature.getPosition().xPos(), controlDescription.getPosition().yPos() + descHeight + 10));
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IPlankType(binnie.extratrees.wood.planks.IPlankType) ControlText(binnie.core.gui.controls.ControlText) IPoint(binnie.core.api.gui.IPoint) FenceType(binnie.extratrees.blocks.decor.FenceType) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) Area(binnie.core.gui.geometry.Area) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IPlankType

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

the class MultiFenceRecipeSize method matches.

@Override
public boolean matches(final InventoryCrafting inv, final World world) {
    if (inv.getSizeInventory() != 9)
        return false;
    StringBuilder recipePattern = new StringBuilder();
    List<IPlankType> types = new ArrayList<>();
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        ItemStack stack = inv.getStackInSlot(i);
        boolean isEmpty = stack.isEmpty();
        IPlankType type;
        if (isEmpty) {
            type = null;
        } else {
            type = WoodManager.getPlankType(stack);
        }
        if (!isEmpty && type == null) {
            return false;
        }
        if (isEmpty) {
            recipePattern.append(' ');
        } else {
            if (!types.contains(type)) {
                types.add(type);
                if (types.size() > 2) {
                    return false;
                }
            }
            recipePattern.append(types.indexOf(type));
        }
    }
    if (types.isEmpty()) {
        return false;
    }
    for (MultiFenceRecipePattern pattern : MultiFenceRecipePattern.VALUES) {
        if (pattern.matches(recipePattern.toString()) && types.size() > 0 && pattern.getTypeCount() <= types.size()) {
            cached = pattern.createFence(types.get(0), types.get(pattern.getTypeCount() - 1));
            return true;
        }
    }
    this.cached = ItemStack.EMPTY;
    return false;
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IPlankType

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

the class MultiFenceRecipeEmbedded method matches.

@Override
public boolean matches(final InventoryCrafting inv, final World world) {
    for (int row = 0; row < 3; ++row) {
        ItemStack a = inv.getStackInSlot(row * 3);
        ItemStack b = inv.getStackInSlot(row * 3 + 1);
        ItemStack c = inv.getStackInSlot(row * 3 + 2);
        if (!a.isEmpty() && !b.isEmpty() && !c.isEmpty()) {
            FenceType type = WoodManager.getFenceType(a);
            FenceType typeSecond = WoodManager.getFenceType(c);
            if (type != null && typeSecond != null && type.equals(typeSecond)) {
                FenceDescription fenceDescription = WoodManager.getFenceDescription(a);
                if (fenceDescription != null) {
                    IPlankType descPlankType = fenceDescription.getPlankType();
                    IPlankType plankType = WoodManager.getPlankType(b);
                    if (descPlankType == plankType) {
                        this.cached = WoodManager.getFence(descPlankType, fenceDescription.getSecondaryPlankType(), new FenceType(type.getSize(), type.isSolid(), true), 2);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IPlankType

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

the class MultiFenceRecipeSolidWrapper method getIngredients.

@Override
public void getIngredients(IIngredients ingredients) {
    List<ItemStack> fences = new ArrayList<>();
    List<ItemStack> outputFences = new ArrayList<>();
    if (plankType != null) {
        if (plankTypeSecondary == null) {
            for (IPlankType plankTypeSecondary : WoodManager.getAllPlankTypes()) {
                if (plankType != plankTypeSecondary) {
                    fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), false, fenceType.isEmbossed()), 1));
                    outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), true, fenceType.isEmbossed()), 2));
                }
            }
        } else {
            fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), false, fenceType.isEmbossed()), 1));
            outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), true, fenceType.isEmbossed()), 2));
        }
    } else {
        for (IPlankType plankTypeSecondary : WoodManager.getAllPlankTypes()) {
            for (IPlankType plankType : WoodManager.getAllPlankTypes()) {
                if (plankType != plankTypeSecondary) {
                    fences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), false, fenceType.isEmbossed()), 1));
                    outputFences.add(WoodManager.getFence(plankType, plankTypeSecondary, new FenceType(fenceType.getSize(), true, fenceType.isEmbossed()), 2));
                }
            }
        }
    }
    List<List<ItemStack>> itemInputs = new ArrayList<>();
    itemInputs.add(fences);
    itemInputs.add(fences);
    itemInputs.add(fences);
    List<List<ItemStack>> itemOutputs = new ArrayList<>();
    itemOutputs.add(outputFences);
    ingredients.setOutputLists(ItemStack.class, itemOutputs);
    ingredients.setInputLists(ItemStack.class, itemInputs);
}
Also used : IPlankType(binnie.extratrees.wood.planks.IPlankType) ArrayList(java.util.ArrayList) FenceType(binnie.extratrees.blocks.decor.FenceType) List(java.util.List) ArrayList(java.util.ArrayList) 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