From ce371f2e30b678c2146e12735b04bafd19dfb664 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Tue, 11 Mar 2025 19:28:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B5=E6=B1=A0=E6=BB=A1?= =?UTF-8?q?=E8=83=BD=E9=87=8F=E7=89=A9=E5=93=81=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/atsuishio/superbwarfare/init/ModTabs.java | 4 ++++ .../com/atsuishio/superbwarfare/item/BatteryItem.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModTabs.java b/src/main/java/com/atsuishio/superbwarfare/init/ModTabs.java index 8599a8912..628f996c0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModTabs.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModTabs.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.init; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.item.ArmorPlate; +import com.atsuishio.superbwarfare.item.BatteryItem; import com.atsuishio.superbwarfare.item.gun.handgun.*; import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item; import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem; @@ -127,6 +128,9 @@ public class ModTabs { if (registryObject.get() == ModItems.ARMOR_PLATE.get()) { output.accept(ArmorPlate.getInfiniteInstance()); } + if (registryObject.get() instanceof BatteryItem batteryItem) { + output.accept(batteryItem.makeFullEnergyStack()); + } } })) .build()); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java b/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java index 7a453f245..15b8feec7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java @@ -62,4 +62,12 @@ public class BatteryItem extends Item { public @NotNull Optional getTooltipImage(@NotNull ItemStack pStack) { return Optional.of(new CellImageComponent(pStack)); } + + public ItemStack makeFullEnergyStack() { + ItemStack stack = new ItemStack(this); + stack.getCapability(ForgeCapabilities.ENERGY).ifPresent( + e -> e.receiveEnergy(maxEnergy, false) + ); + return stack; + } }