Class PlayerBasedCastEnv

java.lang.Object
at.petrak.hexcasting.api.casting.eval.CastingEnvironment
at.petrak.hexcasting.api.casting.eval.env.PlayerBasedCastEnv
Direct Known Subclasses:
PackagedItemCastEnv, StaffCastEnv

public abstract class PlayerBasedCastEnv extends CastingEnvironment
  • Field Details

    • DEFAULT_AMBIT_RADIUS

      public static final double DEFAULT_AMBIT_RADIUS
      See Also:
    • DEFAULT_SENTINEL_RADIUS

      public static final double DEFAULT_SENTINEL_RADIUS
      See Also:
    • caster

      protected final net.minecraft.server.level.ServerPlayer caster
    • castingHand

      protected final net.minecraft.world.InteractionHand castingHand
  • Constructor Details

    • PlayerBasedCastEnv

      protected PlayerBasedCastEnv(net.minecraft.server.level.ServerPlayer caster, net.minecraft.world.InteractionHand castingHand)
  • Method Details

    • getCastingEntity

      public net.minecraft.world.entity.LivingEntity getCastingEntity()
      Description copied from class: CastingEnvironment
      Gets the caster. Can be null if CastingEnvironment.getCaster() is also null
      Specified by:
      getCastingEntity in class CastingEnvironment
      Returns:
      the entity casting
    • getCaster

      public net.minecraft.server.level.ServerPlayer getCaster()
      Description copied from class: CastingEnvironment
      Get the caster. Might be null!

      Implementations should NOT rely on this in general, use the methods on this class instead. This is mostly for spells (flight, etc)

      Overrides:
      getCaster in class CastingEnvironment
    • postExecution

      public void postExecution(at.petrak.hexcasting.api.casting.eval.CastResult result)
      Description copied from class: CastingEnvironment
      Do whatever you like after a pattern is executed.
      Overrides:
      postExecution in class CastingEnvironment
    • getUsableStacks

      protected List<net.minecraft.world.item.ItemStack> getUsableStacks(CastingEnvironment.StackDiscoveryMode mode)
      Description copied from class: CastingEnvironment
      Get all the item stacks this env can use.
      Specified by:
      getUsableStacks in class CastingEnvironment
    • getPrimaryStacks

      protected List<CastingEnvironment.HeldItemInfo> getPrimaryStacks()
      Description copied from class: CastingEnvironment
      Get the primary/secondary item stacks this env can use (i.e. main hand and offhand for the player).
      Specified by:
      getPrimaryStacks in class CastingEnvironment
    • getAmbitRadius

      public double getAmbitRadius()
    • getSentinelRadius

      public double getSentinelRadius()
    • replaceItem

      public boolean replaceItem(Predicate<net.minecraft.world.item.ItemStack> stackOk, net.minecraft.world.item.ItemStack replaceWith, @Nullable @Nullable net.minecraft.world.InteractionHand hand)
      Description copied from class: CastingEnvironment
      Attempt to replace the first stack found which matches the predicate with the stack to replace with.
      Specified by:
      replaceItem in class CastingEnvironment
      Returns:
      whether it was successful.
    • isVecInRangeEnvironment

      public boolean isVecInRangeEnvironment(net.minecraft.world.phys.Vec3 vec)
      Description copied from class: CastingEnvironment
      Get if the vec is close enough, to the player or sentinel ...

      Doesn't take into account being out of the world.

      Specified by:
      isVecInRangeEnvironment in class CastingEnvironment
    • hasEditPermissionsAtEnvironment

      public boolean hasEditPermissionsAtEnvironment(net.minecraft.core.BlockPos pos)
      Description copied from class: CastingEnvironment
      Return whether the caster can edit blocks at the given permission (i.e. not adventure mode, etc.)
      Specified by:
      hasEditPermissionsAtEnvironment in class CastingEnvironment
    • extractMediaFromInventory

      protected long extractMediaFromInventory(long costLeft, boolean allowOvercast, boolean simulate)
      Search the player's inventory for media ADs and use them.
    • canOvercast

      protected boolean canOvercast()
    • setPigment

      @Nullable public @Nullable FrozenPigment setPigment(@Nullable @Nullable FrozenPigment pigment)
      Specified by:
      setPigment in class CastingEnvironment
    • produceParticles

      public void produceParticles(at.petrak.hexcasting.api.casting.ParticleSpray particles, FrozenPigment pigment)
      Specified by:
      produceParticles in class CastingEnvironment
    • mishapSprayPos

      public net.minecraft.world.phys.Vec3 mishapSprayPos()
      Specified by:
      mishapSprayPos in class CastingEnvironment
    • getMishapEnvironment

      public MishapEnvironment getMishapEnvironment()
      Description copied from class: CastingEnvironment
      Get an interface used to do mishaps
      Specified by:
      getMishapEnvironment in class CastingEnvironment
    • sendMishapMsgToPlayer

      protected void sendMishapMsgToPlayer(at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect.DoMishap mishap)
    • isCreativeMode

      protected boolean isCreativeMode()
      Description copied from class: CastingEnvironment
      Whether to provide infinite items.
      Overrides:
      isCreativeMode in class CastingEnvironment
    • printMessage

      public void printMessage(net.minecraft.network.chat.Component message)
      Specified by:
      printMessage in class CastingEnvironment