Search in sources :

Example 1 with ItemLiquidContainer

use of forestry.core.items.ItemLiquidContainer in project ForestryMC by ForestryMC.

the class LiquidHelper method injectLiquidContainer.

public static void injectLiquidContainer(Fluids fluid, ItemStack filled) {
    Item item = filled.getItem();
    if (item.getContainerItem() instanceof ItemBucket) {
        LiquidHelper.injectLiquidContainer(fluid, Defaults.BUCKET_VOLUME, filled, new ItemStack(Items.bucket));
        return;
    } else if (item instanceof ItemLiquidContainer) {
        ItemLiquidContainer liquidContainer = (ItemLiquidContainer) item;
        switch(liquidContainer.getType()) {
            case CAN:
                LiquidHelper.injectTinContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.canEmpty.getItemStack());
                return;
            case CAPSULE:
                LiquidHelper.injectWaxContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.waxCapsule.getItemStack());
                return;
            case REFRACTORY:
                LiquidHelper.injectRefractoryContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.refractoryEmpty.getItemStack());
                return;
        }
    }
    Proxies.log.warning("Unable to inject liquid container: " + filled);
}
Also used : Item(net.minecraft.item.Item) ForestryItem(forestry.core.config.ForestryItem) ItemLiquidContainer(forestry.core.items.ItemLiquidContainer) ItemStack(net.minecraft.item.ItemStack) ItemBucket(net.minecraft.item.ItemBucket)

Example 2 with ItemLiquidContainer

use of forestry.core.items.ItemLiquidContainer in project ForestryMC by ForestryMC.

the class PluginFluids method registerItems.

@Override
public void registerItems() {
    for (EnumContainerType type : EnumContainerType.values()) {
        Item emptyContainer = new ItemLiquidContainer(type, Blocks.air, null);
        switch(type) {
            case CAN:
                ForestryItem.canEmpty.registerItem(emptyContainer, "canEmpty");
                break;
            case CAPSULE:
                ForestryItem.waxCapsule.registerItem(emptyContainer, "waxCapsule");
                break;
            case REFRACTORY:
                ForestryItem.refractoryEmpty.registerItem(emptyContainer, "refractoryEmpty");
                break;
        }
        for (Fluids fluidType : Fluids.values()) {
            ForestryItem container = fluidType.getContainerForType(type);
            if (container == null) {
                continue;
            }
            ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor());
            fluidType.setProperties(liquidContainer);
            container.registerItem(liquidContainer, container.toString());
        }
    }
}
Also used : Item(net.minecraft.item.Item) ForestryItem(forestry.core.config.ForestryItem) ItemLiquidContainer(forestry.core.items.ItemLiquidContainer) EnumContainerType(forestry.core.items.ItemLiquidContainer.EnumContainerType) Fluids(forestry.core.fluids.Fluids) ForestryItem(forestry.core.config.ForestryItem)

Aggregations

ForestryItem (forestry.core.config.ForestryItem)2 ItemLiquidContainer (forestry.core.items.ItemLiquidContainer)2 Item (net.minecraft.item.Item)2 Fluids (forestry.core.fluids.Fluids)1 EnumContainerType (forestry.core.items.ItemLiquidContainer.EnumContainerType)1 ItemBucket (net.minecraft.item.ItemBucket)1 ItemStack (net.minecraft.item.ItemStack)1