修复可能导致线程错误的问题

This commit is contained in:
17146 2025-05-07 17:14:07 +08:00 committed by Light_Quanta
parent 25e2a82e53
commit 6f9abc4b35
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
7 changed files with 54 additions and 27 deletions

View file

@ -442,7 +442,11 @@ public class GunData {
public List<Perk> availablePerks() { public List<Perk> availablePerks() {
List<Perk> availablePerks = new ArrayList<>(); List<Perk> availablePerks = new ArrayList<>();
var perkNames = defaultGunData().availablePerks; var perkNames = defaultGunData().availablePerks;
perkNames.sort((s1, s2) -> { if (perkNames == null || perkNames.isEmpty()) return availablePerks;
List<String> sortedNames = new ArrayList<>(perkNames);
sortedNames.sort((s1, s2) -> {
int p1 = getPriority(s1); int p1 = getPriority(s1);
int p2 = getPriority(s2); int p2 = getPriority(s2);
@ -462,7 +466,7 @@ public class GunData {
var perkValues = perks.stream().map(DeferredHolder::get).toList(); var perkValues = perks.stream().map(DeferredHolder::get).toList();
var perkKeys = perks.stream().map(perk -> perk.getKey().location().toString()).toList(); var perkKeys = perks.stream().map(perk -> perk.getKey().location().toString()).toList();
for (String name : perkNames) { for (String name : sortedNames) {
if (name.startsWith("@")) { if (name.startsWith("@")) {
String type = name.substring(1); String type = name.substring(1);
switch (type) { switch (type) {

View file

@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -166,11 +164,6 @@ public class AK12Item extends GunItem implements GeoItem {
return "AK-12"; return "AK-12";
} }
@Override
public boolean canApplyPerk(Perk perk) {
return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk);
}
@Override @Override
public boolean isMagazineReload(ItemStack stack) { public boolean isMagazineReload(ItemStack stack) {
return true; return true;

View file

@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -174,11 +172,6 @@ public class AK47Item extends GunItem implements GeoItem {
return "AK-47"; return "AK-47";
} }
@Override
public boolean canApplyPerk(Perk perk) {
return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk);
}
@Override @Override
public boolean isMagazineReload(ItemStack stack) { public boolean isMagazineReload(ItemStack stack) {
return true; return true;

View file

@ -8,8 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -174,11 +172,6 @@ public class Hk416Item extends GunItem implements GeoItem {
return "HK-416"; return "HK-416";
} }
@Override
public boolean canApplyPerk(Perk perk) {
return PerkHelper.RIFLE_PERKS.test(perk) || PerkHelper.MAGAZINE_PERKS.test(perk);
}
@Override @Override
public boolean isMagazineReload(ItemStack stack) { public boolean isMagazineReload(ItemStack stack) {
return true; return true;

View file

@ -15,5 +15,22 @@
"BypassesArmor": 0.23, "BypassesArmor": 0.23,
"SoundRadius": 12, "SoundRadius": 12,
"RPM": 700, "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"
]
} }

View file

@ -17,9 +17,19 @@
"RPM": 600, "RPM": 600,
"AmmoType": "@RifleAmmo", "AmmoType": "@RifleAmmo",
"AvailablePerks": [ "AvailablePerks": [
"superbwarfare:heal_clip",
"superbwarfare:kill_clip",
"@Ammo", "@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:micro_missile",
"!superbwarfare:longer_wire" "!superbwarfare:longer_wire"
] ]

View file

@ -15,5 +15,22 @@
"BypassesArmor": 0.25, "BypassesArmor": 0.25,
"SoundRadius": 14, "SoundRadius": 14,
"RPM": 900, "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"
]
} }