mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
[1.19.x] Fluid API Overhaul (#8695)
This commit is contained in:
1 parent
e386229b66
commit
2a05c7c01d
67 files changed
+3856
-740
No files matched your search
@@ -94,7 +94,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
return super.execute(source, stack);
|
||||
}
|
||||
|
||||
FluidStack fluidStack = fluidHandler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.EXECUTE);
|
||||
FluidStack fluidStack = fluidHandler.drain(FluidType.BUCKET_VOLUME, IFluidHandler.FluidAction.EXECUTE);
|
||||
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
|
||||
BlockPos blockpos = source.getPos().relative(dispenserFacing);
|
||||
FluidActionResult result = FluidUtil.tryPlaceFluid(null, source.getLevel(), InteractionHand.MAIN_HAND, blockpos, stack, fluidStack);
|
||||
|
||||
@@ -1,446 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Minecraft Forge Fluid Implementation
|
||||
*
|
||||
* This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid
|
||||
* and contains its general properties.
|
||||
*
|
||||
* These properties do not have inherent gameplay mechanics - they are provided so that mods may
|
||||
* choose to take advantage of them.
|
||||
*
|
||||
* Fluid implementations are not required to actively use these properties, nor are objects
|
||||
* interfacing with fluids required to make use of them, but it is encouraged.
|
||||
*
|
||||
* The default values can be used as a reference point for mods adding fluids such as oil or heavy
|
||||
* water.
|
||||
*
|
||||
*/
|
||||
public class FluidAttributes
|
||||
{
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
|
||||
private String translationKey;
|
||||
|
||||
private final ResourceLocation stillTexture;
|
||||
private final ResourceLocation flowingTexture;
|
||||
|
||||
@Nullable
|
||||
private final ResourceLocation overlayTexture;
|
||||
|
||||
private final SoundEvent fillSound;
|
||||
private final SoundEvent emptySound;
|
||||
|
||||
/**
|
||||
* The light level emitted by this fluid.
|
||||
*
|
||||
* Default value is 0, as most fluids do not actively emit light.
|
||||
*/
|
||||
private final int luminosity;
|
||||
|
||||
/**
|
||||
* Density of the fluid - completely arbitrary; negative density indicates that the fluid is
|
||||
* lighter than air.
|
||||
*
|
||||
* Default value is approximately the real-life density of water in kg/m^3.
|
||||
*/
|
||||
private final int density;
|
||||
|
||||
/**
|
||||
* Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is
|
||||
* hotter than air.
|
||||
*
|
||||
* Default value is approximately the real-life room temperature of water in degrees Kelvin.
|
||||
*/
|
||||
private final int temperature;
|
||||
|
||||
/**
|
||||
* Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not
|
||||
* permissible.
|
||||
*
|
||||
* Default value is approximately the real-life density of water in m/s^2 (x10^-3).
|
||||
*
|
||||
* Higher viscosity means that a fluid flows more slowly, like molasses.
|
||||
* Lower viscosity means that a fluid flows more quickly, like helium.
|
||||
*
|
||||
*/
|
||||
private final int viscosity;
|
||||
|
||||
/**
|
||||
* This indicates if the fluid is gaseous.
|
||||
*
|
||||
* Generally this is associated with negative density fluids.
|
||||
*/
|
||||
private final boolean isGaseous;
|
||||
|
||||
/**
|
||||
* The rarity of the fluid.
|
||||
*
|
||||
* Used primarily in tool tips.
|
||||
*/
|
||||
private final Rarity rarity;
|
||||
|
||||
/**
|
||||
* Color used by universal bucket and the ModelFluid baked model.
|
||||
* Note that this int includes the alpha so converting this to RGB with alpha would be
|
||||
* float r = ((color >> 16) & 0xFF) / 255f; // red
|
||||
* float g = ((color >> 8) & 0xFF) / 255f; // green
|
||||
* float b = ((color >> 0) & 0xFF) / 255f; // blue
|
||||
* float a = ((color >> 24) & 0xFF) / 255f; // alpha
|
||||
*/
|
||||
private final int color;
|
||||
|
||||
protected FluidAttributes(Builder builder, Fluid fluid)
|
||||
{
|
||||
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeDescriptionId("fluid", ForgeRegistries.FLUIDS.getKey(fluid));
|
||||
this.stillTexture = builder.stillTexture;
|
||||
this.flowingTexture = builder.flowingTexture;
|
||||
this.overlayTexture = builder.overlayTexture;
|
||||
this.color = builder.color;
|
||||
this.fillSound = builder.fillSound;
|
||||
this.emptySound = builder.emptySound;
|
||||
this.luminosity = builder.luminosity;
|
||||
this.temperature = builder.temperature;
|
||||
this.viscosity = builder.viscosity;
|
||||
this.density = builder.density;
|
||||
this.isGaseous = builder.isGaseous;
|
||||
this.rarity = builder.rarity;
|
||||
}
|
||||
|
||||
public ItemStack getBucket(FluidStack stack)
|
||||
{
|
||||
return new ItemStack(stack.getFluid().getBucket());
|
||||
}
|
||||
|
||||
public BlockState getBlock(BlockAndTintGetter reader, BlockPos pos, FluidState state)
|
||||
{
|
||||
return state.createLegacyBlock();
|
||||
}
|
||||
|
||||
public FluidState getStateForPlacement(BlockAndTintGetter reader, BlockPos pos, FluidStack state)
|
||||
{
|
||||
return state.getFluid().defaultFluidState();
|
||||
}
|
||||
|
||||
public final boolean canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidState state)
|
||||
{
|
||||
return !getBlock(reader, pos, state).isAir();
|
||||
}
|
||||
|
||||
public final boolean canBePlacedInWorld(BlockAndTintGetter reader, BlockPos pos, FluidStack state)
|
||||
{
|
||||
return !getBlock(reader, pos, getStateForPlacement(reader, pos, state)).isAir();
|
||||
}
|
||||
|
||||
public final boolean isLighterThanAir()
|
||||
{
|
||||
return this.density <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this fluid should vaporize in dimensions where water vaporizes when placed.
|
||||
* To preserve the intentions of vanilla, fluids that can turn lava into obsidian should vaporize.
|
||||
* This prevents players from making the nether safe with a single bucket.
|
||||
* Based on {@link BucketItem#emptyContents(Player, Level, BlockPos, BlockHitResult)}
|
||||
*
|
||||
* @param fluidStack The fluidStack is trying to be placed.
|
||||
* @return true if this fluid should vaporize in dimensions where water vaporizes when placed.
|
||||
*/
|
||||
public boolean doesVaporize(BlockAndTintGetter reader, BlockPos pos, FluidStack fluidStack)
|
||||
{
|
||||
BlockState blockstate = getBlock(reader, pos, getStateForPlacement(reader, pos, fluidStack));
|
||||
if (blockstate == null)
|
||||
return false;
|
||||
return blockstate.getMaterial() == net.minecraft.world.level.material.Material.WATER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called instead of placing the fluid block if {@link DimensionType#ultraWarm()} and {@link #doesVaporize(BlockAndTintGetter, BlockPos, FluidStack)} are true.
|
||||
* Override this to make your explosive liquid blow up instead of the default smoke, etc.
|
||||
* Based on {@link BucketItem#emptyContents(Player, Level, BlockPos, BlockHitResult)}
|
||||
*
|
||||
* @param player Player who tried to place the fluid. May be null for blocks like dispensers.
|
||||
* @param worldIn World to vaporize the fluid in.
|
||||
* @param pos The position in the world the fluid block was going to be placed.
|
||||
* @param fluidStack The fluidStack that was going to be placed.
|
||||
*/
|
||||
public void vaporize(@Nullable Player player, Level worldIn, BlockPos pos, FluidStack fluidStack)
|
||||
{
|
||||
worldIn.playSound(player, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (worldIn.random.nextFloat() - worldIn.random.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
worldIn.addAlwaysVisibleParticle(ParticleTypes.LARGE_SMOKE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the localized name of this fluid.
|
||||
*/
|
||||
public Component getDisplayName(FluidStack stack)
|
||||
{
|
||||
return Component.translatable(getTranslationKey(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* A FluidStack sensitive version of getTranslationKey
|
||||
*/
|
||||
public String getTranslationKey(FluidStack stack)
|
||||
{
|
||||
return this.getTranslationKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation key of this fluid.
|
||||
*/
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return this.translationKey;
|
||||
}
|
||||
|
||||
/* Default Accessors */
|
||||
public final int getLuminosity()
|
||||
{
|
||||
return this.luminosity;
|
||||
}
|
||||
|
||||
public final int getDensity()
|
||||
{
|
||||
return this.density;
|
||||
}
|
||||
|
||||
public final int getTemperature()
|
||||
{
|
||||
return this.temperature;
|
||||
}
|
||||
|
||||
public final int getViscosity()
|
||||
{
|
||||
return this.viscosity;
|
||||
}
|
||||
|
||||
public final boolean isGaseous()
|
||||
{
|
||||
return this.isGaseous;
|
||||
}
|
||||
|
||||
public Rarity getRarity()
|
||||
{
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
public ResourceLocation getStillTexture()
|
||||
{
|
||||
return stillTexture;
|
||||
}
|
||||
|
||||
public ResourceLocation getFlowingTexture()
|
||||
{
|
||||
return flowingTexture;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getOverlayTexture()
|
||||
{
|
||||
return overlayTexture;
|
||||
}
|
||||
|
||||
public SoundEvent getFillSound()
|
||||
{
|
||||
return fillSound;
|
||||
}
|
||||
|
||||
public SoundEvent getEmptySound()
|
||||
{
|
||||
return emptySound;
|
||||
}
|
||||
|
||||
/* Stack-based Accessors */
|
||||
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
|
||||
public int getDensity(FluidStack stack){ return getDensity(); }
|
||||
public int getTemperature(FluidStack stack){ return getTemperature(); }
|
||||
public int getViscosity(FluidStack stack){ return getViscosity(); }
|
||||
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
|
||||
public Rarity getRarity(FluidStack stack){ return getRarity(); }
|
||||
public int getColor(FluidStack stack){ return getColor(); }
|
||||
public ResourceLocation getStillTexture(FluidStack stack) { return getStillTexture(); }
|
||||
public ResourceLocation getFlowingTexture(FluidStack stack) { return getFlowingTexture(); }
|
||||
public SoundEvent getFillSound(FluidStack stack) { return getFillSound(); }
|
||||
public SoundEvent getEmptySound(FluidStack stack) { return getEmptySound(); }
|
||||
|
||||
/* World-based Accessors */
|
||||
public int getLuminosity(BlockAndTintGetter level, BlockPos pos){ return getLuminosity(); }
|
||||
public int getDensity(BlockAndTintGetter level, BlockPos pos){ return getDensity(); }
|
||||
public int getTemperature(BlockAndTintGetter level, BlockPos pos){ return getTemperature(); }
|
||||
public int getViscosity(BlockAndTintGetter level, BlockPos pos){ return getViscosity(); }
|
||||
public boolean isGaseous(BlockAndTintGetter level, BlockPos pos){ return isGaseous(); }
|
||||
public Rarity getRarity(BlockAndTintGetter level, BlockPos pos){ return getRarity(); }
|
||||
public int getColor(BlockAndTintGetter level, BlockPos pos){ return getColor(); }
|
||||
public ResourceLocation getStillTexture(BlockAndTintGetter level, BlockPos pos) { return getStillTexture(); }
|
||||
public ResourceLocation getFlowingTexture(BlockAndTintGetter level, BlockPos pos) { return getFlowingTexture(); }
|
||||
public SoundEvent getFillSound(BlockAndTintGetter level, BlockPos pos) { return getFillSound(); }
|
||||
public SoundEvent getEmptySound(BlockAndTintGetter level, BlockPos pos) { return getEmptySound(); }
|
||||
|
||||
public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
||||
return new Builder(stillTexture, flowingTexture, FluidAttributes::new);
|
||||
}
|
||||
|
||||
public Stream<ResourceLocation> getTextures()
|
||||
{
|
||||
if (overlayTexture != null)
|
||||
return Stream.of(stillTexture, flowingTexture, overlayTexture);
|
||||
return Stream.of(stillTexture, flowingTexture);
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private final ResourceLocation stillTexture;
|
||||
private final ResourceLocation flowingTexture;
|
||||
private ResourceLocation overlayTexture;
|
||||
private int color = 0xFFFFFFFF;
|
||||
private String translationKey;
|
||||
private SoundEvent fillSound;
|
||||
private SoundEvent emptySound;
|
||||
private int luminosity = 0;
|
||||
private int density = 1000;
|
||||
private int temperature = 300;
|
||||
private int viscosity = 1000;
|
||||
private boolean isGaseous;
|
||||
private Rarity rarity = Rarity.COMMON;
|
||||
private BiFunction<Builder,Fluid,FluidAttributes> factory;
|
||||
|
||||
protected Builder(ResourceLocation stillTexture, ResourceLocation flowingTexture, BiFunction<Builder,Fluid,FluidAttributes> factory) {
|
||||
this.factory = factory;
|
||||
this.stillTexture = stillTexture;
|
||||
this.flowingTexture = flowingTexture;
|
||||
}
|
||||
|
||||
public final Builder translationKey(String translationKey)
|
||||
{
|
||||
this.translationKey = translationKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder color(int color)
|
||||
{
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder overlay(ResourceLocation texture)
|
||||
{
|
||||
overlayTexture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder luminosity(int luminosity)
|
||||
{
|
||||
this.luminosity = luminosity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder density(int density)
|
||||
{
|
||||
this.density = density;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder temperature(int temperature)
|
||||
{
|
||||
this.temperature = temperature;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder viscosity(int viscosity)
|
||||
{
|
||||
this.viscosity = viscosity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder gaseous()
|
||||
{
|
||||
isGaseous = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder rarity(Rarity rarity)
|
||||
{
|
||||
this.rarity = rarity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder sound(SoundEvent sound)
|
||||
{
|
||||
this.fillSound = this.emptySound = sound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder sound(SoundEvent fillSound, SoundEvent emptySound)
|
||||
{
|
||||
this.fillSound = fillSound;
|
||||
this.emptySound = emptySound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluidAttributes build(Fluid fluid)
|
||||
{
|
||||
return factory.apply(this, fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Water extends FluidAttributes
|
||||
{
|
||||
protected Water(Builder builder, Fluid fluid)
|
||||
{
|
||||
super(builder, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(BlockAndTintGetter level, BlockPos pos)
|
||||
{
|
||||
return BiomeColors.getAverageWaterColor(level, pos) | 0xFF000000;
|
||||
}
|
||||
|
||||
public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
||||
return new Builder(stillTexture, flowingTexture, Water::new);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A registry which defines the interactions a source fluid can have with its
|
||||
* surroundings. Each possible flow direction is checked for all interactions with
|
||||
* the source.
|
||||
*
|
||||
* <p>Fluid interactions mimic the behavior of {@code LiquidBlock#shouldSpreadLiquid}.
|
||||
* As such, all directions, besides {@link Direction#DOWN} is tested and then replaced.
|
||||
* Any fluids which cause a change in the down interaction must be handled in
|
||||
* {@code FlowingFluid#spreadTo} and not by this interaction manager.
|
||||
*/
|
||||
public final class FluidInteractionRegistry
|
||||
{
|
||||
private static final Map<FluidType, List<InteractionInformation>> INTERACTIONS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Adds an interaction between a source and its surroundings.
|
||||
*
|
||||
* @param source the source of the interaction, this will be replaced if the interaction occurs
|
||||
* @param interaction the interaction data to check and perform
|
||||
*/
|
||||
public static synchronized void addInteraction(FluidType source, InteractionInformation interaction)
|
||||
{
|
||||
INTERACTIONS.computeIfAbsent(source, s -> new ArrayList<>()).add(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs all potential fluid interactions at a given position.
|
||||
*
|
||||
* <p>Note: Only the first interaction check that succeeds will occur.
|
||||
*
|
||||
* @param level the level the interactions take place in
|
||||
* @param pos the position of the source fluid
|
||||
* @return {@code true} if an interaction took place, {@code false} otherwise
|
||||
*/
|
||||
public static boolean canInteract(Level level, BlockPos pos)
|
||||
{
|
||||
FluidState state = level.getFluidState(pos);
|
||||
for (Direction direction : LiquidBlock.POSSIBLE_FLOW_DIRECTIONS)
|
||||
{
|
||||
BlockPos relativePos = pos.relative(direction.getOpposite());
|
||||
List<InteractionInformation> interactions = INTERACTIONS.getOrDefault(state.getFluidType(), Collections.emptyList());
|
||||
for (InteractionInformation interaction : interactions)
|
||||
{
|
||||
if (interaction.predicate().test(level, pos, relativePos, state))
|
||||
{
|
||||
interaction.interaction().interact(level, pos, relativePos, state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// Lava + Water = Obsidian (Source Lava) / Cobblestone (Flowing Lava)
|
||||
addInteraction(ForgeMod.LAVA_TYPE.get(), new InteractionInformation(
|
||||
ForgeMod.WATER_TYPE.get(),
|
||||
fluidState -> fluidState.isSource() ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.COBBLESTONE.defaultBlockState()
|
||||
));
|
||||
|
||||
// Lava + Soul Soil (Below) + Blue Ice = Basalt
|
||||
addInteraction(ForgeMod.LAVA_TYPE.get(), new InteractionInformation(
|
||||
(level, currentPos, relativePos, currentState) -> level.getBlockState(currentPos.below()).is(Blocks.SOUL_SOIL) && level.getBlockState(relativePos).is(Blocks.BLUE_ICE),
|
||||
Blocks.BASALT.defaultBlockState()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the interaction data for a given source type on when to succeed
|
||||
* and what to perform.
|
||||
*
|
||||
* @param predicate a test to see whether an interaction can occur
|
||||
* @param interaction the interaction to perform
|
||||
*/
|
||||
public record InteractionInformation(HasFluidInteraction predicate, FluidInteraction interaction)
|
||||
{
|
||||
/**
|
||||
* Constructor which checks the surroundings fluids for a specific type
|
||||
* and then transforms the source state into a block.
|
||||
*
|
||||
* @param type the type of the fluid that must be surrounding the source
|
||||
* @param state the state of the block replacing the source
|
||||
*/
|
||||
public InteractionInformation(FluidType type, BlockState state)
|
||||
{
|
||||
this(type, fluidState -> state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which transforms the source state into a block.
|
||||
*
|
||||
* @param predicate a test to see whether an interaction can occur
|
||||
* @param state the state of the block replacing the source
|
||||
*/
|
||||
public InteractionInformation(HasFluidInteraction predicate, BlockState state)
|
||||
{
|
||||
this(predicate, fluidState -> state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which checks the surroundings fluids for a specific type
|
||||
* and then transforms the source state into a block.
|
||||
*
|
||||
* @param type the type of the fluid that must be surrounding the source
|
||||
* @param getState a function to transform the source fluid into a block state
|
||||
*/
|
||||
public InteractionInformation(FluidType type, Function<FluidState, BlockState> getState)
|
||||
{
|
||||
this((level, currentPos, relativePos, currentState) -> level.getFluidState(relativePos).getFluidType() == type, getState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which transforms the source state into a block.
|
||||
*
|
||||
* @param predicate a test to see whether an interaction can occur
|
||||
* @param getState a function to transform the source fluid into a block state
|
||||
*/
|
||||
public InteractionInformation(HasFluidInteraction predicate, Function<FluidState, BlockState> getState)
|
||||
{
|
||||
this(predicate, (level, currentPos, relativePos, currentState) ->
|
||||
{
|
||||
level.setBlockAndUpdate(currentPos, ForgeEventFactory.fireFluidPlaceBlockEvent(level, currentPos, currentPos, getState.apply(currentState)));
|
||||
level.levelEvent(1501, currentPos, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface which tests whether a source fluid can interact with its
|
||||
* surroundings.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface HasFluidInteraction
|
||||
{
|
||||
/**
|
||||
* Returns whether the interaction can occur.
|
||||
*
|
||||
* @param level the level the interaction takes place in
|
||||
* @param currentPos the position of the source
|
||||
* @param relativePos a position surrounding the source
|
||||
* @param currentState the state of the fluid surrounding the source
|
||||
* @return {@code true} if an interaction can occur, {@code false} otherwise
|
||||
*/
|
||||
boolean test(Level level, BlockPos currentPos, BlockPos relativePos, FluidState currentState);
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface which performs an interaction for a source.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface FluidInteraction
|
||||
{
|
||||
/**
|
||||
* Performs the interaction between the source and the surrounding data.
|
||||
*
|
||||
* @param level the level the interaction takes place in
|
||||
* @param currentPos the position of the source
|
||||
* @param relativePos a position surrounding the source
|
||||
* @param currentState the state of the fluid surrounding the source
|
||||
*/
|
||||
void interact(Level level, BlockPos currentPos, BlockPos relativePos, FluidState currentState);
|
||||
}
|
||||
}
|
||||
@@ -234,12 +234,12 @@ public class FluidStack
|
||||
|
||||
public Component getDisplayName()
|
||||
{
|
||||
return this.getFluid().getAttributes().getDisplayName(this);
|
||||
return this.getFluid().getFluidType().getDescription(this);
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return this.getFluid().getAttributes().getTranslationKey(this);
|
||||
return this.getFluid().getFluidType().getDescriptionId(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.SoundActions;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -137,7 +138,7 @@ public class FluidUtil
|
||||
tryFluidTransfer(containerFluidHandler, fluidSource, maxAmount, true);
|
||||
if (player != null)
|
||||
{
|
||||
SoundEvent soundevent = simulatedTransfer.getFluid().getAttributes().getFillSound(simulatedTransfer);
|
||||
SoundEvent soundevent = simulatedTransfer.getFluid().getFluidType().getSound(simulatedTransfer, SoundActions.BUCKET_FILL);
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -181,7 +182,7 @@ public class FluidUtil
|
||||
|
||||
if (doDrain && player != null)
|
||||
{
|
||||
SoundEvent soundevent = transfer.getFluid().getAttributes().getEmptySound(transfer);
|
||||
SoundEvent soundevent = transfer.getFluid().getFluidType().getSound(transfer, SoundActions.BUCKET_EMPTY);
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -546,7 +547,7 @@ public class FluidUtil
|
||||
}
|
||||
|
||||
Fluid fluid = resource.getFluid();
|
||||
if (fluid == Fluids.EMPTY || !fluid.getAttributes().canBePlacedInWorld(level, pos, resource))
|
||||
if (fluid == Fluids.EMPTY || !fluid.getFluidType().canBePlacedInLevel(level, pos, resource))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -569,12 +570,12 @@ public class FluidUtil
|
||||
return false; // Non-air, solid, unreplacable block. We can't put fluid here.
|
||||
}
|
||||
|
||||
if (level.dimensionType().ultraWarm() && fluid.getAttributes().doesVaporize(level, pos, resource))
|
||||
if (fluid.getFluidType().isVaporizedOnPlacement(level, pos, resource))
|
||||
{
|
||||
FluidStack result = fluidSource.drain(resource, IFluidHandler.FluidAction.EXECUTE);
|
||||
if (!result.isEmpty())
|
||||
{
|
||||
result.getFluid().getAttributes().vaporize(player, level, pos, result);
|
||||
result.getFluid().getFluidType().onVaporize(player, level, pos, result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -593,7 +594,7 @@ public class FluidUtil
|
||||
FluidStack result = tryFluidTransfer(handler, fluidSource, resource, true);
|
||||
if (!result.isEmpty())
|
||||
{
|
||||
SoundEvent soundevent = resource.getFluid().getAttributes().getEmptySound(resource);
|
||||
SoundEvent soundevent = resource.getFluid().getFluidType().getSound(resource, SoundActions.BUCKET_EMPTY);
|
||||
level.playSound(player, pos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
@@ -609,7 +610,7 @@ public class FluidUtil
|
||||
*/
|
||||
private static IFluidHandler getFluidBlockHandler(Fluid fluid, Level level, BlockPos pos)
|
||||
{
|
||||
BlockState state = fluid.getAttributes().getBlock(level, pos, fluid.defaultFluidState());
|
||||
BlockState state = fluid.getFluidType().getBlockForFluidState(level, pos, fluid.defaultFluidState());
|
||||
return new BlockWrapper(state, level, pos);
|
||||
}
|
||||
|
||||
@@ -660,6 +661,6 @@ public class FluidUtil
|
||||
}
|
||||
}
|
||||
|
||||
return fluid.getAttributes().getBucket(fluidStack);
|
||||
return fluid.getFluidType().getBucket(fluidStack);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraftforge.common.SoundActions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -30,14 +31,13 @@ import java.util.function.Supplier;
|
||||
|
||||
public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
{
|
||||
private final Supplier<? extends FluidType> fluidType;
|
||||
private final Supplier<? extends Fluid> flowing;
|
||||
private final Supplier<? extends Fluid> still;
|
||||
@Nullable
|
||||
private final Supplier<? extends Item> bucket;
|
||||
@Nullable
|
||||
private final Supplier<? extends LiquidBlock> block;
|
||||
private final FluidAttributes.Builder builder;
|
||||
private final boolean canMultiply;
|
||||
private final int slopeFindDistance;
|
||||
private final int levelDecreasePerBlock;
|
||||
private final float explosionResistance;
|
||||
@@ -45,10 +45,9 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
|
||||
protected ForgeFlowingFluid(Properties properties)
|
||||
{
|
||||
this.fluidType = properties.fluidType;
|
||||
this.flowing = properties.flowing;
|
||||
this.still = properties.still;
|
||||
this.builder = properties.attributes;
|
||||
this.canMultiply = properties.canMultiply;
|
||||
this.bucket = properties.bucket;
|
||||
this.block = properties.block;
|
||||
this.slopeFindDistance = properties.slopeFindDistance;
|
||||
@@ -57,6 +56,12 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
this.tickRate = properties.tickRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getFluidType()
|
||||
{
|
||||
return this.fluidType.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getFlowing()
|
||||
{
|
||||
@@ -72,7 +77,13 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
@Override
|
||||
protected boolean canConvertToSource()
|
||||
{
|
||||
return canMultiply;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos)
|
||||
{
|
||||
return this.getFluidType().canConvertToSource(state, reader, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,13 +147,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
@Override
|
||||
public Optional<SoundEvent> getPickupSound()
|
||||
{
|
||||
return Optional.ofNullable(getAttributes().getFillSound());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FluidAttributes createAttributes()
|
||||
{
|
||||
return builder.build(this);
|
||||
return Optional.ofNullable(getFluidType().getSound(SoundActions.BUCKET_FILL));
|
||||
}
|
||||
|
||||
public static class Flowing extends ForgeFlowingFluid
|
||||
@@ -185,10 +190,9 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
|
||||
public static class Properties
|
||||
{
|
||||
private Supplier<? extends FluidType> fluidType;
|
||||
private Supplier<? extends Fluid> still;
|
||||
private Supplier<? extends Fluid> flowing;
|
||||
private FluidAttributes.Builder attributes;
|
||||
private boolean canMultiply;
|
||||
private Supplier<? extends Item> bucket;
|
||||
private Supplier<? extends LiquidBlock> block;
|
||||
private int slopeFindDistance = 4;
|
||||
@@ -196,17 +200,11 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
private float explosionResistance = 1;
|
||||
private int tickRate = 5;
|
||||
|
||||
public Properties(Supplier<? extends Fluid> still, Supplier<? extends Fluid> flowing, FluidAttributes.Builder attributes)
|
||||
public Properties(Supplier<? extends FluidType> fluidType, Supplier<? extends Fluid> still, Supplier<? extends Fluid> flowing)
|
||||
{
|
||||
this.fluidType = fluidType;
|
||||
this.still = still;
|
||||
this.flowing = flowing;
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public Properties canMultiply()
|
||||
{
|
||||
canMultiply = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Properties bucket(Supplier<? extends Item> bucket)
|
||||
|
||||
@@ -13,14 +13,14 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TileFluidHandler extends BlockEntity
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(FluidAttributes.BUCKET_VOLUME);
|
||||
protected FluidTank tank = new FluidTank(FluidType.BUCKET_VOLUME);
|
||||
|
||||
private final LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank);
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.templates.VoidFluidHandler;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BlockWrapper extends VoidFluidHandler
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
{
|
||||
// NOTE: "Filling" means placement in this context!
|
||||
if (resource.getAmount() < FluidAttributes.BUCKET_VOLUME)
|
||||
if (resource.getAmount() < FluidType.BUCKET_VOLUME)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class BlockWrapper extends VoidFluidHandler
|
||||
FluidUtil.destroyBlockOnFluidPlacement(world, blockPos);
|
||||
world.setBlock(blockPos, state, Block.UPDATE_ALL_IMMEDIATE);
|
||||
}
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
public static class LiquidContainerBlockWrapper extends VoidFluidHandler
|
||||
@@ -68,15 +68,15 @@ public class BlockWrapper extends VoidFluidHandler
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
{
|
||||
// NOTE: "Filling" means placement in this context!
|
||||
if (resource.getAmount() >= FluidAttributes.BUCKET_VOLUME)
|
||||
if (resource.getAmount() >= FluidType.BUCKET_VOLUME)
|
||||
{
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
if (liquidContainer.canPlaceLiquid(world, blockPos, state, resource.getFluid()))
|
||||
{
|
||||
//If we are executing try to actually fill the container, if it failed return that we failed
|
||||
if (action.simulate() || liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getAttributes().getStateForPlacement(world, blockPos, resource)))
|
||||
if (action.simulate() || liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getFluidType().getStateForPlacement(world, blockPos, resource)))
|
||||
{
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -11,8 +11,8 @@ import net.minecraft.world.level.block.BucketPickup;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -50,7 +50,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
FluidState fluidState = world.getFluidState(blockPos);
|
||||
if (!fluidState.isEmpty())
|
||||
{
|
||||
return new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(fluidState.getType(), FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
}
|
||||
return FluidStack.EMPTY;
|
||||
@@ -59,7 +59,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
@Override
|
||||
public int getTankCapacity(int tank)
|
||||
{
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
if (!resource.isEmpty() && FluidAttributes.BUCKET_VOLUME <= resource.getAmount())
|
||||
if (!resource.isEmpty() && FluidType.BUCKET_VOLUME <= resource.getAmount())
|
||||
{
|
||||
FluidState fluidState = world.getFluidState(blockPos);
|
||||
if (!fluidState.isEmpty() && resource.getFluid() == fluidState.getType())
|
||||
@@ -88,7 +88,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos));
|
||||
if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket)
|
||||
{
|
||||
FluidStack extracted = new FluidStack(bucket.getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
FluidStack extracted = new FluidStack(bucket.getFluid(), FluidType.BUCKET_VOLUME);
|
||||
if (!resource.isFluidEqual(extracted))
|
||||
{
|
||||
//Be loud if something went wrong
|
||||
@@ -101,7 +101,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
FluidStack extracted = new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
FluidStack extracted = new FluidStack(fluidState.getType(), FluidType.BUCKET_VOLUME);
|
||||
if (resource.isFluidEqual(extracted))
|
||||
{
|
||||
//Validate NBT matches
|
||||
@@ -117,19 +117,19 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
if (FluidAttributes.BUCKET_VOLUME <= maxDrain)
|
||||
if (FluidType.BUCKET_VOLUME <= maxDrain)
|
||||
{
|
||||
FluidState fluidState = world.getFluidState(blockPos);
|
||||
if (!fluidState.isEmpty())
|
||||
{
|
||||
if (action.simulate())
|
||||
{
|
||||
return new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(fluidState.getType(), FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos));
|
||||
if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket)
|
||||
{
|
||||
return new FluidStack(bucket.getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(bucket.getFluid(), FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ package net.minecraftforge.fluids.capability.wrappers;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FluidBlockWrapper implements IFluidHandler
|
||||
return (int) (stored.getAmount() / filledPercentage);
|
||||
}
|
||||
}
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,8 +11,8 @@ import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
@@ -54,7 +54,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !fluid.getFluid().getAttributes().getBucket(fluid).isEmpty();
|
||||
return !fluid.getFluid().getFluidType().getBucket(fluid).isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -63,11 +63,11 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
Item item = container.getItem();
|
||||
if (item instanceof BucketItem)
|
||||
{
|
||||
return new FluidStack(((BucketItem)item).getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(((BucketItem)item).getFluid(), FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
else if (item instanceof MilkBucketItem && ForgeMod.MILK.isPresent())
|
||||
{
|
||||
return new FluidStack(ForgeMod.MILK.get(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(ForgeMod.MILK.get(), FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,7 +99,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +111,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
{
|
||||
if (container.getCount() != 1 || resource.getAmount() < FluidAttributes.BUCKET_VOLUME || container.getItem() instanceof MilkBucketItem || !getFluid().isEmpty() || !canFillFluidType(resource))
|
||||
if (container.getCount() != 1 || resource.getAmount() < FluidType.BUCKET_VOLUME || container.getItem() instanceof MilkBucketItem || !getFluid().isEmpty() || !canFillFluidType(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -121,14 +121,14 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
setFluid(resource);
|
||||
}
|
||||
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
return FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
if (container.getCount() != 1 || resource.getAmount() < FluidAttributes.BUCKET_VOLUME)
|
||||
if (container.getCount() != 1 || resource.getAmount() < FluidType.BUCKET_VOLUME)
|
||||
{
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
if (container.getCount() != 1 || maxDrain < FluidAttributes.BUCKET_VOLUME)
|
||||
if (container.getCount() != 1 || maxDrain < FluidType.BUCKET_VOLUME)
|
||||
{
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user