From e9c968f5698c4d332c4d41917cbb9c647c63bf07 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Fri, 31 Jan 2025 01:49:38 -0500 Subject: [PATCH] Firefly Bottle in creative inventory has component --- .../registry/WWCreativeInventorySorting.java | 10 ++++++++++ .../net/frozenblock/wilderwild/registry/WWItems.java | 7 +------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/frozenblock/wilderwild/registry/WWCreativeInventorySorting.java b/src/main/java/net/frozenblock/wilderwild/registry/WWCreativeInventorySorting.java index f8a52f781f..7c7ba2f74d 100644 --- a/src/main/java/net/frozenblock/wilderwild/registry/WWCreativeInventorySorting.java +++ b/src/main/java/net/frozenblock/wilderwild/registry/WWCreativeInventorySorting.java @@ -21,6 +21,7 @@ import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.frozenblock.lib.item.api.FrozenCreativeTabs; import net.frozenblock.lib.item.api.ItemBlockStateTagUtils; +import net.frozenblock.wilderwild.entity.variant.firefly.FireflyColors; import net.frozenblock.wilderwild.tag.WWInstrumentTags; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.TagKey; @@ -338,6 +339,15 @@ public static void init() { // FIREFLY addAfterInSpawnEggs(Items.EVOKER_SPAWN_EGG, WWItems.FIREFLY_SPAWN_EGG); + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(entries -> { + var stack = new ItemStack(WWItems.FIREFLY_BOTTLE); + stack.setCount(1); + stack.set( + WWDataComponents.FIREFLY_COLOR, + entries.getContext().holders().lookupOrThrow(WilderWildRegistries.FIREFLY_COLOR).getOrThrow(FireflyColors.DEFAULT) + ); + entries.accept(stack); + }); addInToolsAndUtilities(WWItems.FIREFLY_BOTTLE); // BUTTERFLY diff --git a/src/main/java/net/frozenblock/wilderwild/registry/WWItems.java b/src/main/java/net/frozenblock/wilderwild/registry/WWItems.java index 93e7496156..086c9161ae 100644 --- a/src/main/java/net/frozenblock/wilderwild/registry/WWItems.java +++ b/src/main/java/net/frozenblock/wilderwild/registry/WWItems.java @@ -166,12 +166,7 @@ public final class WWItems { WWSounds.ITEM_BOTTLE_RELEASE_FIREFLY, properties ), - new Item.Properties() - .stacksTo(16) - .component( - WWDataComponents.BOTTLE_ENTITY_DATA, - CustomData.EMPTY.update(compoundTag -> compoundTag.putString("FireflyBottleVariantTag", FireflyColors.DEFAULT.location().toString())) - ) + new Item.Properties().stacksTo(16).component(WWDataComponents.BOTTLE_ENTITY_DATA, CustomData.EMPTY) ); public static final MobBottleItem BUTTERFLY_BOTTLE = register("butterfly_bottle", properties -> new MobBottleItem(