Class HandlerUtil

java.lang.Object
de.z0rdak.yawp.handler.HandlerUtil

public final class HandlerUtil extends Object
  • Method Details

    • getDimKey

      public static net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> getDimKey(net.minecraft.world.entity.Entity entity)
    • getDimKey

      public static net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> getDimKey(net.minecraft.world.level.Level world)
    • isAnimal

      public static boolean isAnimal(net.minecraft.world.entity.Entity entity)
    • isServerSide

      public static boolean isServerSide(net.minecraft.world.entity.Entity entity)
    • isServerSide

      public static boolean isServerSide(net.minecraft.world.level.LevelAccessor world)
    • isServerSide

      public static boolean isServerSide(net.minecraft.world.level.Level world)
    • isVillager

      public static boolean isVillager(net.minecraft.world.entity.Entity entity)
    • isPlayer

      public static boolean isPlayer(net.minecraft.world.entity.Entity entity)
    • isMonster

      public static boolean isMonster(net.minecraft.world.entity.Entity entity)
    • notServerSideOrPlayerNull

      public static boolean notServerSideOrPlayerNull(net.minecraft.world.entity.Entity entity)
    • processCheck

      public static FlagState processCheck(FlagCheckEvent checkEvent, @Nullable @Nullable Consumer<FlagCheckResult> onAllow, @Nullable @Nullable Consumer<FlagCheckResult> onDeny)
      Processes the given flag check event and executes the given consumers if the flag is allowed or denied.
      The flag check event is evaluated and posted to the event bus.
      If the flag is allowed, the onAllow consumer is executed, otherwise onDeny.
      Parameters:
      checkEvent - the flag check event to process
      onAllow - the consumer to execute if the flag is allowed
      onDeny - the consumer to execute if the flag is denied
      Returns:
      the flag state of the result
    • processCheck

      public static FlagState processCheck(FlagCheckEvent checkEvent, @Nullable @Nullable Consumer<FlagCheckResult> onDeny)
    • processCheck

      public static FlagState processCheck(FlagCheckEvent checkEvent)
    • checkMobGrief

      public static void checkMobGrief(net.minecraft.world.entity.Entity entity, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci)
    • checkMobGrief

      public static void checkMobGrief(net.minecraft.world.entity.Entity entity, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<Boolean> cir)
    • checkMobGrief

      public static void checkMobGrief(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci)
    • checkMobGrief

      public static void checkMobGrief(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<Boolean> cir)
    • syncPlayerInventory

      public static void syncPlayerInventory(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player)
    • updateBlockState

      public static void updateBlockState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
    • evaluate

      public static FlagCheckResult evaluate(FlagCheckEvent checkEvent)
      Evaluates the given flag check event and returns the result.
      The responsible region is determined and the flag state is checked against the player's permissions.
      Parameters:
      checkEvent - the flag check event to evaluate
      Returns:
      the result of the flag check event
    • getFlagMapRecursive

      public static Map<String,FlagMessage.FlagCorrelation> getFlagMapRecursive(IProtectedRegion region, Map<String,FlagMessage.FlagCorrelation> carry)
    • getFlagsRecursive

      public static FlagContainer getFlagsRecursive(IProtectedRegion region, FlagContainer carry)
      Recursively gets all flags defined in the region hierarchy of the provided region, including all it's parents.
      This is used, when we have determined the responsible region for an Event or a BlockPos.
      We need to check all flags of the responsible region and all its parents to determine the final flag state.
      Parameters:
      region - the region (and its parents) to get active flags
      carry - a flag container, holding information about region flags
      Returns:
      a flag container of all active flags of the given region including its parents.
    • getRegionHierarchy

      public static List<IProtectedRegion> getRegionHierarchy(IProtectedRegion region, List<IProtectedRegion> carry)
      Recursively gets the region hierarchy for the given region.
      The region hierarchy is a list of regions starting with the given region and ending with the global region.
      Parameters:
      region - the region to get the hierarchy for
      carry - the list to carry the hierarchy (initially empty)
      Returns:
      the region hierarchy for the given region
    • getResponsibleFlag

      public static FlagMessage.FlagCorrelation getResponsibleFlag(IProtectedRegion region, RegionFlag regionFlag, @Nullable FlagMessage.FlagCorrelation carry)