Search in sources :

Example 1 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project CommonCapabilities by CyclopsMC.

the class TestFluidStackComponentStorageWrapper method testExtractNoExtract.

@Test
public void testExtractNoExtract() {
    IFluidHandler storage = new FluidTank(1) {

        @Override
        public FluidStack drain(int maxDrain, FluidAction action) {
            return FluidStack.EMPTY;
        }
    };
    storage.fill(LAVA_10, IFluidHandler.FluidAction.EXECUTE);
    IngredientComponentStorageWrapperHandlerFluidStack.ComponentStorageWrapper wrapper = new IngredientComponentStorageWrapperHandlerFluidStack.ComponentStorageWrapper(IngredientComponents.FLUIDSTACK, storage);
    assertThat(eq(wrapper.extract(LAVA_10, FluidMatch.EXACT, false), FluidStack.EMPTY), is(true));
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) Test(org.junit.Test)

Example 2 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project CommonCapabilities by CyclopsMC.

the class TestFluidStackComponentStorageWrapper method testInsertFull.

@Test
public void testInsertFull() {
    IFluidHandler storage = new FluidTank(0);
    IngredientComponentStorageWrapperHandlerFluidStack.ComponentStorageWrapper wrapper = new IngredientComponentStorageWrapperHandlerFluidStack.ComponentStorageWrapper(IngredientComponents.FLUIDSTACK, storage);
    assertThat(eq(wrapper.insert(WATER_64, true), WATER_64), is(true));
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) Test(org.junit.Test)

Example 3 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project TinkersConstruct by SlimeKnights.

the class TankItem method appendHoverText.

@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
    if (stack.hasTag()) {
        FluidTank tank = getFluidTank(stack);
        if (tank.getFluidAmount() > 0) {
            tooltip.add(new TranslatableComponent(KEY_FLUID, tank.getFluid().getDisplayName()).withStyle(ChatFormatting.GRAY));
            int amount = tank.getFluidAmount();
            TooltipKey key = SafeClientAccess.getTooltipKey();
            if (tank.getCapacity() % FluidValues.INGOT != 0 || key == TooltipKey.SHIFT) {
                tooltip.add(new TranslatableComponent(KEY_MB, amount).withStyle(ChatFormatting.GRAY));
            } else {
                int ingots = amount / FluidValues.INGOT;
                int mb = amount % FluidValues.INGOT;
                if (mb == 0) {
                    tooltip.add(new TranslatableComponent(KEY_INGOTS, ingots).withStyle(ChatFormatting.GRAY));
                } else {
                    tooltip.add(new TranslatableComponent(KEY_MIXED, ingots, mb).withStyle(ChatFormatting.GRAY));
                }
                if (key != TooltipKey.UNKNOWN) {
                    tooltip.add(FluidTooltipHandler.HOLD_SHIFT);
                }
            }
        }
    } else {
        super.appendHoverText(stack, worldIn, tooltip, flagIn);
    }
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TooltipKey(slimeknights.tconstruct.library.utils.TooltipKey)

Example 4 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project TinkersConstruct by SlimeKnights.

the class TankItemFluidHandler method drain.

@Nonnull
@Override
public FluidStack drain(int maxDrain, FluidAction action) {
    FluidTank tank = getTank();
    FluidStack didDrain = tank.drain(maxDrain, action);
    if (!didDrain.isEmpty() && action.execute()) {
        updateContainer(tank);
    }
    return didDrain;
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) FluidStack(net.minecraftforge.fluids.FluidStack) Nonnull(javax.annotation.Nonnull)

Example 5 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project TinkersConstruct by SlimeKnights.

the class TankItemFluidHandler method drain.

@Nonnull
@Override
public FluidStack drain(FluidStack resource, FluidAction action) {
    FluidTank tank = getTank();
    FluidStack didDrain = tank.drain(resource, action);
    if (!didDrain.isEmpty() && action.execute()) {
        updateContainer(tank);
    }
    return didDrain;
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) FluidStack(net.minecraftforge.fluids.FluidStack) Nonnull(javax.annotation.Nonnull)

Aggregations

FluidTank (net.minecraftforge.fluids.capability.templates.FluidTank)35 FluidStack (net.minecraftforge.fluids.FluidStack)20 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)8 ItemStack (net.minecraft.world.item.ItemStack)7 BlockPos (net.minecraft.core.BlockPos)6 Direction (net.minecraft.core.Direction)6 ComponentInventory (electrodynamics.prefab.tile.components.type.ComponentInventory)5 CompoundTag (net.minecraft.nbt.CompoundTag)5 ArrayList (java.util.ArrayList)4 BucketItem (net.minecraft.world.item.BucketItem)4 Level (net.minecraft.world.level.Level)4 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)4 ComponentDirection (electrodynamics.prefab.tile.components.type.ComponentDirection)3 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 ItemStack (net.minecraft.item.ItemStack)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 AABB (net.minecraft.world.phys.AABB)3 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)2 Iterate (com.simibubi.create.foundation.utility.Iterate)2