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
-
Nested Class Summary
Nested classes/interfaces inherited from class at.petrak.hexcasting.api.casting.eval.CastingEnvironment
CastingEnvironment.HeldItemInfo, CastingEnvironment.StackDiscoveryMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final net.minecraft.server.level.ServerPlayerprotected final net.minecraft.world.InteractionHandstatic final doublestatic final doubleFields inherited from class at.petrak.hexcasting.api.casting.eval.CastingEnvironment
componentMap, world -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPlayerBasedCastEnv(net.minecraft.server.level.ServerPlayer caster, net.minecraft.world.InteractionHand castingHand) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected longextractMediaFromInventory(long costLeft, boolean allowOvercast, boolean simulate) Search the player's inventory for media ADs and use them.doublenet.minecraft.server.level.ServerPlayerGet the caster.net.minecraft.world.entity.LivingEntityGets the caster.Get an interface used to do mishapsprotected List<CastingEnvironment.HeldItemInfo>Get the primary/secondary item stacks this env can use (i.e.doubleprotected List<net.minecraft.world.item.ItemStack>Get all the item stacks this env can use.booleanhasEditPermissionsAtEnvironment(net.minecraft.core.BlockPos pos) Return whether the caster can edit blocks at the given permission (i.e.protected booleanWhether to provide infinite items.booleanisVecInRangeEnvironment(net.minecraft.world.phys.Vec3 vec) Get if the vec is close enough, to the player or sentinel ...net.minecraft.world.phys.Vec3voidpostExecution(at.petrak.hexcasting.api.casting.eval.CastResult result) Do whatever you like after a pattern is executed.voidprintMessage(net.minecraft.network.chat.Component message) voidproduceParticles(at.petrak.hexcasting.api.casting.ParticleSpray particles, FrozenPigment pigment) booleanreplaceItem(Predicate<net.minecraft.world.item.ItemStack> stackOk, net.minecraft.world.item.ItemStack replaceWith, @Nullable net.minecraft.world.InteractionHand hand) Attempt to replace the first stack found which matches the predicate with the stack to replace with.protected voidsendMishapMsgToPlayer(at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect.DoMishap mishap) @Nullable FrozenPigmentsetPigment(@Nullable FrozenPigment pigment) Methods inherited from class at.petrak.hexcasting.api.casting.eval.CastingEnvironment
actionKey, addCreateEventListener, addCreateEventListener, addExtension, assertEntityInRange, assertPosInRange, assertPosInRangeForEditing, assertVecInRange, assertVecInWorld, canEditBlockAt, extractMedia, extractMediaEnvironment, getCastingHand, getExtension, getHeldItemToOperateOn, getOtherHand, getPigment, getPrimaryStacksForPlayer, getUsableStacksForPlayer, getWorld, hasEditPermissionsAt, isEnlightened, isEntityInRange, isEntityInRange, isVecInAmbit, isVecInRange, isVecInWorld, maxOpCount, postCast, precheckAction, queryForMatchingStack, removeExtension, replaceItemForPlayer, triggerCreateEvent, withdrawItem
-
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:CastingEnvironmentGets the caster. Can be null ifCastingEnvironment.getCaster()is also null- Specified by:
getCastingEntityin classCastingEnvironment- Returns:
- the entity casting
-
getCaster
public net.minecraft.server.level.ServerPlayer getCaster()Description copied from class:CastingEnvironmentGet 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:
getCasterin classCastingEnvironment
-
postExecution
public void postExecution(at.petrak.hexcasting.api.casting.eval.CastResult result) Description copied from class:CastingEnvironmentDo whatever you like after a pattern is executed.- Overrides:
postExecutionin classCastingEnvironment
-
getUsableStacks
protected List<net.minecraft.world.item.ItemStack> getUsableStacks(CastingEnvironment.StackDiscoveryMode mode) Description copied from class:CastingEnvironmentGet all the item stacks this env can use.- Specified by:
getUsableStacksin classCastingEnvironment
-
getPrimaryStacks
Description copied from class:CastingEnvironmentGet the primary/secondary item stacks this env can use (i.e. main hand and offhand for the player).- Specified by:
getPrimaryStacksin classCastingEnvironment
-
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:CastingEnvironmentAttempt to replace the first stack found which matches the predicate with the stack to replace with.- Specified by:
replaceItemin classCastingEnvironment- Returns:
- whether it was successful.
-
isVecInRangeEnvironment
public boolean isVecInRangeEnvironment(net.minecraft.world.phys.Vec3 vec) Description copied from class:CastingEnvironmentGet if the vec is close enough, to the player or sentinel ...Doesn't take into account being out of the world.
- Specified by:
isVecInRangeEnvironmentin classCastingEnvironment
-
hasEditPermissionsAtEnvironment
public boolean hasEditPermissionsAtEnvironment(net.minecraft.core.BlockPos pos) Description copied from class:CastingEnvironmentReturn whether the caster can edit blocks at the given permission (i.e. not adventure mode, etc.)- Specified by:
hasEditPermissionsAtEnvironmentin classCastingEnvironment
-
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
- Specified by:
setPigmentin classCastingEnvironment
-
produceParticles
public void produceParticles(at.petrak.hexcasting.api.casting.ParticleSpray particles, FrozenPigment pigment) - Specified by:
produceParticlesin classCastingEnvironment
-
mishapSprayPos
public net.minecraft.world.phys.Vec3 mishapSprayPos()- Specified by:
mishapSprayPosin classCastingEnvironment
-
getMishapEnvironment
Description copied from class:CastingEnvironmentGet an interface used to do mishaps- Specified by:
getMishapEnvironmentin classCastingEnvironment
-
sendMishapMsgToPlayer
protected void sendMishapMsgToPlayer(at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect.DoMishap mishap) -
isCreativeMode
protected boolean isCreativeMode()Description copied from class:CastingEnvironmentWhether to provide infinite items.- Overrides:
isCreativeModein classCastingEnvironment
-
printMessage
public void printMessage(net.minecraft.network.chat.Component message) - Specified by:
printMessagein classCastingEnvironment
-