Search in sources :

Example 1 with Container

use of net.dries007.tfc.common.container.Container in project TerraFirmaCraft by TerraFirmaCraft.

the class PotBlockEntity method handleCooking.

@Override
protected void handleCooking() {
    if (isBoiling()) {
        assert cachedRecipe != null;
        if (boilingTicks < cachedRecipe.getDuration()) {
            boilingTicks++;
            if (boilingTicks == 1)
                markForSync();
        } else {
            // Create output
            // Save the recipe here, as setting inventory will call setAndUpdateSlots, which will clear the cached recipe before output is created
            final PotRecipe recipe = cachedRecipe;
            final PotRecipe.Output output = recipe.getOutput(inventory);
            // Clear inputs
            inventory.tank.setFluid(FluidStack.EMPTY);
            for (int slot = SLOT_EXTRA_INPUT_START; slot <= SLOT_EXTRA_INPUT_END; slot++) {
                // Consume items, but set container items if they exist
                inventory.setStackInSlot(slot, inventory.getStackInSlot(slot).getContainerItem());
            }
            // Let the output handle filling into the empty pot
            output.onFinish(inventory);
            if (// Then, if we still have contents, save the output
            !output.isEmpty()) {
                this.output = output;
            }
            // Reset recipe progress
            cachedRecipe = null;
            boilingTicks = 0;
            updateCachedRecipe();
            markForSync();
        }
    } else {
        boilingTicks = 0;
    }
}
Also used : PotRecipe(net.dries007.tfc.common.recipes.PotRecipe)

Example 2 with Container

use of net.dries007.tfc.common.container.Container in project firmalife by eerussianguy.

the class FLGuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    Container container = getServerGuiElement(ID, player, world, x, y, z);
    Type type = Type.valueOf(ID);
    switch(type) {
        case KNAPPING_PUMPKIN:
            return new GuiKnapping(container, player, KnappingType.LEATHER, PUMPKIN_TEXTURE);
        default:
            return null;
    }
}
Also used : Container(net.minecraft.inventory.Container) KnappingType(net.dries007.tfc.api.recipes.knapping.KnappingType) GuiKnapping(net.dries007.tfc.client.gui.GuiKnapping)

Example 3 with Container

use of net.dries007.tfc.common.container.Container in project firmalife by eerussianguy.

the class FLGuiHandler method getServerGuiElement.

@Override
public Container getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    BlockPos pos = new BlockPos(x, y, z);
    ItemStack stack = player.getHeldItemMainhand();
    Type type = Type.valueOf(ID);
    switch(type) {
        case KNAPPING_PUMPKIN:
            return new ContainerKnapping(KnappingFL.PUMPKIN, player.inventory, stack.getItem() == Item.getItemFromBlock(BlocksFL.PUMPKIN_FRUIT) ? stack : player.getHeldItemOffhand());
        default:
            return null;
    }
}
Also used : KnappingType(net.dries007.tfc.api.recipes.knapping.KnappingType) BlockPos(net.minecraft.util.math.BlockPos) ContainerKnapping(net.dries007.tfc.objects.container.ContainerKnapping) ItemStack(net.minecraft.item.ItemStack)

Aggregations

KnappingType (net.dries007.tfc.api.recipes.knapping.KnappingType)2 GuiKnapping (net.dries007.tfc.client.gui.GuiKnapping)1 PotRecipe (net.dries007.tfc.common.recipes.PotRecipe)1 ContainerKnapping (net.dries007.tfc.objects.container.ContainerKnapping)1 Container (net.minecraft.inventory.Container)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1