Search in sources :

Example 1 with CustomWoodType

use of com.infinityraider.agricraft.utility.CustomWoodType in project AgriCraft by AgriCraft.

the class CustomWoodShapedRecipe method matches.

@Override
public boolean matches(InventoryCrafting ic, World world) {
    final Optional<CustomWoodType> material = inferMaterial(ic);
    if (!material.isPresent()) {
        return false;
    }
    for (int r = 0; r < 3; r++) {
        for (int c = 0; c < 3; c++) {
            final FuzzyStack expected = layout.get(r, c);
            final ItemStack input = ic.getStackInRowAndColumn(r, c);
            final Optional<CustomWoodType> inputMaterial = CustomWoodTypeRegistry.getFromStack(input);
            if (inputMaterial.isPresent() && !material.equals(inputMaterial)) {
                return false;
            } else if (!Objects.equals(input, expected)) {
                return false;
            }
        }
    }
    return true;
}
Also used : FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType) ItemStack(net.minecraft.item.ItemStack)

Example 2 with CustomWoodType

use of com.infinityraider.agricraft.utility.CustomWoodType in project AgriCraft by AgriCraft.

the class RenderSprinkler method renderWorldBlockStatic.

@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockSprinkler block, EnumFacing side) {
    tessellator.translate(0, 4 * Constants.UNIT, 0);
    CustomWoodType type;
    if (state instanceof IExtendedBlockState) {
        type = ((IExtendedBlockState) state).getValue(AgriProperties.CUSTOM_WOOD_TYPE);
    } else {
        type = CustomWoodTypeRegistry.DEFAULT;
    }
    tessellator.drawScaledPrism(4, 8, 4, 12, 16, 12, type.getIcon());
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType)

Example 3 with CustomWoodType

use of com.infinityraider.agricraft.utility.CustomWoodType in project AgriCraft by AgriCraft.

the class CustomWoodShapedRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting ic) {
    final ItemStack result = super.getCraftingResult(ic);
    final Optional<CustomWoodType> material = inferMaterial(ic);
    if (material.isPresent()) {
        final NBTTagCompound tag = StackHelper.getTag(result);
        material.get().writeToNBT(tag);
        result.setTagCompound(tag);
    }
    return result;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType)

Example 4 with CustomWoodType

use of com.infinityraider.agricraft.utility.CustomWoodType in project AgriCraft by AgriCraft.

the class RenderBlockCustomWood method renderWorldBlockStatic.

@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, B block, EnumFacing side) {
    if (state instanceof IExtendedBlockState) {
        CustomWoodType type = ((IExtendedBlockState) state).getValue(AgriProperties.CUSTOM_WOOD_TYPE);
        this.renderWorldBlockWoodStatic(tessellator, (IExtendedBlockState) state, block, side, type.getIcon());
    }
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType)

Example 5 with CustomWoodType

use of com.infinityraider.agricraft.utility.CustomWoodType in project AgriCraft by AgriCraft.

the class ItemBlockCustomWood method getSubItems.

/**
 * Populates the sub-item list. This method allows getting sub blocks server side as well (no
 *
 * @side, like {@link #getSubItems(CreativeTabs, NonNullList)}). This method is marked for
 * cleaning.
 *
 * @param list the list to populate.
 */
public void getSubItems(List<ItemStack> list) {
    for (CustomWoodType type : CustomWoodTypeRegistry.getAllTypes()) {
        ItemStack variant = new ItemStack(this.block, 1, 0);
        variant.setTagCompound(type.writeToNBT(new NBTTagCompound()));
        list.add(variant);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

CustomWoodType (com.infinityraider.agricraft.utility.CustomWoodType)6 ItemStack (net.minecraft.item.ItemStack)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 FuzzyStack (com.infinityraider.agricraft.api.v1.util.FuzzyStack)1