Class LocationCheckCondition

java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootCondition
com.github.darksoulq.abyssallib.world.data.loot.condition.LocationCheckCondition

public class LocationCheckCondition extends LootCondition
A loot condition that evaluates to true if the loot generation occurs within specific biomes.

This condition allows for biome-specific loot tables, enabling different drops based on the geographical location of the event in the game world.

  • Field Details

    • CODEC

      public static final Codec<LocationCheckCondition> CODEC
      The codec used for serializing and deserializing the location check condition.

      It maps the "biomes" field, which expects a list of namespaced strings representing valid biomes for this condition.

    • TYPE

      public static final LootConditionType<LocationCheckCondition> TYPE
      The registered type definition for the location check loot condition.
  • Constructor Details

    • LocationCheckCondition

      public LocationCheckCondition(List<String> biomes)
      Constructs a new LocationCheckCondition with a list of allowed biomes.
      Parameters:
      biomes - A list of namespaced biome keys (e.g., "minecraft:plains").
  • Method Details

    • test

      public boolean test(LootContext context)
      Tests whether the biome at the context's location is present in the allowed list.

      This method retrieves the Biome at the generation coordinates and uses the RegistryAccess API to resolve its NamespacedKey for comparison.

      Specified by:
      test in class LootCondition
      Parameters:
      context - The LootContext providing the world coordinates.
      Returns:
      true if the current biome is in the list; false otherwise.
    • getType

      public LootConditionType<?> getType()
      Retrieves the specific type definition for this loot condition.
      Specified by:
      getType in class LootCondition
      Returns:
      The LootConditionType associated with LocationCheckCondition.