Search in sources :

Example 6 with FenceType

use of binnie.extratrees.blocks.decor.FenceType 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)

Example 7 with FenceType

use of binnie.extratrees.blocks.decor.FenceType in project Binnie by ForestryMC.

the class MultiFenceRecipeRegistryPlugin method getRecipeWrappers.

@Override
public <T extends IRecipeWrapper> List<T> getRecipeWrappers(IRecipeCategory<T> recipeCategory) {
    if (!recipeCategory.getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
        return Collections.emptyList();
    }
    if (recipes.isEmpty()) {
        for (MultiFenceRecipePattern pattern : MultiFenceRecipePattern.VALUES) {
            recipes.add(new MultiFenceRecipeSizeWrapper(pattern));
        }
        for (FenceType fenceType : FenceType.getValues()) {
            recipes.add(new MultiFenceRecipeEmbeddedWrapper(fenceType));
            recipes.add(new MultiFenceRecipeSolidWrapper(fenceType));
        }
    }
    return (List<T>) recipes;
}
Also used : MultiFenceRecipePattern(binnie.extratrees.blocks.decor.MultiFenceRecipePattern) FenceType(binnie.extratrees.blocks.decor.FenceType) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with FenceType

use of binnie.extratrees.blocks.decor.FenceType in project Binnie by ForestryMC.

the class ModelMultiFence method bakeBlockModel.

private void bakeBlockModel(BlockMultiFence block, AABBModelBaker modelBaker, Key key) {
    float minPostPos = 0.5f - POST_WIDGTH / 2.0f;
    float maxPostPos = 0.5f + POST_WIDGTH / 2.0f;
    int meta = key.meta;
    FenceType fenceType = key.type;
    TextureAtlasSprite primarySprite = block.getSprite(meta, false);
    TextureAtlasSprite secondarySprite = block.getSprite(meta, true);
    modelBaker.setModelBounds(new AxisAlignedBB(minPostPos, 0.0, minPostPos, maxPostPos, POST_HEIGHT, maxPostPos));
    modelBaker.addBlockModel(null, primarySprite, 0);
    boolean connectNegX = key.west;
    boolean connectPosX = key.east;
    boolean connectNegZ = key.north;
    boolean connectPosZ = key.south;
    boolean connectAnyX = connectNegX || connectPosX;
    boolean connectAnyZ = connectNegZ || connectPosZ;
    if (!connectAnyX && !connectAnyZ) {
        connectAnyX = true;
    }
    minPostPos = 7.0f * SCALE;
    maxPostPos = 9.0f * SCALE;
    float barMinY = 12.0f * SCALE;
    float barMaxY = 15.0f * SCALE;
    float minX = connectNegX ? 0.0f : minPostPos;
    float maxX = connectPosX ? 1.0f : maxPostPos;
    float minZ = connectNegZ ? 0.0f : minPostPos;
    float maxZ = connectPosZ ? 1.0f : maxPostPos;
    boolean renderBottom = true;
    if (fenceType.getSize() == 2) {
        barMaxY -= 5.0f * SCALE;
        barMinY -= 5.0f * SCALE;
    }
    if (fenceType.isSolid()) {
        renderBottom = false;
        if (fenceType.getSize() == 0) {
            barMinY = 6.0f * SCALE;
        } else {
            barMinY = SCALE;
        }
    }
    float totalMaxY = barMaxY;
    if (connectAnyX) {
        modelBaker.setModelBounds(new AxisAlignedBB(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos));
        modelBaker.addBlockModel(null, secondarySprite, 0);
    }
    if (connectAnyZ) {
        modelBaker.setModelBounds(new AxisAlignedBB(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ));
        modelBaker.addBlockModel(null, secondarySprite, 0);
    }
    if (renderBottom) {
        barMinY -= 6.0f * SCALE;
        barMaxY -= 6.0f * SCALE;
        if (fenceType.getSize() == 1) {
            barMinY += SCALE;
        }
        if (connectAnyX) {
            modelBaker.setModelBounds(new AxisAlignedBB(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos));
            modelBaker.addBlockModel(null, secondarySprite, 0);
        }
        if (connectAnyZ) {
            modelBaker.setModelBounds(new AxisAlignedBB(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ));
            modelBaker.addBlockModel(null, secondarySprite, 0);
        }
        if (fenceType.getSize() == 1) {
            barMinY -= 6.0f * SCALE;
            barMaxY -= 6.0f * SCALE;
            barMaxY += SCALE;
            if (connectAnyX) {
                modelBaker.setModelBounds(new AxisAlignedBB(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos));
                modelBaker.addBlockModel(null, secondarySprite, 0);
            }
            if (connectAnyZ) {
                modelBaker.setModelBounds(new AxisAlignedBB(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ));
                modelBaker.addBlockModel(null, secondarySprite, 0);
            }
        }
    }
    float totalMinY = barMinY;
    if (fenceType.isEmbossed()) {
        minPostPos -= (float) (SCALE - 0.25 * SCALE);
        maxPostPos += (float) (SCALE - 0.25 * SCALE);
        float minY = totalMinY + 2.0f * SCALE;
        float maxY = totalMaxY - 2.0f * SCALE;
        if (fenceType.getSize() == 1 && !fenceType.isSolid()) {
            minY = 6.0f * SCALE;
            maxY = 10.0f * SCALE;
        } else if (fenceType.getSize() == 0 && fenceType.isSolid()) {
            minY -= 4.0f * SCALE;
            maxY -= 4.0f * SCALE;
        } else if (fenceType.getSize() == 2 && fenceType.isSolid()) {
            minY += 4.0f * SCALE;
            maxY += 4.0f * SCALE;
        }
        if (connectAnyX) {
            modelBaker.setModelBounds(new AxisAlignedBB(minX, minY, minPostPos, maxX, maxY, maxPostPos));
            modelBaker.addBlockModel(null, primarySprite, 0);
        }
        if (connectAnyZ) {
            modelBaker.setModelBounds(new AxisAlignedBB(minPostPos, minY, minZ, maxPostPos, maxY, maxZ));
            modelBaker.addBlockModel(null, primarySprite, 0);
        }
    }
    modelBaker.setParticleSprite(primarySprite);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FenceType(binnie.extratrees.blocks.decor.FenceType)

Aggregations

FenceType (binnie.extratrees.blocks.decor.FenceType)8 ItemStack (net.minecraft.item.ItemStack)5 IPlankType (binnie.extratrees.wood.planks.IPlankType)4 ArrayList (java.util.ArrayList)4 List (java.util.List)3 FenceDescription (binnie.extratrees.blocks.decor.FenceDescription)2 MultiFenceRecipePattern (binnie.extratrees.blocks.decor.MultiFenceRecipePattern)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)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 IRecipeWrapper (mezz.jei.api.recipe.IRecipeWrapper)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 FluidStack (net.minecraftforge.fluids.FluidStack)1