Package vazkii.botania.common.helper
Class PlayerHelper
java.lang.Object
vazkii.botania.common.helper.PlayerHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconsumeAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) static net.minecraft.world.item.ItemStackgetAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) static net.minecraft.world.item.ItemStackgetFirstHeldItem(net.minecraft.world.entity.LivingEntity living, Predicate<net.minecraft.world.item.ItemStack> pred) static net.minecraft.world.item.ItemStackgetFirstHeldItem(net.minecraft.world.entity.LivingEntity living, net.minecraft.world.item.Item item) static net.minecraft.world.item.ItemStackgetFirstHeldItemClass(net.minecraft.world.entity.LivingEntity living, Class<?> template) static net.minecraft.world.item.ItemStackgetItemClassFromInventory(net.minecraft.world.entity.player.Player player, Class<?> template) static net.minecraft.world.item.ItemStackgetItemFromInventory(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> itemPred) static List<net.minecraft.world.entity.player.Player> getRealPlayersIn(net.minecraft.world.level.Level level, net.minecraft.world.phys.AABB aabb) static voidgrantCriterion(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation advancementId, String criterion) static booleanhasAdvancement(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation advancementId) static booleanhasAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) static booleanhasAnyHeldItem(net.minecraft.world.entity.player.Player player) static booleanhasHeldItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) static booleanhasHeldItemClass(net.minecraft.world.entity.player.Player player, Class<?> template) static booleanisTruePlayer(@Nullable net.minecraft.world.entity.Entity e) static voidsetFakePlayerClass(Class<? extends net.minecraft.world.entity.player.Player> fakePlayerClass) static net.minecraft.world.InteractionResultsubstituteUse(net.minecraft.world.item.context.UseOnContext ctx, net.minecraft.world.item.ItemStack toUse) static com.mojang.datafixers.util.Pair<net.minecraft.world.InteractionResult, net.minecraft.core.BlockPos> substituteUseTrackPos(net.minecraft.world.item.context.UseOnContext ctx, net.minecraft.world.item.ItemStack toUse) Temporarily swaptoUseinto the hand of the player, use it, then swap it back out.
-
Method Details
-
setFakePlayerClass
public static void setFakePlayerClass(Class<? extends net.minecraft.world.entity.player.Player> fakePlayerClass) -
isTruePlayer
public static boolean isTruePlayer(@Nullable @Nullable net.minecraft.world.entity.Entity e) -
getRealPlayersIn
public static List<net.minecraft.world.entity.player.Player> getRealPlayersIn(net.minecraft.world.level.Level level, net.minecraft.world.phys.AABB aabb) -
hasAnyHeldItem
public static boolean hasAnyHeldItem(net.minecraft.world.entity.player.Player player) -
hasHeldItem
public static boolean hasHeldItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) -
hasHeldItemClass
public static boolean hasHeldItemClass(net.minecraft.world.entity.player.Player player, Class<?> template) -
getFirstHeldItem
public static net.minecraft.world.item.ItemStack getFirstHeldItem(net.minecraft.world.entity.LivingEntity living, net.minecraft.world.item.Item item) -
getFirstHeldItem
public static net.minecraft.world.item.ItemStack getFirstHeldItem(net.minecraft.world.entity.LivingEntity living, Predicate<net.minecraft.world.item.ItemStack> pred) -
getFirstHeldItemClass
public static net.minecraft.world.item.ItemStack getFirstHeldItemClass(net.minecraft.world.entity.LivingEntity living, Class<?> template) -
getAmmo
public static net.minecraft.world.item.ItemStack getAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) -
hasAmmo
public static boolean hasAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) -
consumeAmmo
public static void consumeAmmo(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> ammoFunc) -
getItemFromInventory
public static net.minecraft.world.item.ItemStack getItemFromInventory(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> itemPred) -
getItemClassFromInventory
public static net.minecraft.world.item.ItemStack getItemClassFromInventory(net.minecraft.world.entity.player.Player player, Class<?> template) -
hasAdvancement
public static boolean hasAdvancement(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation advancementId) -
grantCriterion
public static void grantCriterion(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation advancementId, String criterion) -
substituteUse
public static net.minecraft.world.InteractionResult substituteUse(net.minecraft.world.item.context.UseOnContext ctx, net.minecraft.world.item.ItemStack toUse) -
substituteUseTrackPos
public static com.mojang.datafixers.util.Pair<net.minecraft.world.InteractionResult,net.minecraft.core.BlockPos> substituteUseTrackPos(net.minecraft.world.item.context.UseOnContext ctx, net.minecraft.world.item.ItemStack toUse) Temporarily swaptoUseinto the hand of the player, use it, then swap it back out. This is to ensure that any code in mods' onItemUse that relies on player.getHeldItem(ctx.hand) == ctx.stack will work as intended. Properly handles null players, as long as the Item's onItemUse also handles them.- Returns:
- The usage result, as well as a properly offset block position pointing at where the block was placed (if the item was a BlockItem)
-