Interface Sprayed
- All Superinterfaces:
Custom,net.minecraft.item.ItemConvertible,Registered,Registered.Client,Registered.Common
- All Known Implementing Classes:
SprayBottleItem,SprayPotionItem
- Since:
- 2.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordSprayed.Behavior<T extends Sprayed.SprayTarget>Describes and implements a behavior when spraying an object.static final recordDescribes the target block of a spray invocation.static final recordDescribes the target entity of a spray invocation.static final recordDescribes a spray item refilling context.static final recordDescribes the source of a spray item interaction.static final recordThe result of spraying an object.static interfaceDescribes the target of a spray invocation.Nested classes/interfaces inherited from interface dev.jaxydog.astral.register.Registered
Registered.All, Registered.Client, Registered.Common, Registered.Generated, Registered.Server -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.util.IdentifierThe identifier corresponding to a spray item's 'empty' model.static final SoundContextThe sound played when refilling a spray item.static final SoundContextThe sound played when spraying a spray item. -
Method Summary
Modifier and TypeMethodDescription<T extends Sprayed.SprayTarget>
voidaddBehavior(Class<T> type, Sprayed.Behavior<T> behavior) Adds a new behavior to this spray item.default booleancanSpray(Sprayed.Source source, Sprayed.BlockTarget target, int charges) Returns whether the given item stack may spray the target block and consume the given charge count.default booleancanSpray(Sprayed.Source source, Sprayed.EntityTarget target, int charges) Returns whether the given item stack may spray the target entity and consume the given charge count.<T extends Sprayed.SprayTarget>
List<Sprayed.Behavior<T>> getBehaviors(Class<T> type) Returns a list of behaviors for this spray item.default intgetCharges(net.minecraft.item.ItemStack stack) Returns the number of times the given item stack may be sprayed before requiring a refill.default intgetCooldown(net.minecraft.item.ItemStack stack) Returns the given item stack's usage cooldown in ticks.default intgetDuration(net.minecraft.item.ItemStack stack) Returns the given item stack's spray duration in ticks.default floatgetEmptyModelData(net.minecraft.item.ItemStack stack, net.minecraft.world.World world, net.minecraft.entity.LivingEntity entity, int seed) Returns the data used within a spray item's model in order to determine its current texture.default intgetMaxCharges(net.minecraft.item.ItemStack stack) Returns the maximum number of times the given item stack may be sprayed before requiring a refill.default booleanisEmpty(net.minecraft.item.ItemStack stack) Returns whether the given item stack is empty.default booleanisFilled(net.minecraft.item.ItemStack stack) Returns whether the given item stack is filled.default booleanisRefillable(net.minecraft.item.ItemStack stack) Returns whether the given item stack may be refilled.default booleanisSprayable(net.minecraft.item.ItemStack stack) Returns whether the given item stack contains at least 1 remaining charge and can therefore be sprayed.default booleanisSprayable(net.minecraft.item.ItemStack stack, int charges) Returns whether the given item stack contains at leastchargesremaining charges and can therefore be sprayed.default Sprayed.SprayResultonSpray(Sprayed.Source source, Sprayed.BlockTarget target, boolean silent) Runs actions on a sprayed block, returning a result.default Sprayed.SprayResultonSpray(Sprayed.Source source, Sprayed.EntityTarget target, boolean silent) Runs actions on a sprayed target, returning a result.default voidrefill(Sprayed.Source source, Sprayed.RefillContext context) Refills the spray item using the given context.default voidRegisters this value on the client environment.default voidsetCharges(net.minecraft.item.ItemStack stack, int charges) Sets the number of times the given item stack may be sprayed before requiring a refill.default booleanspray(Sprayed.Source source, net.minecraft.world.World world, Sprayed.SprayResult result) Sprays the item.default booleanspray(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity actor, net.minecraft.util.math.Vec3d from, net.minecraft.entity.Entity target, boolean silent) Sprays a target entity.default booleanspray(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity actor, net.minecraft.util.math.Vec3d from, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.Direction side, boolean silent) Sprays a block.Methods inherited from interface dev.jaxydog.astral.content.item.Custom
getItemGroup, registerCommonMethods inherited from interface net.minecraft.item.ItemConvertible
asItemMethods inherited from interface dev.jaxydog.astral.register.Registered
getRegistryId, getRegistryPath
-
Field Details
-
EMPTY_MODEL_ID
static final net.minecraft.util.Identifier EMPTY_MODEL_IDThe identifier corresponding to a spray item's 'empty' model.This is expected to be used only within the
ModelPredicateProviderRegistry.- Since:
- 2.0.0
-
SPRAY_SOUND
The sound played when spraying a spray item.- Since:
- 2.0.0
-
REFILL_SOUND
The sound played when refilling a spray item.- Since:
- 2.0.0
-
-
Method Details
-
addBehavior
Adds a new behavior to this spray item.- Type Parameters:
T- The behavior's target type.- Parameters:
type- The class of the behavior's target type.behavior- The entity behavior.- Since:
- 2.0.0
-
getBehaviors
Returns a list of behaviors for this spray item.- Type Parameters:
T- The behavior's expected target type.- Parameters:
type- The class of the behavior's expected target type.- Returns:
- A list of behaviors.
- Since:
- 2.0.0
-
getEmptyModelData
default float getEmptyModelData(net.minecraft.item.ItemStack stack, net.minecraft.world.World world, net.minecraft.entity.LivingEntity entity, int seed) Returns the data used within a spray item's model in order to determine its current texture.If the stack is considered 'empty', this method should return
1F. Otherwise, it should return0F. This method may be overwritten to allow for additional numbers between [0, 1], however this range should not be exceeded.- Parameters:
stack- The item stack.world- The current world.entity- The entity holding the item.seed- The randomness seed.- Returns:
- A number between
0and1. - Since:
- 2.0.0
-
getCooldown
default int getCooldown(net.minecraft.item.ItemStack stack) Returns the given item stack's usage cooldown in ticks.A value of less than or equal to
0should be interpreted as having no cooldown.The default implementation returns a duration of
8ticks.- Parameters:
stack- The item stack.- Returns:
- The cooldown in ticks.
- Since:
- 2.0.0
-
getDuration
default int getDuration(net.minecraft.item.ItemStack stack) Returns the given item stack's spray duration in ticks.This is used within the implementation of
SprayableEntityto determine reactions.A value of less than or equal to
0should be interpreted as the item being unable to spraySprayableEntityinstances.The default implementation returns a duration of
40ticks.- Parameters:
stack- The item stack.- Returns:
- The duration in ticks.
- Since:
- 2.0.0
-
getMaxCharges
default int getMaxCharges(net.minecraft.item.ItemStack stack) Returns the maximum number of times the given item stack may be sprayed before requiring a refill.A value of
0means that the item may not be sprayed.The default implementation returns the stack's maximum damage amount. If this is overridden,
getCharges(ItemStack)andsetCharges(ItemStack, int)should also be updated.- Parameters:
stack- The item stack.- Returns:
- The number of charges.
- Since:
- 2.0.0
-
getCharges
default int getCharges(net.minecraft.item.ItemStack stack) Returns the number of times the given item stack may be sprayed before requiring a refill.A value of
0means that the item may not be sprayed.The default implementation returns the stack's remaining durability. If this is overridden,
getMaxCharges(ItemStack)andsetCharges(ItemStack, int)should also be updated.- Parameters:
stack- The item stack.- Returns:
- The number of charges.
- Since:
- 2.0.0
-
setCharges
default void setCharges(net.minecraft.item.ItemStack stack, int charges) Sets the number of times the given item stack may be sprayed before requiring a refill.The given value will never be outside [0,
getMaxCharges(ItemStack)].- Parameters:
stack- The item stack.charges- The number of charges.- Since:
- 2.0.0
-
isSprayable
default boolean isSprayable(net.minecraft.item.ItemStack stack, int charges) Returns whether the given item stack contains at leastchargesremaining charges and can therefore be sprayed.- Parameters:
stack- The item stack.charges- The required charges.- Returns:
- Whether the stack may be sprayed.
- Since:
- 2.0.0
-
isSprayable
default boolean isSprayable(net.minecraft.item.ItemStack stack) Returns whether the given item stack contains at least 1 remaining charge and can therefore be sprayed.- Parameters:
stack- The item stack.- Returns:
- Whether the stack may be sprayed.
- Since:
- 2.0.0
-
isFilled
default boolean isFilled(net.minecraft.item.ItemStack stack) Returns whether the given item stack is filled.The default implementation checks whether the current charges are at least the maximum.
- Parameters:
stack- The item stack.- Returns:
- Whether the stack may be refilled.
- Since:
- 2.0.0
-
isRefillable
default boolean isRefillable(net.minecraft.item.ItemStack stack) Returns whether the given item stack may be refilled.The default implementation checks whether the current charges are less than the maximum.
- Parameters:
stack- The item stack.- Returns:
- Whether the stack may be refilled.
- Since:
- 2.0.0
-
isEmpty
default boolean isEmpty(net.minecraft.item.ItemStack stack) Returns whether the given item stack is empty.The default implementation just asserts that the remaining charges are less than or equal to zero.
- Parameters:
stack- The item stack.- Returns:
- Whether the stack is empty.
- Since:
- 2.0.0
-
canSpray
Returns whether the given item stack may spray the target entity and consume the given charge count.- Parameters:
source- The spray source.target- The spray target.charges- The number of charges.- Returns:
- Whether the target may be sprayed.
- Since:
- 2.0.0
-
canSpray
Returns whether the given item stack may spray the target block and consume the given charge count.- Parameters:
source- The spray source.target- The spray target.charges- The number of charges.- Returns:
- Whether the block may be sprayed.
- Since:
- 2.0.0
-
onSpray
default Sprayed.SprayResult onSpray(Sprayed.Source source, Sprayed.EntityTarget target, boolean silent) Runs actions on a sprayed target, returning a result.- Parameters:
source- The spray source.target- The spray target.silent- Whether the spray sound should be skipped.- Returns:
- The spray result.
- Since:
- 2.0.0
-
onSpray
default Sprayed.SprayResult onSpray(Sprayed.Source source, Sprayed.BlockTarget target, boolean silent) Runs actions on a sprayed block, returning a result.- Parameters:
source- The spray source.target- The spray target.silent- Whether the spray sound should be skipped.- Returns:
- The spray result.
- Since:
- 2.0.0
-
spray
default boolean spray(net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity actor, net.minecraft.util.math.Vec3d from, net.minecraft.entity.Entity target, boolean silent) Sprays a target entity.This method should not be overwritten directly, instead you should prefer overwriting
onSpray(Source, EntityTarget, boolean).- Parameters:
stack- The item stack.actor- The actor entity.from- The source position.target- The target entity.silent- Whether the spray sound should be skipped.- Returns:
- Whether the target was sprayed.
- Since:
- 2.0.0
-
spray
default boolean spray(net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity actor, net.minecraft.util.math.Vec3d from, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.Direction side, boolean silent) Sprays a block.This method should not be overwritten directly, instead you should prefer overwriting
onSpray(Source, BlockTarget, boolean).- Parameters:
stack- The item stack.actor- The actor entity.from- The source position.world- The current world.pos- The block position.side- The sprayed side.silent- Whether the spray sound should be skipped.- Returns:
- Whether the target was sprayed.
- Since:
- 2.0.0
-
spray
default boolean spray(Sprayed.Source source, net.minecraft.world.World world, Sprayed.SprayResult result) Sprays the item.This should never be called directly. Instead, you want either
spray(ItemStack, LivingEntity, Vec3d, Entity, boolean)orspray(ItemStack, LivingEntity, Vec3d, World, BlockPos, Direction, boolean).- Parameters:
source- The spray source.result- The result of another spray method.- Returns:
- Whether the result was acted upon.
- Since:
- 2.0.0
-
refill
Refills the spray item using the given context.- Parameters:
source- The refill source.context- The refill context.- Since:
- 2.0.0
-
registerClient
default void registerClient()Description copied from interface:Registered.ClientRegisters this value on the client environment.The contained code will only ever run on the game client. If you only want the server or want both, see its sister interfaces.
- Specified by:
registerClientin interfaceRegistered.Client- See Also:
-