Search in sources :

Example 1 with BlockPackedIce

use of net.minecraft.block.BlockPackedIce in project Cavern2 by kegare.

the class RecipeChargeIceEquipment method matches.

@Override
public boolean matches(InventoryCrafting crafting, World world) {
    resultItem = ItemStack.EMPTY;
    if (!(crafting.getStackInRowAndColumn(1, 1).getItem() instanceof IIceEquipment)) {
        return false;
    }
    int ice = 0;
    for (int row = 0; row < 3; ++row) {
        for (int column = 0; column < 3; ++column) {
            if (row == 1 && column == 1) {
                continue;
            }
            ItemStack stack = crafting.getStackInRowAndColumn(row, column);
            if (!stack.isEmpty()) {
                Block block = Block.getBlockFromItem(stack.getItem());
                if (block == null) {
                    continue;
                }
                if (block instanceof BlockIce || block instanceof BlockPackedIce) {
                    if (row != 1 && column == 1 || row == 1 && column != 1) {
                        ++ice;
                    }
                } else if (row != 1 && column != 1) {
                    return false;
                }
            }
        }
    }
    if (ice >= 4) {
        resultItem = getResult(crafting);
        return true;
    }
    return false;
}
Also used : BlockIce(net.minecraft.block.BlockIce) IIceEquipment(cavern.api.IIceEquipment) BlockPackedIce(net.minecraft.block.BlockPackedIce) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 2 with BlockPackedIce

use of net.minecraft.block.BlockPackedIce in project Cavern2 by kegare.

the class RecipeChargeIceEquipment method getResult.

protected ItemStack getResult(InventoryCrafting crafting) {
    ItemStack result = crafting.getStackInRowAndColumn(1, 1).copy();
    int ice = 0;
    int packed = 0;
    for (int row = 0; row < 3; ++row) {
        for (int column = 0; column < 3; ++column) {
            if (row == 1 && column == 1) {
                continue;
            }
            ItemStack stack = crafting.getStackInRowAndColumn(row, column);
            if (!stack.isEmpty()) {
                Block block = Block.getBlockFromItem(stack.getItem());
                if (block == null) {
                    continue;
                }
                if (block instanceof BlockPackedIce) {
                    ++packed;
                } else if (block instanceof BlockIce) {
                    ++ice;
                }
            }
        }
    }
    if (result.isItemStackDamageable() && result.isItemDamaged()) {
        result.setItemDamage(0);
    } else {
        result = ((IIceEquipment) result.getItem()).addCharge(result, ice + packed * 9);
        result.getTagCompound().setBoolean("AfterIceCharge", true);
    }
    return result;
}
Also used : BlockIce(net.minecraft.block.BlockIce) BlockPackedIce(net.minecraft.block.BlockPackedIce) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Block (net.minecraft.block.Block)2 BlockIce (net.minecraft.block.BlockIce)2 BlockPackedIce (net.minecraft.block.BlockPackedIce)2 ItemStack (net.minecraft.item.ItemStack)2 IIceEquipment (cavern.api.IIceEquipment)1