Class FluidBase

java.lang.Object
org.moddingx.libx.base.FluidBase
All Implemented Interfaces:
net.minecraft.world.level.ItemLike, Registerable

@PlainRegisterable public class FluidBase extends Object implements net.minecraft.world.level.ItemLike, Registerable
A Registerable that registers a fluid type, source and flowing fluid, a liquid block and a bucket item.
  • Field Details

    • mod

      protected final ModX mod
  • Constructor Details

  • Method Details

    • createClientInfo

      protected ClientExtensionInfo.Fluid createClientInfo(net.minecraft.resources.Identifier id)
      Creates the client extensions and the fluid model for this fluid. The default implementation creates client extensions that have no special properties and a fluid model without tint that uses a still texture located at [namespace]:block/[path] and a flowing texture located at [namespace]:block/[path]_flowing.
    • registerAdditional

      Description copied from interface: Registerable
      Registers additional objects. Those may be Registerable as well. These objects will be registered with the id of this object and optionally a name suffix.
      Specified by:
      registerAdditional in interface Registerable
    • registerClientAdditional

      @OverridingMethodsMustInvokeSuper public void registerClientAdditional(RegistrationContext ctx, Registerable.EntryCollector builder)
      Description copied from interface: Registerable
      Specified by:
      registerClientAdditional in interface Registerable
    • getFluidType

      @Nonnull public final net.neoforged.neoforge.fluids.FluidType getFluidType()
      Gets the fluid type for this FluidBase.
    • getFluid

      @Nonnull public final net.minecraft.world.level.material.Fluid getFluid()
      Gets the source fluid for this FluidBase. This is the same as getSourceFluid(). One should prefer this method over getSourceFluid() when needing a representative for the whole fluid type, for example when creating fluid stacks.
    • getSourceFluid

      @Nonnull public final net.minecraft.world.level.material.Fluid getSourceFluid()
      Gets the source fluid for this FluidBase. This is the same as getFluid(). One should prefer this method over getFluid() when a distinction between source and flowing fluids is to be made.
    • getFlowingFluid

      @Nonnull public final net.minecraft.world.level.material.Fluid getFlowingFluid()
      Gets the flowing fluid for this FluidBase.
    • getLiquidBlock

      @Nonnull public final net.minecraft.world.level.block.LiquidBlock getLiquidBlock()
      Gets the liquid block for this FluidBase.

      The liquid block is created during registration, as its id is not known before. Therefore, this method must not be called during construction or static initialization of the FluidBase and will throw an IllegalStateException until the fluid has been registered. It is however safe to pass a method reference to this method around, as long as it is only invoked after registration.

      Throws:
      IllegalStateException - if this FluidBase has not been registered yet
    • getBucketItem

      @Nonnull public final net.minecraft.world.item.BucketItem getBucketItem()
      Gets the bucket item for this FluidBase.

      The bucket item is created during registration, as its id is not known before. Therefore, this method must not be called during construction or static initialization of the FluidBase and will throw an IllegalStateException until the fluid has been registered. It is however safe to pass a method reference to this method around, as long as it is only invoked after registration.

      Throws:
      IllegalStateException - if this FluidBase has not been registered yet
    • asItem

      @Nonnull public final net.minecraft.world.item.Item asItem()
      This is the same as getBucketItem() and allows FluidBase to be used as an ItemLike.

      Just like getBucketItem(), this throws an IllegalStateException if the fluid has not been registered yet, so a FluidBase must not be used as an ItemLike before registration.

      Specified by:
      asItem in interface net.minecraft.world.level.ItemLike
      Throws:
      IllegalStateException - if this FluidBase has not been registered yet
    • fluidBuilder

      public static FluidBase.Builder fluidBuilder()
      Creates a new fluid builder for setting the basic fluid properties to be passed in the constructor.