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));
}
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));
}
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);
}
}
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;
}
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;
}
Aggregations