From f15a84b28564598b9a18350ab3c461c864477084 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 2 Oct 2022 23:22:28 +0700 Subject: [PATCH] Add charged sword variant to creative tab --- .../ru/dbotthepony/mc/otm/item/EnergySwordItem.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index cb850b249..3d05bab1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMultimap import com.google.common.collect.Multimap import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos +import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.entity.EquipmentSlot @@ -12,6 +13,7 @@ import net.minecraft.world.entity.ai.attributes.Attribute import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity @@ -177,6 +179,16 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE).tab(Ov return EnergyConsumerItem(stack, MAX_ENERGY) } + override fun fillItemCategory(p_41391_: CreativeModeTab, p_41392_: NonNullList) { + super.fillItemCategory(p_41391_, p_41392_) + + if (allowedIn(p_41391_)) { + p_41392_.add(ItemStack(this).also { + it.matteryEnergy?.receiveEnergyInner(MAX_ENERGY, false) + }) + } + } + override fun getAttributeModifiers( slot: EquipmentSlot, itemStack: ItemStack