Record Class DispatchableFunction<T>

java.lang.Object
java.lang.Record
com.lightning.northstar.planet.data.func.DispatchableFunction<T>
All Implemented Interfaces:
LevelFunction

@ParametersAreNonnullByDefault public record DispatchableFunction<T>(net.minecraft.resources.ResourceLocation type, BiFunction<net.minecraft.world.level.Level,net.minecraft.core.BlockPos,T> key, Map<T,LevelFunction> entries, LevelFunction fallback) extends Record implements LevelFunction
  • Field Details

    • FALLBACK_KEY

      public static final net.minecraft.resources.ResourceLocation FALLBACK_KEY
      The key used to mark fallback entries.
    • FALLBACK_KEY_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.resources.ResourceLocation> FALLBACK_KEY_CODEC
      A codec that only accepts FALLBACK_KEY or fails.
    • BIOME

      public static final DispatchableFunction.Factory<net.minecraft.resources.ResourceLocation> BIOME
    • BLOCK

      public static final DispatchableFunction.Factory<net.minecraft.world.level.block.Block> BLOCK
    • WEATHER

      public static final DispatchableFunction.Factory<net.minecraft.resources.ResourceLocation> WEATHER
  • Constructor Details

    • DispatchableFunction

      public DispatchableFunction(net.minecraft.resources.ResourceLocation type, BiFunction<net.minecraft.world.level.Level,net.minecraft.core.BlockPos,T> key, Map<T,LevelFunction> entries, LevelFunction fallback)
      Creates an instance of a DispatchableFunction record class.
      Parameters:
      type - the value for the type record component
      key - the value for the key record component
      entries - the value for the entries record component
      fallback - the value for the fallback record component
  • Method Details

    • codec

      public static <T> com.mojang.serialization.MapCodec<DispatchableFunction<T>> codec(com.mojang.serialization.Codec<T> codec, Function<it.unimi.dsi.fastutil.Pair<LevelFunction,Map<T,LevelFunction>>,DispatchableFunction<T>> constructor)
    • get

      public float get(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Specified by:
      get in interface LevelFunction
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public net.minecraft.resources.ResourceLocation type()
      Returns the value of the type record component.
      Specified by:
      type in interface LevelFunction
      Returns:
      the value of the type record component
    • key

      public BiFunction<net.minecraft.world.level.Level,net.minecraft.core.BlockPos,T> key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • entries

      public Map<T,LevelFunction> entries()
      Returns the value of the entries record component.
      Returns:
      the value of the entries record component
    • fallback

      public LevelFunction fallback()
      Returns the value of the fallback record component.
      Returns:
      the value of the fallback record component