Class ItemBuilder

java.lang.Object
dev.latvian.mods.kubejs.registry.BuilderBase<net.minecraft.world.item.Item>
dev.latvian.mods.kubejs.registry.ModelledBuilderBase<net.minecraft.world.item.Item>
dev.latvian.mods.kubejs.item.ItemBuilder
All Implemented Interfaces:
Supplier<net.minecraft.world.item.Item>
Direct Known Subclasses:
ArmorItemBuilder, BlockItemBuilder, FluidBucketItemBuilder, HandheldItemBuilder, ShearsItemBuilder, SmithingTemplateItemBuilder

@ReturnsSelf public class ItemBuilder extends ModelledBuilderBase<net.minecraft.world.item.Item>
  • Field Details

    • components

      public transient Map<Object,Object> components
    • maxStackSize

      public transient int maxStackSize
    • maxDamage

      public transient int maxDamage
    • burnTime

      public transient int burnTime
    • subtypes

      public transient Function<net.minecraft.world.item.ItemStack,Collection<net.minecraft.world.item.ItemStack>> subtypes
    • rarity

      public transient net.minecraft.world.item.Rarity rarity
    • fireResistant

      public transient boolean fireResistant
    • glow

      public transient boolean glow
    • tooltip

      public final transient List<net.minecraft.network.chat.Component> tooltip
    • tint

      @Nullable public transient @Nullable ItemTintFunction tint
    • foodBuilder

      public transient FoodBuilder foodBuilder
    • barColor

      public transient Function<net.minecraft.world.item.ItemStack,KubeColor> barColor
    • barWidth

      public transient ToIntFunction<net.minecraft.world.item.ItemStack> barWidth
    • nameGetter

      public transient ItemBuilder.NameCallback nameGetter
    • anim

      public transient net.minecraft.world.item.UseAnim anim
    • useDuration

      public transient ToIntBiFunction<net.minecraft.world.item.ItemStack,net.minecraft.world.entity.LivingEntity> useDuration
    • use

      public transient ItemBuilder.UseCallback use
    • finishUsing

      public transient ItemBuilder.FinishUsingCallback finishUsing
    • releaseUsing

      public transient ItemBuilder.ReleaseUsingCallback releaseUsing
    • hurtEnemy

      public transient Predicate<ItemBuilder.HurtEnemyContext> hurtEnemy
    • jukeboxPlayable

      public transient net.minecraft.world.item.JukeboxPlayable jukeboxPlayable
    • tool

      public transient net.minecraft.world.item.component.Tool tool
    • itemAttributeModifiers

      public transient net.minecraft.world.item.component.ItemAttributeModifiers itemAttributeModifiers
    • canRepair

      public transient boolean canRepair
  • Constructor Details

    • ItemBuilder

      public ItemBuilder(net.minecraft.resources.ResourceLocation id)
  • Method Details

    • createObject

      public net.minecraft.world.item.Item createObject()
      Specified by:
      createObject in class BuilderBase<net.minecraft.world.item.Item>
    • transformObject

      public net.minecraft.world.item.Item transformObject(net.minecraft.world.item.Item obj)
      Overrides:
      transformObject in class BuilderBase<net.minecraft.world.item.Item>
    • generateAssets

      public void generateAssets(KubeAssetGenerator generator)
      Overrides:
      generateAssets in class BuilderBase<net.minecraft.world.item.Item>
    • generateItemModels

      protected void generateItemModels(KubeAssetGenerator generator)
    • component

      public <T> ItemBuilder component(net.minecraft.core.component.DataComponentType<T> type, T value)
    • maxStackSize

      @Info("Sets the item\'s max stack size. Default is 64.") public ItemBuilder maxStackSize(int v)
    • unstackable

      @Info("Makes the item not stackable, equivalent to setting the item\'s max stack size to 1.") public ItemBuilder unstackable()
    • maxDamage

      @Info("Sets the item\'s max damage. Default is 0 (No durability).") public ItemBuilder maxDamage(int v)
    • burnTime

      @Info("Sets the item\'s burn time. Default is 0 (Not a fuel).") public ItemBuilder burnTime(TickDuration v)
    • containerItem

      @Info("Sets the item\'s container item, e.g. a bucket for a milk bucket.") public ItemBuilder containerItem(net.minecraft.resources.ResourceLocation id)
    • subtypes

      @Info("Adds subtypes to the item. The function should return a collection of item stacks, each with a different subtype.\n\nEach subtype will appear as a separate item in JEI and the creative inventory.\n") public ItemBuilder subtypes(Function<net.minecraft.world.item.ItemStack,Collection<net.minecraft.world.item.ItemStack>> fn)
    • rarity

      @Info("Sets the item\'s rarity.") public ItemBuilder rarity(net.minecraft.world.item.Rarity v)
    • glow

      @Info("Makes the item glow like enchanted, even if it\'s not enchanted.") public ItemBuilder glow(boolean v)
    • tooltip

      @Info("Adds a tooltip to the item.") public ItemBuilder tooltip(net.minecraft.network.chat.Component text)
    • group

      @Deprecated public ItemBuilder group(@Nullable @Nullable String g)
      Deprecated.
    • color

      @Info("Colorizes item\'s texture of the given index. Index is used when you have multiple layers, e.g. a crushed ore (of rock + ore).") public ItemBuilder color(int index, ItemTintFunction color)
    • color

      @Info("Colorizes item\'s texture of the given index. Useful for coloring items, like GT ores ore dusts.") public ItemBuilder color(ItemTintFunction callback)
    • barColor

      @Info("Determines the color of the item\'s durability bar. Defaulted to vanilla behavior.") public ItemBuilder 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") public ItemBuilder barWidth(ToIntFunction<net.minecraft.world.item.ItemStack> barWidth)
    • name

      @Info("Sets the item\'s name dynamically.\n") public ItemBuilder name(ItemBuilder.NameCallback name)
    • food

      @Info("Set the food properties of the item.\n") public ItemBuilder food(Consumer<FoodBuilder> b)
    • food

      @Info("Set the food nutrition and saturation of the item.\n") public ItemBuilder food(int nutrition, float saturation)
    • fireResistant

      @Info("Makes the item fire resistant like netherite tools (or not).") public ItemBuilder fireResistant(boolean isFireResistant)
    • fireResistant

      @Info("Makes the item fire resistant like netherite tools.") public ItemBuilder fireResistant()
    • useAnimation

      @Info("Determines the animation of the item when used, e.g. eating food.") public ItemBuilder useAnimation(net.minecraft.world.item.UseAnim animation)
    • 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") public ItemBuilder 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") public ItemBuilder use(ItemBuilder.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") public ItemBuilder finishUsing(ItemBuilder.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") public ItemBuilder releaseUsing(ItemBuilder.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") public ItemBuilder hurtEnemy(Predicate<ItemBuilder.HurtEnemyContext> context)
    • jukeboxPlayable

      public ItemBuilder jukeboxPlayable(net.minecraft.resources.ResourceKey<net.minecraft.world.item.JukeboxSong> song, boolean showInTooltip)
    • jukeboxPlayable

      public ItemBuilder jukeboxPlayable(net.minecraft.resources.ResourceKey<net.minecraft.world.item.JukeboxSong> song)
    • disableRepair

      public ItemBuilder disableRepair()
    • createItemProperties

      public net.minecraft.world.item.Item.Properties createItemProperties()