From 6f9abc4b3541c146062ad4773872389c5c4477c6 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Wed, 7 May 2025 17:14:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=BA=BF=E7=A8=8B=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/item/gun/data/GunData.java | 8 ++++++-- .../item/gun/rifle/AK12Item.java | 7 ------- .../item/gun/rifle/AK47Item.java | 7 ------- .../item/gun/rifle/Hk416Item.java | 7 ------- .../data/superbwarfare/guns/ak_12.json | 19 ++++++++++++++++++- .../data/superbwarfare/guns/ak_47.json | 14 ++++++++++++-- .../data/superbwarfare/guns/hk_416.json | 19 ++++++++++++++++++- 7 files changed, 54 insertions(+), 27 deletions(-) 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 0cd7c772b..1a4d19839 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 @@ -442,7 +442,11 @@ public class GunData { public List availablePerks() { List availablePerks = new ArrayList<>(); var perkNames = defaultGunData().availablePerks; - perkNames.sort((s1, s2) -> { + if (perkNames == null || perkNames.isEmpty()) return availablePerks; + + List sortedNames = new ArrayList<>(perkNames); + + sortedNames.sort((s1, s2) -> { int p1 = getPriority(s1); int p2 = getPriority(s2); @@ -462,7 +466,7 @@ public class GunData { var perkValues = perks.stream().map(DeferredHolder::get).toList(); var perkKeys = perks.stream().map(perk -> perk.getKey().location().toString()).toList(); - for (String name : perkNames) { + for (String name : sortedNames) { if (name.startsWith("@")) { String type = name.substring(1); switch (type) { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java index e047a6e2b..8c79197a9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java @@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.item.gun.GunItem; 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.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; @@ -166,11 +164,6 @@ public class AK12Item extends GunItem implements GeoItem { return "AK-12"; } - @Override - public boolean canApplyPerk(Perk perk) { - return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk); - } - @Override public boolean isMagazineReload(ItemStack stack) { return true; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java index 89a899db6..604233121 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java @@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.item.gun.GunItem; 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.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; @@ -174,11 +172,6 @@ public class AK47Item extends GunItem implements GeoItem { return "AK-47"; } - @Override - public boolean canApplyPerk(Perk perk) { - return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk); - } - @Override public boolean isMagazineReload(ItemStack stack) { return true; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java index 5032ea858..5dbc7691b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java @@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.item.gun.GunItem; 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.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; @@ -174,11 +172,6 @@ public class Hk416Item extends GunItem implements GeoItem { return "HK-416"; } - @Override - public boolean canApplyPerk(Perk perk) { - return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk); - } - @Override public boolean isMagazineReload(ItemStack stack) { return true; diff --git a/src/main/resources/data/superbwarfare/guns/ak_12.json b/src/main/resources/data/superbwarfare/guns/ak_12.json index b9da83e1c..622ce8fb0 100644 --- a/src/main/resources/data/superbwarfare/guns/ak_12.json +++ b/src/main/resources/data/superbwarfare/guns/ak_12.json @@ -15,5 +15,22 @@ "BypassesArmor": 0.23, "SoundRadius": 12, "RPM": 700, - "AmmoType": "@RifleAmmo" + "AmmoType": "@RifleAmmo", + "AvailablePerks": [ + "@Ammo", + "superbwarfare:heal_clip", + "superbwarfare:field_doctor", + "superbwarfare:fourth_times_charm", + "superbwarfare:subsistence", + "superbwarfare:powerful_attraction", + "superbwarfare:intelligent_chip", + "superbwarfare:kill_clip", + "superbwarfare:gutshot_straight", + "superbwarfare:monster_hunter", + "superbwarfare:head_seeker", + "superbwarfare:desperado", + "superbwarfare:vorpal_weapon", + "!superbwarfare:micro_missile", + "!superbwarfare:longer_wire" + ] } \ No newline at end of file diff --git a/src/main/resources/data/superbwarfare/guns/ak_47.json b/src/main/resources/data/superbwarfare/guns/ak_47.json index d7d434e82..c3ec8b858 100644 --- a/src/main/resources/data/superbwarfare/guns/ak_47.json +++ b/src/main/resources/data/superbwarfare/guns/ak_47.json @@ -17,9 +17,19 @@ "RPM": 600, "AmmoType": "@RifleAmmo", "AvailablePerks": [ - "superbwarfare:heal_clip", - "superbwarfare:kill_clip", "@Ammo", + "superbwarfare:heal_clip", + "superbwarfare:field_doctor", + "superbwarfare:fourth_times_charm", + "superbwarfare:subsistence", + "superbwarfare:powerful_attraction", + "superbwarfare:intelligent_chip", + "superbwarfare:kill_clip", + "superbwarfare:gutshot_straight", + "superbwarfare:monster_hunter", + "superbwarfare:head_seeker", + "superbwarfare:desperado", + "superbwarfare:vorpal_weapon", "!superbwarfare:micro_missile", "!superbwarfare:longer_wire" ] diff --git a/src/main/resources/data/superbwarfare/guns/hk_416.json b/src/main/resources/data/superbwarfare/guns/hk_416.json index 5f3b4d225..c60f47c2d 100644 --- a/src/main/resources/data/superbwarfare/guns/hk_416.json +++ b/src/main/resources/data/superbwarfare/guns/hk_416.json @@ -15,5 +15,22 @@ "BypassesArmor": 0.25, "SoundRadius": 14, "RPM": 900, - "AmmoType": "@RifleAmmo" + "AmmoType": "@RifleAmmo", + "AvailablePerks": [ + "@Ammo", + "superbwarfare:heal_clip", + "superbwarfare:field_doctor", + "superbwarfare:fourth_times_charm", + "superbwarfare:subsistence", + "superbwarfare:powerful_attraction", + "superbwarfare:intelligent_chip", + "superbwarfare:kill_clip", + "superbwarfare:gutshot_straight", + "superbwarfare:monster_hunter", + "superbwarfare:head_seeker", + "superbwarfare:desperado", + "superbwarfare:vorpal_weapon", + "!superbwarfare:micro_missile", + "!superbwarfare:longer_wire" + ] } \ No newline at end of file