Package de.z0rdak.yawp.handler
Class HandlerUtil
java.lang.Object
de.z0rdak.yawp.handler.HandlerUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckMobGrief(net.minecraft.world.entity.Entity entity, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) static voidcheckMobGrief(net.minecraft.world.entity.Entity entity, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<Boolean> cir) static voidcheckMobGrief(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) static voidcheckMobGrief(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable<Boolean> cir) static FlagCheckResultevaluate(FlagCheckEvent checkEvent) Evaluates the given flag check event and returns the result.static net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>getDimKey(net.minecraft.world.entity.Entity entity) static net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>getDimKey(net.minecraft.world.level.Level world) static Map<String,FlagMessage.FlagCorrelation> getFlagMapRecursive(IProtectedRegion region, Map<String, FlagMessage.FlagCorrelation> carry) static FlagContainergetFlagsRecursive(IProtectedRegion region, FlagContainer carry) Recursively gets all flags defined in the region hierarchy of the provided region, including all it's parents.static List<IProtectedRegion>getRegionHierarchy(IProtectedRegion region, List<IProtectedRegion> carry) Recursively gets the region hierarchy for the given region.static FlagMessage.FlagCorrelationgetResponsibleFlag(IProtectedRegion region, RegionFlag regionFlag, FlagMessage.FlagCorrelation carry) static booleanisAnimal(net.minecraft.world.entity.Entity entity) static booleanisMonster(net.minecraft.world.entity.Entity entity) static booleanisPlayer(net.minecraft.world.entity.Entity entity) static booleanisServerSide(net.minecraft.world.entity.Entity entity) static booleanisServerSide(net.minecraft.world.level.Level world) static booleanisServerSide(net.minecraft.world.level.LevelAccessor world) static booleanisVillager(net.minecraft.world.entity.Entity entity) static booleannotServerSideOrPlayerNull(net.minecraft.world.entity.Entity entity) static FlagStateprocessCheck(FlagCheckEvent checkEvent) static FlagStateprocessCheck(FlagCheckEvent checkEvent, @Nullable Consumer<FlagCheckResult> onDeny) static FlagStateprocessCheck(FlagCheckEvent checkEvent, @Nullable Consumer<FlagCheckResult> onAllow, @Nullable Consumer<FlagCheckResult> onDeny) Processes the given flag check event and executes the given consumers if the flag is allowed or denied.static voidsyncPlayerInventory(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player) static voidupdateBlockState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
-
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 processonAllow- the consumer to execute if the flag is allowedonDeny- 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
-
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
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
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 flagscarry- 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 forcarry- 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)
-