From bf721de4cca879d6652eeca8b7dc70fbe3d57570 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Tue, 11 Mar 2025 18:34:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B5=E6=B1=A0=E7=89=A9?= =?UTF-8?q?=E5=93=81=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/init/ModItems.java | 4 +- .../item/{Battery.java => BatteryItem.java} | 11 +-- .../atsuishio/superbwarfare/item/Cell.java | 81 ------------------ .../textures/item/large_battery_pack.png | Bin 0 -> 518 bytes .../textures/item/medium_battery_pack.png | Bin 0 -> 480 bytes .../textures/item/small_battery_pack.png | Bin 0 -> 395 bytes .../recipes/battery_from_cell_crafting.json | 13 --- 7 files changed, 8 insertions(+), 101 deletions(-) rename src/main/java/com/atsuishio/superbwarfare/item/{Battery.java => BatteryItem.java} (92%) delete mode 100644 src/main/java/com/atsuishio/superbwarfare/item/Cell.java create mode 100644 src/main/resources/assets/superbwarfare/textures/item/large_battery_pack.png create mode 100644 src/main/resources/assets/superbwarfare/textures/item/medium_battery_pack.png create mode 100644 src/main/resources/assets/superbwarfare/textures/item/small_battery_pack.png delete mode 100644 src/main/resources/data/superbwarfare/recipes/battery_from_cell_crafting.json diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 02e311729..261c64669 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -171,8 +171,8 @@ public class ModItems { public static final RegistryObject SCHEELITE = ITEMS.register("scheelite", () -> new Item(new Item.Properties())); public static final RegistryObject RAW_SILVER = ITEMS.register("raw_silver", () -> new Item(new Item.Properties())); public static final RegistryObject DOG_TAG = ITEMS.register("dog_tag", DogTag::new); - public static final RegistryObject CELL = ITEMS.register("cell", Cell::new); - public static final RegistryObject BATTERY = ITEMS.register("battery", Battery::new); + public static final RegistryObject CELL = ITEMS.register("cell", () -> new BatteryItem(24000, new Item.Properties())); + public static final RegistryObject BATTERY = ITEMS.register("battery", () -> new BatteryItem(100000, new Item.Properties())); public static final RegistryObject TRANSCRIPT = ITEMS.register("transcript", Transcript::new); public static final RegistryObject FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/Battery.java b/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java similarity index 92% rename from src/main/java/com/atsuishio/superbwarfare/item/Battery.java rename to src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java index 216d70b4e..9eef0c959 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/Battery.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/BatteryItem.java @@ -17,15 +17,16 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; -public class Battery extends Item { - - public static final int MAX_ENERGY = 100000; +public class BatteryItem extends Item { private final Supplier energyCapacity; - public Battery() { + public static int MAX_ENERGY = 0; + + public BatteryItem(int maxEnergy, Properties properties) { super(new Properties().stacksTo(1)); - this.energyCapacity = () -> MAX_ENERGY; + this.energyCapacity = () -> maxEnergy; + MAX_ENERGY = maxEnergy; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/item/Cell.java b/src/main/java/com/atsuishio/superbwarfare/item/Cell.java deleted file mode 100644 index 25f756345..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/item/Cell.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.atsuishio.superbwarfare.item; - -import com.atsuishio.superbwarfare.capability.energy.ItemEnergyProvider; -import com.atsuishio.superbwarfare.client.tooltip.component.CellImageComponent; -import com.atsuishio.superbwarfare.init.ModItems; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; - -public class Cell extends Item { - - public static final int MAX_ENERGY = 24000; - - private final Supplier energyCapacity; - - public Cell() { - super(new Properties().stacksTo(1)); - this.energyCapacity = () -> MAX_ENERGY; - } - - @Override - public boolean isBarVisible(ItemStack pStack) { - if (!pStack.getCapability(ForgeCapabilities.ENERGY).isPresent()) { - return false; - } - - AtomicInteger energy = new AtomicInteger(0); - pStack.getCapability(ForgeCapabilities.ENERGY).ifPresent( - e -> energy.set(e.getEnergyStored()) - ); - return energy.get() != MAX_ENERGY; - } - - @Override - public int getBarWidth(ItemStack pStack) { - AtomicInteger energy = new AtomicInteger(0); - pStack.getCapability(ForgeCapabilities.ENERGY).ifPresent( - e -> energy.set(e.getEnergyStored()) - ); - - return Math.round((float) energy.get() * 13.0F / MAX_ENERGY); - } - - @Override - public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag tag) { - return new ItemEnergyProvider(stack, energyCapacity.get()); - } - - @Override - public int getBarColor(ItemStack pStack) { - return 0xFFFF00; - } - - @Override - public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) { - super.inventoryTick(stack, world, entity, slot, selected); - } - - public static ItemStack getGunInstance() { - ItemStack stack = new ItemStack(ModItems.TASER.get()); - stack.getCapability(ForgeCapabilities.ENERGY).ifPresent( - energy -> energy.receiveEnergy(MAX_ENERGY, false) - ); - return stack; - } - - @Override - public @NotNull Optional getTooltipImage(@NotNull ItemStack pStack) { - return Optional.of(new CellImageComponent(pStack)); - } -} diff --git a/src/main/resources/assets/superbwarfare/textures/item/large_battery_pack.png b/src/main/resources/assets/superbwarfare/textures/item/large_battery_pack.png new file mode 100644 index 0000000000000000000000000000000000000000..65cb1af6247e96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IR(J;oR=mkY)ij>qFG-4L=~ puT?}eNs=#v`ze8k{PN!4>I1ymkuC|^22}t6002ovPDHLkV1h%Lr?mh8 literal 0 HcmV?d00001 diff --git a/src/main/resources/data/superbwarfare/recipes/battery_from_cell_crafting.json b/src/main/resources/data/superbwarfare/recipes/battery_from_cell_crafting.json deleted file mode 100644 index 742876f72..000000000 --- a/src/main/resources/data/superbwarfare/recipes/battery_from_cell_crafting.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category":"misc", - "ingredients": [ - { - "item":"superbwarfare:battery" - } - ], - "result": { - "item": "superbwarfare:cell", - "count": 4 - } -} \ No newline at end of file