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 000000000..65cb1af62 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/item/large_battery_pack.png differ diff --git a/src/main/resources/assets/superbwarfare/textures/item/medium_battery_pack.png b/src/main/resources/assets/superbwarfare/textures/item/medium_battery_pack.png new file mode 100644 index 000000000..91cb955d8 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/item/medium_battery_pack.png differ diff --git a/src/main/resources/assets/superbwarfare/textures/item/small_battery_pack.png b/src/main/resources/assets/superbwarfare/textures/item/small_battery_pack.png new file mode 100644 index 000000000..3cdb69272 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/item/small_battery_pack.png differ 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