Battery now have charged variant in creative menu
This commit is contained in:
parent
bddc148423
commit
1050ccb5fc
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.item
|
||||
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
@ -41,6 +42,10 @@ open class BatteryItem : Item {
|
||||
return if (isCreative) ImpreciseFraction.LONG_MAX_VALUE else super.missingPower
|
||||
}
|
||||
|
||||
fun maxPower() {
|
||||
batteryLevel = maxBatteryLevel
|
||||
}
|
||||
|
||||
override var batteryLevel: ImpreciseFraction
|
||||
get() { return if (isCreative) ImpreciseFraction.LONG_MAX_VALUE else super.batteryLevel }
|
||||
set(value) { super.batteryLevel = value }
|
||||
@ -141,6 +146,20 @@ open class BatteryItem : Item {
|
||||
}
|
||||
}
|
||||
|
||||
override fun fillItemCategory(p_41391_: CreativeModeTab, p_41392_: NonNullList<ItemStack>) {
|
||||
super.fillItemCategory(p_41391_, p_41392_)
|
||||
|
||||
if (allowedIn(p_41391_)) {
|
||||
p_41392_.add(ItemStack(this).also {
|
||||
it.matteryEnergy?.let {
|
||||
if (it is Power) {
|
||||
it.maxPower()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider {
|
||||
return Power(stack)
|
||||
}
|
||||
@ -153,10 +172,10 @@ open class BatteryItem : Item {
|
||||
|
||||
class CrudeBatteryItem : BatteryItem(ServerConfig.BATTERY_CRUDE) {
|
||||
override fun appendHoverText(
|
||||
stack: ItemStack,
|
||||
p_41422_: Level?,
|
||||
p_41423_: MutableList<Component>,
|
||||
p_41424_: TooltipFlag
|
||||
stack: ItemStack,
|
||||
p_41422_: Level?,
|
||||
p_41423_: MutableList<Component>,
|
||||
p_41424_: TooltipFlag
|
||||
) {
|
||||
super.appendHoverText(stack, p_41422_, p_41423_, p_41424_)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user