Class TierSortingRegistry

java.lang.Object
net.minecraftforge.common.TierSortingRegistry

public class TierSortingRegistry extends Object
  • Field Details

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • ITEM_TIER_ORDERING_JSON

      private static final ResourceLocation ITEM_TIER_ORDERING_JSON
    • hasCustomTiers

      private static boolean hasCustomTiers
    • tiers

      private static final com.google.common.collect.BiMap<ResourceLocation,Tier> tiers
    • edges

      private static final com.google.common.collect.Multimap<ResourceLocation,ResourceLocation> edges
    • vanillaEdges

      private static final com.google.common.collect.Multimap<ResourceLocation,ResourceLocation> vanillaEdges
    • sortedTiers

      private static final List<Tier> sortedTiers
    • sortedTiersUnmodifiable

      private static final List<Tier> sortedTiersUnmodifiable
    • CHANNEL_NAME

      private static final ResourceLocation CHANNEL_NAME
    • PROTOCOL_VERSION

      private static final String PROTOCOL_VERSION
      See Also:
    • SYNC_CHANNEL

      private static final SimpleChannel SYNC_CHANNEL
  • Constructor Details

    • TierSortingRegistry

      public TierSortingRegistry()
  • Method Details

    • registerTier

      public static Tier registerTier(Tier tier, ResourceLocation name, List<Object> after, List<Object> before)
      Registers a tier into the tier sorting registry.
      Parameters:
      tier - The tier to register
      name - The name to use internally for dependency resolution
      after - List of tiers to place this tier after (the tiers in the list will be considered lesser tiers)
      before - List of tiers to place this tier before (the tiers in the list will be considered better tiers)
    • getSortedTiers

      public static List<Tier> getSortedTiers()
      Returns the list of tiers in the order defined by the dependencies. This list will remain valid
      Returns:
      An unmodifiable list of tiers ordered lesser to greater
    • byName

      @Nullable public static @Nullable Tier byName(ResourceLocation name)
      Returns the tier associated with a name, if registered into the sorting system.
      Parameters:
      name - The name to look up
      Returns:
      The tier, or null if not registered
    • getName

      @Nullable public static @Nullable ResourceLocation getName(Tier tier)
      Returns the name associated with a tier, if the tier is registered into the sorting system.
      Parameters:
      tier - The tier to look up
      Returns:
      The name for the tier, or null if not registered
    • isTierSorted

      public static boolean isTierSorted(Tier tier)
      Queries if a tier should be evaluated using the sorting system, by calling isCorrectTierForDrops
      Parameters:
      tier - The tier to query
      Returns:
      True if isCorrectTierForDrops should be called for the tier
    • isCorrectTierForDrops

      public static boolean isCorrectTierForDrops(Tier tier, BlockState state)
      Queries if a tier is high enough to be able to get drops for the given blockstate.
      Parameters:
      tier - The tier to look up
      state - The state to test against
      Returns:
      True if the tier is good enough
    • getTiersLowerThan

      public static List<Tier> getTiersLowerThan(Tier tier)
      Helper to query all tiers that are lower than the given tier
      Parameters:
      tier - The tier
      Returns:
      All the lower tiers
    • isCorrectTierVanilla

      private static boolean isCorrectTierVanilla(Tier tier, BlockState state)
      Fallback for when a tier isn't in the registry, copy of the logic in DiggerItem.isCorrectToolForDrops(net.minecraft.world.level.block.state.BlockState)
    • processTier

      private static void processTier(Tier tier, ResourceLocation name, List<Object> afters, List<Object> befores)
    • getTierName

      private static ResourceLocation getTierName(Object entry)
    • allowVanilla

      static boolean allowVanilla()
    • init

      static void init()
    • getReloadListener

      static PreparableReloadListener getReloadListener()
    • recalculateItemTiers

      private static void recalculateItemTiers()
    • setTierOrder

      private static void setTierOrder(List<Tier> tierList)
    • runInServerThreadIfPossible

      private static void runInServerThreadIfPossible(it.unimi.dsi.fastutil.booleans.BooleanConsumer runnable)
    • syncToAll

      private static void syncToAll()
    • playerLoggedIn

      private static void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
    • syncToPlayer

      private static void syncToPlayer(ServerPlayer serverPlayer)
    • receive

      private static TierSortingRegistry.SyncPacket receive(FriendlyByteBuf buffer)
    • handle

      private static void handle(TierSortingRegistry.SyncPacket packet, Supplier<NetworkEvent.Context> context)