diff --git a/src/main/java/com/atsuishio/superbwarfare/capability/player/PlayerVariable.java b/src/main/java/com/atsuishio/superbwarfare/capability/player/PlayerVariable.java index 9a7b3b033..fd84bbdd6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/capability/player/PlayerVariable.java +++ b/src/main/java/com/atsuishio/superbwarfare/capability/player/PlayerVariable.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.capability.player; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.network.message.receive.PlayerVariablesSyncMessage; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; @@ -24,7 +24,7 @@ import java.util.Map; public class PlayerVariable implements INBTSerializable { private PlayerVariable old = null; - public Map ammo = new HashMap<>(); + public Map ammo = new HashMap<>(); public boolean tacticalSprint = false; public boolean edit = false; @@ -54,7 +54,7 @@ public class PlayerVariable implements INBTSerializable { public CompoundTag writeToNBT() { CompoundTag nbt = new CompoundTag(); - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.set(nbt, type.get(this)); } @@ -65,7 +65,7 @@ public class PlayerVariable implements INBTSerializable { } public PlayerVariable readFromNBT(CompoundTag tag) { - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.set(this, type.get(tag)); } @@ -78,7 +78,7 @@ public class PlayerVariable implements INBTSerializable { public PlayerVariable copy() { var clone = new PlayerVariable(); - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.set(clone, type.get(this)); } @@ -92,7 +92,7 @@ public class PlayerVariable implements INBTSerializable { public boolean equals(Object obj) { if (!(obj instanceof PlayerVariable other)) return false; - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { if (type.get(this) != type.get(other)) return false; } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoCountOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoCountOverlay.java index 87e95cc95..302d99fdf 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoCountOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoCountOverlay.java @@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.item.common.ammo.AmmoSupplierItem; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.animation.AnimationCurves; import com.atsuishio.superbwarfare.tools.animation.AnimationTimer; import com.atsuishio.superbwarfare.tools.animation.ValueAnimator; @@ -38,10 +38,10 @@ public class AmmoCountOverlay implements LayeredDraw.Layer { .backwardAnimation(AnimationCurves.EASE_IN_EXPO); private static final ValueAnimator[] ammoCountAnimators = ValueAnimator.create( - AmmoType.values().length, 800, 0 + Ammo.values().length, 800, 0 ); private static final ValueAnimator[] ammoBoxAnimators = ValueAnimator.create( - AmmoType.values().length, 800, 0 + Ammo.values().length, 800, 0 ); /** @@ -86,13 +86,13 @@ public class AmmoCountOverlay implements LayeredDraw.Layer { var ammoX = ammoInfoTimer.lerp(w + 120, (float) w / 2 + 40, currentTime); final int fontHeight = 15; - var yOffset = (-h - AmmoType.values().length * fontHeight) / 2f; + var yOffset = (-h - Ammo.values().length * fontHeight) / 2f; // 渲染总弹药数量 var cap = player.getData(ModAttachments.PLAYER_VARIABLE); var font = Minecraft.getInstance().font; - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { var index = type.ordinal(); var ammoCount = type.get(cap); var animator = ammoCountAnimators[index]; diff --git a/src/main/java/com/atsuishio/superbwarfare/command/AmmoCommand.java b/src/main/java/com/atsuishio/superbwarfare/command/AmmoCommand.java index 569fa4109..7c985405b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/command/AmmoCommand.java +++ b/src/main/java/com/atsuishio/superbwarfare/command/AmmoCommand.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.command; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.commands.CommandSourceStack; @@ -15,7 +15,7 @@ public class AmmoCommand { public static LiteralArgumentBuilder get() { // mojang你看看你写的是个牛魔Builder😅 return Commands.literal("ammo").requires(s -> s.hasPermission(0)) - .then(Commands.literal("get").then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("type", EnumArgument.enumArgument(AmmoType.class)).executes(context -> { + .then(Commands.literal("get").then(Commands.argument("player", EntityArgument.player()).then(Commands.argument("type", EnumArgument.enumArgument(Ammo.class)).executes(context -> { var player = EntityArgument.getPlayer(context, "player"); var source = context.getSource(); @@ -28,15 +28,15 @@ public class AmmoCommand { } } - var type = context.getArgument("type", AmmoType.class); + var type = context.getArgument("type", Ammo.class); var value = type.get(player); context.getSource().sendSuccess(() -> Component.translatable("commands.ammo.get", Component.translatable(type.translatableKey), value), true); return 0; })))) - .then(Commands.literal("set").requires(s -> s.hasPermission(2)).then(Commands.argument("players", EntityArgument.players()).then(Commands.argument("type", EnumArgument.enumArgument(AmmoType.class)).then(Commands.argument("value", IntegerArgumentType.integer(0)).executes(context -> { + .then(Commands.literal("set").requires(s -> s.hasPermission(2)).then(Commands.argument("players", EntityArgument.players()).then(Commands.argument("type", EnumArgument.enumArgument(Ammo.class)).then(Commands.argument("value", IntegerArgumentType.integer(0)).executes(context -> { var players = EntityArgument.getPlayers(context, "players"); - var type = context.getArgument("type", AmmoType.class); + var type = context.getArgument("type", Ammo.class); var value = IntegerArgumentType.getInteger(context, "value"); for (var player : players) { @@ -46,9 +46,9 @@ public class AmmoCommand { context.getSource().sendSuccess(() -> Component.translatable("commands.ammo.set", Component.translatable(type.translatableKey), value, players.size()), true); return 0; }))))) - .then(Commands.literal("add").requires(s -> s.hasPermission(2)).then(Commands.argument("players", EntityArgument.players()).then(Commands.argument("type", EnumArgument.enumArgument(AmmoType.class)).then(Commands.argument("value", IntegerArgumentType.integer(0)).executes(context -> { + .then(Commands.literal("add").requires(s -> s.hasPermission(2)).then(Commands.argument("players", EntityArgument.players()).then(Commands.argument("type", EnumArgument.enumArgument(Ammo.class)).then(Commands.argument("value", IntegerArgumentType.integer(0)).executes(context -> { var players = EntityArgument.getPlayers(context, "players"); - var type = context.getArgument("type", AmmoType.class); + var type = context.getArgument("type", Ammo.class); var value = IntegerArgumentType.getInteger(context, "value"); for (var player : players) { diff --git a/src/main/java/com/atsuishio/superbwarfare/component/ModDataComponents.java b/src/main/java/com/atsuishio/superbwarfare/component/ModDataComponents.java index e71c05b71..f42923618 100644 --- a/src/main/java/com/atsuishio/superbwarfare/component/ModDataComponents.java +++ b/src/main/java/com/atsuishio/superbwarfare/component/ModDataComponents.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.component; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.item.FiringParameters; import com.atsuishio.superbwarfare.item.common.ammo.box.AmmoBoxInfo; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -54,7 +54,7 @@ public class ModDataComponents { } public static void register(IEventBus eventBus) { - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.dataComponent = register("ammo_" + type.name.toLowerCase(), builder -> builder.persistent(Codec.INT)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index 1eafee34a..58a2fe008 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -17,7 +17,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.ParticleTool; @@ -208,10 +208,10 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity int ammoCount = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; - }).mapToInt(AmmoType.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get()); + }).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get()); if ((hasItem(ModItems.ROCKET_70.get()) || InventoryTool.hasCreativeAmmoBox(player)) && reloadCoolDown == 0 && this.getEntityData().get(LOADED_ROCKET) < 14) { this.entityData.set(LOADED_ROCKET, this.getEntityData().get(LOADED_ROCKET) + 1); @@ -562,13 +562,13 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.HEAVY.add(ammoBox, -1); + Ammo.HEAVY.add(ammoBox, -1); } else { this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 82b4f98c8..0e415fc78 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -20,7 +20,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.ParticleTool; @@ -252,10 +252,10 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit int ammoCount = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.RIFLE.get(stack) > 0; + return Ammo.RIFLE.get(stack) > 0; } return false; - }).mapToInt(AmmoType.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get()); + }).mapToInt(Ammo.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get()); if ((hasItem(ModItems.WIRE_GUIDE_MISSILE.get()) || InventoryTool.hasCreativeAmmoBox(player)) @@ -353,13 +353,13 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.RIFLE.get(stack) > 0; + return Ammo.RIFLE.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.RIFLE.add(ammoBox, -1); + Ammo.RIFLE.add(ammoBox, -1); } else { this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 3b73608d1..e745bda31 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -19,7 +19,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.ParticleTool; @@ -206,10 +206,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt int ammoCount = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.RIFLE.get(stack) > 0; + return Ammo.RIFLE.get(stack) > 0; } return false; - }).mapToInt(AmmoType.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get()); + }).mapToInt(Ammo.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get()); if (getWeaponIndex(0) == 0) { this.entityData.set(AMMO, countItem(ModItems.SMALL_SHELL.get())); @@ -301,13 +301,13 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.RIFLE.get(stack) > 0; + return Ammo.RIFLE.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.RIFLE.add(ammoBox, -1); + Ammo.RIFLE.add(ammoBox, -1); } else { this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index bd01c904e..acb4172ba 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -13,7 +13,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.ParticleTool; @@ -179,10 +179,10 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo int ammoCount = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; - }).mapToInt(AmmoType.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get()); + }).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get()); this.entityData.set(AMMO, ammoCount); @@ -247,13 +247,13 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.HEAVY.add(ammoBox, -1); + Ammo.HEAVY.add(ammoBox, -1); } else { this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index 3234ff4ac..0d2dafecc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -509,13 +509,13 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.HEAVY.add(ammoBox, -1); + Ammo.HEAVY.add(ammoBox, -1); } else { this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } @@ -576,13 +576,13 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) { - return AmmoType.HEAVY.get(stack) > 0; + return Ammo.HEAVY.get(stack) > 0; } return false; }).findFirst().orElse(ItemStack.EMPTY); if (!ammoBox.isEmpty()) { - AmmoType.HEAVY.add(ammoBox, -1); + Ammo.HEAVY.add(ammoBox, -1); } else { consumeItem(getWeapon(1).ammo, 1); } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index e94afdf63..18573e50e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -11,7 +11,7 @@ import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.value.ReloadState; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.SoundTool; import net.minecraft.core.Holder; @@ -255,15 +255,6 @@ public class GunEventHandler { } } - public static double perkDamage(ItemStack stack) { - var data = GunData.from(stack); - var perk = data.perk.get(Perk.Type.AMMO); - if (perk instanceof AmmoPerk ammoPerk) { - return ammoPerk.damageRate; - } - return 1; - } - public static double perkSpeed(GunData data) { var perk = data.perk.get(Perk.Type.AMMO); if (perk instanceof AmmoPerk ammoPerk) { @@ -453,7 +444,7 @@ public class GunEventHandler { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var type = AmmoType.getType(ammoTypeInfo.value()); + var type = Ammo.getType(ammoTypeInfo.value()); assert type != null; if (type.get(capability) == 0) { @@ -534,7 +525,7 @@ public class GunEventHandler { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var type = AmmoType.getType(ammoTypeInfo.value()); + var type = Ammo.getType(ammoTypeInfo.value()); assert type != null; if (type.get(capability) == 0) { diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 83eeef41c..dc0dadf55 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -654,7 +654,7 @@ public class LivingEventHandler { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var type = AmmoType.getType(ammoTypeInfo.value()); + var type = Ammo.getType(ammoTypeInfo.value()); assert type != null; int ammoFinal = Math.min(type.get(cap), ammoNeed); @@ -732,14 +732,14 @@ public class LivingEventHandler { if (event.getEntity() instanceof Player player && !player.level().getLevelData().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) { var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch(); - boolean drop = Stream.of(AmmoType.values()) + boolean drop = Stream.of(Ammo.values()) .mapToInt(type -> type.get(cap)) .sum() > 0; if (drop) { var stack = new ItemStack(ModItems.AMMO_BOX.get()); - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.set(stack, type.get(cap)); type.set(cap, 0); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 1ed6e8c59..97abc90e8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -25,7 +25,7 @@ import com.atsuishio.superbwarfare.item.gun.smg.VectorItem; import com.atsuishio.superbwarfare.item.gun.sniper.*; import com.atsuishio.superbwarfare.item.gun.special.BocekItem; import com.atsuishio.superbwarfare.item.gun.special.TaserItem; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.world.item.BlockItem; @@ -91,11 +91,11 @@ public class ModItems { */ public static final DeferredRegister AMMO = DeferredRegister.create(BuiltInRegistries.ITEM, Mod.MODID); - public static final DeferredHolder HANDGUN_AMMO = AMMO.register("handgun_ammo", () -> new AmmoSupplierItem(AmmoType.HANDGUN, 1, new Item.Properties())); - public static final DeferredHolder RIFLE_AMMO = AMMO.register("rifle_ammo", () -> new AmmoSupplierItem(AmmoType.RIFLE, 1, new Item.Properties())); - public static final DeferredHolder SNIPER_AMMO = AMMO.register("sniper_ammo", () -> new AmmoSupplierItem(AmmoType.SNIPER, 1, new Item.Properties())); - public static final DeferredHolder SHOTGUN_AMMO = AMMO.register("shotgun_ammo", () -> new AmmoSupplierItem(AmmoType.SHOTGUN, 1, new Item.Properties())); - public static final DeferredHolder HEAVY_AMMO = AMMO.register("heavy_ammo", () -> new AmmoSupplierItem(AmmoType.HEAVY, 1, new Item.Properties())); + public static final DeferredHolder HANDGUN_AMMO = AMMO.register("handgun_ammo", () -> new AmmoSupplierItem(Ammo.HANDGUN, 1, new Item.Properties())); + public static final DeferredHolder RIFLE_AMMO = AMMO.register("rifle_ammo", () -> new AmmoSupplierItem(Ammo.RIFLE, 1, new Item.Properties())); + public static final DeferredHolder SNIPER_AMMO = AMMO.register("sniper_ammo", () -> new AmmoSupplierItem(Ammo.SNIPER, 1, new Item.Properties())); + public static final DeferredHolder SHOTGUN_AMMO = AMMO.register("shotgun_ammo", () -> new AmmoSupplierItem(Ammo.SHOTGUN, 1, new Item.Properties())); + public static final DeferredHolder HEAVY_AMMO = AMMO.register("heavy_ammo", () -> new AmmoSupplierItem(Ammo.HEAVY, 1, new Item.Properties())); public static final DeferredHolder HANDGUN_AMMO_BOX = AMMO.register("handgun_ammo_box", HandgunAmmoBox::new); public static final DeferredHolder RIFLE_AMMO_BOX = AMMO.register("rifle_ammo_box", RifleAmmoBox::new); public static final DeferredHolder SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/AmmoSupplierItem.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/AmmoSupplierItem.java index c1517f2b6..c91eb5219 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/AmmoSupplierItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/AmmoSupplierItem.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.item.common.ammo; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundSource; @@ -20,10 +20,10 @@ import java.util.List; public class AmmoSupplierItem extends Item { - public final AmmoType type; + public final Ammo type; public final int ammoToAdd; - public AmmoSupplierItem(AmmoType type, int ammoToAdd, Properties properties) { + public AmmoSupplierItem(Ammo type, int ammoToAdd, Properties properties) { super(properties); this.type = type; this.ammoToAdd = ammoToAdd; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/HandgunAmmoBox.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/HandgunAmmoBox.java index b9be96af8..dbdf2db4d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/HandgunAmmoBox.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/HandgunAmmoBox.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.item.common.ammo; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -12,7 +12,7 @@ import java.util.List; public class HandgunAmmoBox extends AmmoSupplierItem { public HandgunAmmoBox() { - super(AmmoType.HANDGUN, 30, new Properties()); + super(Ammo.HANDGUN, 30, new Properties()); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/RifleAmmoBox.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/RifleAmmoBox.java index decba516c..2f5432e89 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/RifleAmmoBox.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/RifleAmmoBox.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.item.common.ammo; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -12,7 +12,7 @@ import java.util.List; public class RifleAmmoBox extends AmmoSupplierItem { public RifleAmmoBox() { - super(AmmoType.RIFLE, 30, new Properties()); + super(Ammo.RIFLE, 30, new Properties()); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/ShotgunAmmoBox.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/ShotgunAmmoBox.java index 1f2a00978..9e573bb92 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/ShotgunAmmoBox.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/ShotgunAmmoBox.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.item.common.ammo; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -12,7 +12,7 @@ import java.util.List; public class ShotgunAmmoBox extends AmmoSupplierItem { public ShotgunAmmoBox() { - super(AmmoType.SHOTGUN, 12, new Properties()); + super(Ammo.SHOTGUN, 12, new Properties()); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/SniperAmmoBox.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/SniperAmmoBox.java index 2aa7b2cd8..c745655d7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/SniperAmmoBox.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/SniperAmmoBox.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.item.common.ammo; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -12,7 +12,7 @@ import java.util.List; public class SniperAmmoBox extends AmmoSupplierItem { public SniperAmmoBox() { - super(AmmoType.SNIPER, 12, new Properties()); + super(Ammo.SNIPER, 12, new Properties()); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/box/AmmoBox.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/box/AmmoBox.java index 5b2d35cf4..806664aec 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/box/AmmoBox.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/box/AmmoBox.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.item.common.ammo.box; import com.atsuishio.superbwarfare.component.ModDataComponents; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.FormatTool; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -43,7 +43,7 @@ public class AmmoBox extends Item { var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch(); if (!level.isClientSide()) { - var types = selectedType.equals("All") ? AmmoType.values() : new AmmoType[]{AmmoType.getType(selectedType)}; + var types = selectedType.equals("All") ? Ammo.values() : new Ammo[]{Ammo.getType(selectedType)}; for (var type : types) { if (type == null) continue; @@ -76,7 +76,7 @@ public class AmmoBox extends Item { var list = new ArrayList(); list.add("All"); - for (var ammoType : AmmoType.values()) { + for (var ammoType : Ammo.values()) { list.add(ammoType.name); } @@ -96,7 +96,7 @@ public class AmmoBox extends Item { stack.set(ModDataComponents.AMMO_BOX_INFO, new AmmoBoxInfo(typeString, info.isDrop())); entity.playSound(ModSounds.FIRE_RATE.get(), 1f, 1f); - var type = AmmoType.getType(typeString); + var type = Ammo.getType(typeString); if (type == null) { player.displayClientMessage(Component.translatable("des.superbwarfare.ammo_box.type.all").withStyle(ChatFormatting.WHITE), true); return true; @@ -123,28 +123,28 @@ public class AmmoBox extends Item { public void appendHoverText(ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltipComponents, @NotNull TooltipFlag tooltipFlag) { var info = stack.get(ModDataComponents.AMMO_BOX_INFO); if (info == null) info = new AmmoBoxInfo("All", false); - var type = AmmoType.getType(info.type()); + var type = Ammo.getType(info.type()); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box").withStyle(ChatFormatting.GRAY)); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box.handgun").withStyle(ChatFormatting.AQUA) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format0D(AmmoType.HANDGUN.get(stack)) + ((type != AmmoType.HANDGUN) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); + .append(Component.literal(FormatTool.format0D(Ammo.HANDGUN.get(stack)) + ((type != Ammo.HANDGUN) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box.rifle").withStyle(ChatFormatting.GREEN) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format0D(AmmoType.RIFLE.get(stack)) + ((type != AmmoType.RIFLE) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); + .append(Component.literal(FormatTool.format0D(Ammo.RIFLE.get(stack)) + ((type != Ammo.RIFLE) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box.shotgun").withStyle(ChatFormatting.RED) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format0D(AmmoType.SHOTGUN.get(stack)) + ((type != AmmoType.SHOTGUN) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); + .append(Component.literal(FormatTool.format0D(Ammo.SHOTGUN.get(stack)) + ((type != Ammo.SHOTGUN) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box.sniper").withStyle(ChatFormatting.GOLD) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format0D(AmmoType.SNIPER.get(stack)) + ((type != AmmoType.SNIPER) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); + .append(Component.literal(FormatTool.format0D(Ammo.SNIPER.get(stack)) + ((type != Ammo.SNIPER) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box.heavy").withStyle(ChatFormatting.LIGHT_PURPLE) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(FormatTool.format0D(AmmoType.HEAVY.get(stack)) + ((type != AmmoType.HEAVY) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); + .append(Component.literal(FormatTool.format0D(Ammo.HEAVY.get(stack)) + ((type != Ammo.HEAVY) ? " " : " ←-")).withStyle(ChatFormatting.BOLD))); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java index 3bd3236bf..31826ee21 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java @@ -10,7 +10,7 @@ import com.atsuishio.superbwarfare.item.CustomRendererItem; import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.core.BlockPos; @@ -81,7 +81,7 @@ public abstract class GunItem extends Item implements CustomRendererItem { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var type = AmmoType.getType(ammoTypeInfo.value()); + var type = Ammo.getType(ammoTypeInfo.value()); assert type != null; type.add(capability, count); @@ -461,7 +461,7 @@ public abstract class GunItem extends Item implements CustomRendererItem { public String getAmmoDisplayName(GunData data) { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var type = AmmoType.getType(ammoTypeInfo.value()); + var type = Ammo.getType(ammoTypeInfo.value()); assert type != null; return switch (type) { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java index 3e45412e8..896a2c444 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java @@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.item.gun.data.subdata.*; import com.atsuishio.superbwarfare.item.gun.data.value.*; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.InventoryTool; import net.minecraft.core.component.DataComponents; @@ -279,7 +279,7 @@ public class GunData { // 玩家弹药 if (ammoType.startsWith("@")) { - if (AmmoType.getType(ammoType.substring(1)) == null) { + if (Ammo.getType(ammoType.substring(1)) == null) { return new AmmoTypeInfo(AmmoConsumeType.INVALID, ammoType.substring(1)); } return new AmmoTypeInfo(AmmoConsumeType.PLAYER_AMMO, ammoType.substring(1)); @@ -310,7 +310,7 @@ public class GunData { var info = ammoTypeInfo(); return switch (info.type()) { case PLAYER_AMMO -> { - var type = AmmoType.getType(info.value()); + var type = Ammo.getType(info.value()); assert type != null; yield type.get(player); @@ -335,7 +335,7 @@ public class GunData { var info = ammoTypeInfo(); switch (info.type()) { case PLAYER_AMMO -> { - var type = AmmoType.getType(info.value()); + var type = Ammo.getType(info.value()); assert type != null; type.set(player, type.get(player) - count); diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java index c82427cde..ff2a41539 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.data.GunData; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import io.netty.buffer.ByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; @@ -57,7 +57,7 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { var ammoTypeInfo = data.ammoTypeInfo(); if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) { - var ammoType = AmmoType.getType(ammoTypeInfo.value()); + var ammoType = Ammo.getType(ammoTypeInfo.value()); assert ammoType != null; if (ammoType.get(cap) == 0) return; diff --git a/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxAddAmmoRecipe.java b/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxAddAmmoRecipe.java index f9613ea48..05eaca0b5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxAddAmmoRecipe.java +++ b/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxAddAmmoRecipe.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.recipe; import com.atsuishio.superbwarfare.init.ModRecipes; import com.atsuishio.superbwarfare.item.common.ammo.AmmoSupplierItem; import com.atsuishio.superbwarfare.item.common.ammo.box.AmmoBox; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.core.HolderLookup; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingBookCategory; @@ -42,14 +42,14 @@ public class AmmoBoxAddAmmoRecipe extends CustomRecipe { } - private void addAmmo(HashMap map, AmmoType type, int count) { + private void addAmmo(HashMap map, Ammo type, int count) { map.put(type, map.getOrDefault(type, 0) + count); } @Override @ParametersAreNonnullByDefault public @NotNull ItemStack assemble(CraftingInput input, HolderLookup.Provider registries) { - var map = new HashMap(); + var map = new HashMap(); var ammoBox = ItemStack.EMPTY; for (var item : input.items()) { @@ -57,13 +57,13 @@ public class AmmoBoxAddAmmoRecipe extends CustomRecipe { addAmmo(map, ammoSupplier.type, ammoSupplier.ammoToAdd); } else if (item.getItem() instanceof AmmoBox) { ammoBox = item.copy(); - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { addAmmo(map, type, type.get(item)); } } } - for (var type : AmmoType.values()) { + for (var type : Ammo.values()) { type.set(ammoBox, map.getOrDefault(type, 0)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxExtractAmmoRecipe.java b/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxExtractAmmoRecipe.java index f110259ba..eacecf4c1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxExtractAmmoRecipe.java +++ b/src/main/java/com/atsuishio/superbwarfare/recipe/AmmoBoxExtractAmmoRecipe.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.component.ModDataComponents; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModRecipes; import com.atsuishio.superbwarfare.item.common.ammo.box.AmmoBox; -import com.atsuishio.superbwarfare.tools.AmmoType; +import com.atsuishio.superbwarfare.tools.Ammo; import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.world.item.ItemStack; @@ -43,7 +43,7 @@ public class AmmoBoxExtractAmmoRecipe extends CustomRecipe { if (data == null) return false; var typeString = data.type(); - var type = AmmoType.getType(typeString); + var type = Ammo.getType(typeString); if (type == null) return false; return type.get(ammoBoxItem) > 0; @@ -52,13 +52,13 @@ public class AmmoBoxExtractAmmoRecipe extends CustomRecipe { @Override @ParametersAreNonnullByDefault public @NotNull ItemStack assemble(CraftingInput input, HolderLookup.Provider registries) { - AmmoType type = null; + Ammo type = null; for (var item : input.items()) { if (item.getItem() instanceof AmmoBox) { var data = item.get(ModDataComponents.AMMO_BOX_INFO); assert data != null; - type = AmmoType.getType(data.type()); + type = Ammo.getType(data.type()); break; } } @@ -72,7 +72,6 @@ public class AmmoBoxExtractAmmoRecipe extends CustomRecipe { case SHOTGUN -> new ItemStack(ModItems.SHOTGUN_AMMO.get()); case SNIPER -> new ItemStack(ModItems.SNIPER_AMMO.get()); case HEAVY -> new ItemStack(ModItems.HEAVY_AMMO.get()); - default -> throw new IllegalStateException("Unexpected value: " + type); }; } @@ -87,7 +86,7 @@ public class AmmoBoxExtractAmmoRecipe extends CustomRecipe { var data = ammoBox.get(ModDataComponents.AMMO_BOX_INFO); assert data != null; - AmmoType type = AmmoType.getType(data.type()); + Ammo type = Ammo.getType(data.type()); assert type != null; type.add(ammoBox, -1); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/AmmoType.java b/src/main/java/com/atsuishio/superbwarfare/tools/Ammo.java similarity index 94% rename from src/main/java/com/atsuishio/superbwarfare/tools/AmmoType.java rename to src/main/java/com/atsuishio/superbwarfare/tools/Ammo.java index a73b2f271..1fa45a9d6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/AmmoType.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/Ammo.java @@ -8,7 +8,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.registries.DeferredHolder; -public enum AmmoType { +public enum Ammo { HANDGUN("item.superbwarfare.ammo.handgun", "HandgunAmmo"), RIFLE("item.superbwarfare.ammo.rifle", "RifleAmmo"), SHOTGUN("item.superbwarfare.ammo.shotgun", "ShotgunAmmo"), @@ -18,13 +18,13 @@ public enum AmmoType { public final String name; public DeferredHolder, DataComponentType> dataComponent; - AmmoType(String translatableKey, String name) { + Ammo(String translatableKey, String name) { this.translatableKey = translatableKey; this.name = name; } - public static AmmoType getType(String name) { - for (AmmoType type : values()) { + public static Ammo getType(String name) { + for (Ammo type : values()) { if (type.name.equals(name)) { return type; }