Package dev.latvian.mods.kubejs.item
Interface ItemBehaviorFunctions
- All Known Implementing Classes:
ArmorItemBuilder,ArmorItemBuilder.AnimalArmor,ArmorItemBuilder.Boots,ArmorItemBuilder.Chestplate,ArmorItemBuilder.Helmet,ArmorItemBuilder.Leggings,BlockItemBuilder,DiggerItemBuilder,DiggerItemBuilder.Axe,DiggerItemBuilder.Hoe,DiggerItemBuilder.Pickaxe,DiggerItemBuilder.Shovel,FluidBucketItemBuilder,HandheldItemBuilder,ItemBuilder,ItemModificationKubeEvent.ItemModifications,SeedItemBuilder,ShearsItemBuilder,SmithingTemplateItemBuilder,SwordItemBuilder
@ReturnsSelf
public interface ItemBehaviorFunctions
-
Method Summary
Modifier and TypeMethodDescriptiondefault ItemBehaviorFunctionsapplyEnchantments(BiFunction<net.minecraft.world.item.ItemStack, List<net.minecraft.world.item.enchantment.EnchantmentInstance>, net.minecraft.world.item.ItemStack> applyEnchantments) default ItemBehaviorFunctionsdefault ItemBehaviorFunctionsbarWidth(ToIntFunction<net.minecraft.world.item.ItemStack> barWidth) default ItemBehaviorFunctionscanBeHurtBy(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.damagesource.DamageSource> canBeHurtBy) default ItemBehaviorFunctionscanDisableShield(boolean canDisableShield) default ItemBehaviorFunctionscanDisableShield(ItemBehavior.DisableShieldTest canDisableShield) default ItemBehaviorFunctionscanElytraFly(boolean canElytraFly) default ItemBehaviorFunctionscanElytraFly(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> canElytraFly) default ItemBehaviorFunctionscanPerformAction(BiPredicate<net.minecraft.world.item.ItemStack, net.neoforged.neoforge.common.ItemAbility> canPerformAction) default ItemBehaviorFunctionscanWalkOnPowderedSnow(boolean canWalkOnPowderedSnow) default ItemBehaviorFunctionscanWalkOnPowderedSnow(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> canWalkOnPowderedSnow) default ItemBehaviorFunctionscraftingRemainingItem(UnaryOperator<net.minecraft.world.item.ItemStack> craftingRemainingItem) default ItemBehaviorFunctionsdisplayName(net.minecraft.network.chat.Component component, boolean formattedDisplayName) default ItemBehaviorFunctionselytraFlightTick(ItemBehavior.ElytraFlightTickCallback elytraFlightTick) default ItemBehaviorFunctionsfinishUsing(ItemBehavior.FinishUsingCallback finishUsing) default ItemBehaviorFunctionsfoodEaten(Consumer<FoodEatenKubeEvent> foodEaten) default ItemBehaviorFunctionsgetEntityLifespan(int lifespan) default ItemBehaviorFunctionsgetEntityLifespan(ToIntBiFunction<net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level> getEntityLifespan) default ItemBehaviorFunctionsglow(boolean glow) default ItemBehaviorFunctionshurtEnemy(Predicate<ItemBehavior.HurtEnemyContext> hurtEnemy) default ItemBehaviorFunctionsimmuneTo(List<net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>> damageTypes) default ItemBehaviorFunctionsisEnderMask(boolean isEnderMask) default ItemBehaviorFunctionsisEnderMask(ItemBehavior.EndermanMaskTest isEnderMask) default ItemBehaviorFunctionsisPiglinCurrency(boolean isPiglinCurrency) default ItemBehaviorFunctionsisPiglinCurrency(Predicate<net.minecraft.world.item.ItemStack> isPiglinCurrency) default ItemBehaviorFunctionsmakesPiglinsNeutral(boolean makesPiglinsNeutral) default ItemBehaviorFunctionsmakesPiglinsNeutral(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> makesPiglinsNeutral) default ItemBehaviorFunctionsdefault ItemBehaviorFunctionsonlyHurtBy(List<net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>> damageTypes) default ItemBehaviorFunctionsreleaseUsing(ItemBehavior.ReleaseUsingCallback releaseUsing) default ItemBehaviorFunctionstooltip(net.minecraft.network.chat.Component component) default ItemBehaviorFunctionsdefault ItemBehaviorFunctionsuseAnimation(net.minecraft.world.item.UseAnim anim) default ItemBehaviorFunctionsuseDuration(ToIntBiFunction<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> useDuration)
-
Method Details
-
kjs$getOrCreateBehavior
-
displayName
@HideFromJS default ItemBehaviorFunctions displayName(net.minecraft.network.chat.Component component, boolean formattedDisplayName) -
glow
@Info("Makes the item glow like enchanted, even if it\'s not enchanted.") default ItemBehaviorFunctions glow(boolean glow) -
tooltip
@Info("Adds a tooltip to the item.") default ItemBehaviorFunctions tooltip(net.minecraft.network.chat.Component component) -
barColor
@Info("Determines the color of the item\'s durability bar. Defaulted to vanilla behavior.") default ItemBehaviorFunctions barColor(Function<net.minecraft.world.item.ItemStack, KubeColor> barColor) -
barWidth
@Info("Determines the width of the item\'s durability bar. Defaulted to vanilla behavior.\n\nThe function should return a value between 0 and 13 (max width of the bar).\n") default ItemBehaviorFunctions barWidth(ToIntFunction<net.minecraft.world.item.ItemStack> barWidth) -
name
@Info("Sets the item\'s name dynamically.\n") default ItemBehaviorFunctions name(ItemBehavior.NameCallback name) -
useAnimation
@Info("Determines the animation of the item when used, e.g. eating food.") default ItemBehaviorFunctions useAnimation(net.minecraft.world.item.UseAnim anim) -
useDuration
@Info("The duration when the item is used.\n\nFor example, when eating food, this is the time it takes to eat the food.\nThis can change the eating speed, or be used for other things (like making a custom bow).\n") default ItemBehaviorFunctions useDuration(ToIntBiFunction<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> useDuration) -
use
@Info("Determines if player will start using the item.\n\nFor example, when eating food, returning true will make the player start eating the food.\n") default ItemBehaviorFunctions use(ItemBehavior.UseCallback use) -
finishUsing
@Info("When players finish using the item.\n\nThis is called only when `useDuration` ticks have passed.\n\nFor example, when eating food, this is called when the player has finished eating the food, so hunger is restored.\n") default ItemBehaviorFunctions finishUsing(ItemBehavior.FinishUsingCallback finishUsing) -
releaseUsing
@Info("When players did not finish using the item but released the right mouse button halfway through.\n\nAn example is the bow, where the arrow is shot when the player releases the right mouse button.\n\nTo ensure the bow won\'t finish using, Minecraft sets the `useDuration` to a very high number (1h).\n") default ItemBehaviorFunctions releaseUsing(ItemBehavior.ReleaseUsingCallback releaseUsing) -
hurtEnemy
@Info("Gets called when the item is used to hurt an entity.\n\nFor example, when using a sword to hit a mob, this is called.\n") default ItemBehaviorFunctions hurtEnemy(Predicate<ItemBehavior.HurtEnemyContext> hurtEnemy) -
foodEaten
-
isPiglinCurrency
@Info("Determines if piglins will give an item or something in exchange for the item.\n") default ItemBehaviorFunctions isPiglinCurrency(Predicate<net.minecraft.world.item.ItemStack> isPiglinCurrency) -
isPiglinCurrency
-
isEnderMask
@Info("Whether this item can be used to hide player head for enderman\n") default ItemBehaviorFunctions isEnderMask(ItemBehavior.EndermanMaskTest isEnderMask) -
isEnderMask
-
makesPiglinsNeutral
@Info("Determines if piglins will be neutral to the wearer of the item and will not attack on sight.\n\nHowever, this does not prevent piglins from being hostile due to other actions, or make piglins\nstop being hostile if they are already hostile.\n") default ItemBehaviorFunctions makesPiglinsNeutral(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> makesPiglinsNeutral) -
makesPiglinsNeutral
-
craftingRemainingItem
@Info("Returns the item that remains in the crafting grid (or furnace fuel) after crafting with this item programatically.\n\nReturning an empty stack or null will make the item be consumed as normal.\n\nAn example would be durability-consuming items, e.g. hammers or wrenches.\n") default ItemBehaviorFunctions craftingRemainingItem(UnaryOperator<net.minecraft.world.item.ItemStack> craftingRemainingItem) -
getEntityLifespan
@Info("Determines the lifespan in ticks of the item when it\'s dropped on the ground as an entity.\n\nUsed for items like Fluix Seeds to prevent them from despawning.\n") default ItemBehaviorFunctions getEntityLifespan(ToIntBiFunction<net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level> getEntityLifespan) -
getEntityLifespan
-
canDisableShield
@Info("Determines if the item can disable shield when attacking like axe does.\n") default ItemBehaviorFunctions canDisableShield(ItemBehavior.DisableShieldTest canDisableShield) -
canDisableShield
-
canElytraFly
@Info("Determines if the item allows player to do elytra flying when equipped in the chest slot.\n") default ItemBehaviorFunctions canElytraFly(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> canElytraFly) -
canElytraFly
-
elytraFlightTick
@Info("Called every tick when the player is flying with elytra with this item equipped in the chest slot.\n\nReturning false will stop the player from flying.\n") default ItemBehaviorFunctions elytraFlightTick(ItemBehavior.ElytraFlightTickCallback elytraFlightTick) -
canWalkOnPowderedSnow
@Info("Determines if the player can walk on powdered snow with this item worn in the feet slot.\n") default ItemBehaviorFunctions canWalkOnPowderedSnow(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.entity.LivingEntity> canWalkOnPowderedSnow) -
canWalkOnPowderedSnow
-
canPerformAction
@Info("Determines if the item can perform corresponding action. E.g. shearing sheep, stripping logs, etc.\n") default ItemBehaviorFunctions canPerformAction(BiPredicate<net.minecraft.world.item.ItemStack, net.neoforged.neoforge.common.ItemAbility> canPerformAction) -
canBeHurtBy
@Info("Determines if the item entity will be destroyed by the damage source.\n\nFor example, netherite items will not be destroyed by lava.\n") default ItemBehaviorFunctions canBeHurtBy(BiPredicate<net.minecraft.world.item.ItemStack, net.minecraft.world.damagesource.DamageSource> canBeHurtBy) -
onlyHurtBy
@Info("Determines if the item entity will be destroyed by listed damages types.\n\nAll other damages will be treated as normal. Passing [] will make the item immune to all damage.\n") default ItemBehaviorFunctions onlyHurtBy(List<net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>> damageTypes) -
immuneTo
@Info("Determines if the item entity will be immune to listed damages types.\n\nAll other damages will be treated as normal. Passing [] will have no effect.\n") default ItemBehaviorFunctions immuneTo(List<net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>> damageTypes) -
applyEnchantments
@Info("Returns the enchanted item stack after applying enchantments to the item.\n\nFor example, books will be transformed into enchanted books by using this.\n") default ItemBehaviorFunctions applyEnchantments(BiFunction<net.minecraft.world.item.ItemStack, List<net.minecraft.world.item.enchantment.EnchantmentInstance>, net.minecraft.world.item.ItemStack> applyEnchantments)
-