From 13ea3232df9a62b65e69c1c1c1d07dd856a98484 Mon Sep 17 00:00:00 2001 From: pietro-lopes <97140255+pietro-lopes@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:51:12 -0300 Subject: [PATCH] fixed jukebox and added disableRepair --- .../latvian/mods/kubejs/item/ItemBuilder.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/latvian/mods/kubejs/item/ItemBuilder.java b/src/main/java/dev/latvian/mods/kubejs/item/ItemBuilder.java index 872172c3f..a028c4476 100644 --- a/src/main/java/dev/latvian/mods/kubejs/item/ItemBuilder.java +++ b/src/main/java/dev/latvian/mods/kubejs/item/ItemBuilder.java @@ -9,10 +9,10 @@ import dev.latvian.mods.kubejs.script.ConsoleJS; import dev.latvian.mods.kubejs.typings.Info; import dev.latvian.mods.rhino.util.ReturnsSelf; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.LivingEntity; @@ -79,6 +79,7 @@ public record HurtEnemyContext(ItemStack getItem, LivingEntity getTarget, Living public transient Tool tool; public transient ItemAttributeModifiers itemAttributeModifiers; + public transient boolean canRepair; public ItemBuilder(ResourceLocation i) { super(i); @@ -104,6 +105,7 @@ public ItemBuilder(ResourceLocation i) { tool = null; itemAttributeModifiers = null; + canRepair = true; } @Override @@ -377,15 +379,20 @@ public ItemBuilder hurtEnemy(Predicate context) { return this; } - public ItemBuilder jukeboxPlayable(Holder song, boolean showInTooltip) { + public ItemBuilder jukeboxPlayable(ResourceKey song, boolean showInTooltip) { this.jukeboxPlayable = new JukeboxPlayable(new EitherHolder<>(song), showInTooltip); return this; } - public ItemBuilder jukeboxPlayable(Holder song) { + public ItemBuilder jukeboxPlayable(ResourceKey song) { return jukeboxPlayable(song, true); } + public ItemBuilder disableRepair() { + this.canRepair = false; + return this; + } + @FunctionalInterface public interface UseCallback { boolean use(Level level, Player player, InteractionHand interactionHand); @@ -457,6 +464,10 @@ public Item.Properties createItemProperties() { properties.component(DataComponents.JUKEBOX_PLAYABLE, jukeboxPlayable); } + if (!canRepair) { + properties.setNoRepair(); + } + return properties; } } \ No newline at end of file