将枪械ID挪至JSON数据内

This commit is contained in:
Light_Quanta 2025-05-22 13:41:25 +08:00
parent 6f30687b77
commit 9f4ad5435a
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
39 changed files with 43 additions and 5 deletions

View file

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class DefaultGunData { public class DefaultGunData {
@SerializedName("ID")
public String id = "";
@SerializedName("RecoilX") @SerializedName("RecoilX")
public double recoilX; public double recoilX;

View file

@ -55,7 +55,7 @@ public class GunData {
this.item = gunItem; this.item = gunItem;
this.stack = stack; this.stack = stack;
var id = stack.getDescriptionId(); var id = stack.getDescriptionId();
this.id = id.substring(id.lastIndexOf(".") + 1); this.id = id.substring(id.indexOf(".") + 1).replace('.', ':');
var customData = stack.get(DataComponents.CUSTOM_DATA); var customData = stack.get(DataComponents.CUSTOM_DATA);
this.tag = customData != null ? customData.copyTag() : new CompoundTag(); this.tag = customData != null ? customData.copyTag() : new CompoundTag();

View file

@ -32,16 +32,16 @@ public class GunsTool {
gunsData.clear(); gunsData.clear();
GunData.dataCache.invalidateAll(); GunData.dataCache.invalidateAll();
// TODO 将枪械ID挪至JSON数据内
for (var entry : manager.listResources("guns", file -> file.getPath().endsWith(".json")).entrySet()) { for (var entry : manager.listResources("guns", file -> file.getPath().endsWith(".json")).entrySet()) {
var id = entry.getKey();
var attribute = entry.getValue(); var attribute = entry.getValue();
try { try {
Gson gson = new Gson(); Gson gson = new Gson();
var data = gson.fromJson(new InputStreamReader(attribute.open()), DefaultGunData.class); var data = gson.fromJson(new InputStreamReader(attribute.open()), DefaultGunData.class);
var path = id.getPath();
gunsData.put(path.substring(5, path.length() - 5), data); if (!gunsData.containsKey(data.id)) {
gunsData.put(data.id, data);
}
} catch (Exception e) { } catch (Exception e) {
Mod.LOGGER.error(e.getMessage()); Mod.LOGGER.error(e.getMessage());
} }

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:aa_12",
"Spread": 3.5, "Spread": 3.5,
"RecoilX": 0.006, "RecoilX": 0.006,
"RecoilY": 0.018, "RecoilY": 0.018,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:ak_12",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 3.5, "Spread": 3.5,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:ak_47",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 4, "Spread": 4,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:aurelia_sceptre",
"Spread": 0.5, "Spread": 0.5,
"RecoilX": 0, "RecoilX": 0,
"RecoilY": 0, "RecoilY": 0,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:bocek",
"Spread": 4, "Spread": 4,
"Headshot": 2.5, "Headshot": 2.5,
"Damage": 48, "Damage": 48,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:devotion",
"DefaultZoom": 2, "DefaultZoom": 2,
"Spread": 5, "Spread": 5,
"RecoilX": 0.0018, "RecoilX": 0.0018,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:glock_17",
"Spread": 2.5, "Spread": 2.5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.013, "RecoilY": 0.013,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:glock_18",
"Spread": 2.5, "Spread": 2.5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.013, "RecoilY": 0.013,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:hk_416",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 3.5, "Spread": 3.5,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:homemade_shotgun",
"Spread": 4, "Spread": 4,
"RecoilX": 0.005, "RecoilX": 0.005,
"RecoilY": 0.026, "RecoilY": 0.026,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:hunting_rifle",
"Spread": 7, "Spread": 7,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.04, "RecoilY": 0.04,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:insidious",
"Spread": 4, "Spread": 4,
"RecoilX": 0.006, "RecoilX": 0.006,
"RecoilY": 0.011, "RecoilY": 0.011,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:javelin",
"DefaultZoom": 3, "DefaultZoom": 3,
"Spread": 5, "Spread": 5,
"Magazine": 1, "Magazine": 1,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:k_98",
"Spread": 5, "Spread": 5,
"RecoilX": 0.002, "RecoilX": 0.002,
"RecoilY": 0.063, "RecoilY": 0.063,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_1911",
"Spread": 2.5, "Spread": 2.5,
"RecoilX": 0.006, "RecoilX": 0.006,
"RecoilY": 0.018, "RecoilY": 0.018,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_4",
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,
"Spread": 4, "Spread": 4,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_60",
"Spread": 5, "Spread": 5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.014, "RecoilY": 0.014,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_79",
"Spread": 3.5, "Spread": 3.5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.023, "RecoilY": 0.023,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_870",
"Spread": 3, "Spread": 3,
"RecoilX": 0.009, "RecoilX": 0.009,
"RecoilY": 0.04, "RecoilY": 0.04,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:m_98b",
"DefaultZoom": 6, "DefaultZoom": 6,
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:marlin",
"Spread": 2, "Spread": 2,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.031, "RecoilY": 0.031,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:minigun",
"Spread": 1.5, "Spread": 1.5,
"RecoilX": 0.003, "RecoilX": 0.003,
"RecoilY": 0.02, "RecoilY": 0.02,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:mk_14",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 5, "Spread": 5,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:mosin_nagant",
"DefaultZoom": 3.5, "DefaultZoom": 3.5,
"Spread": 4.8, "Spread": 4.8,
"RecoilX": 0.002, "RecoilX": 0.002,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:mp_443",
"Spread": 2.5, "Spread": 2.5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.013, "RecoilY": 0.013,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:ntw_20",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 8, "Spread": 8,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:qbz_95",
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,
"Spread": 3.7, "Spread": 3.7,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:rpg",
"Spread": 5, "Spread": 5,
"RecoilX": 0.008, "RecoilX": 0.008,
"RecoilY": 0.018, "RecoilY": 0.018,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:rpk",
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"Spread": 5.5, "Spread": 5.5,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:secondary_cataclysm",
"Spread": 5, "Spread": 5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.023, "RecoilY": 0.023,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:sentinel",
"DefaultZoom": 3, "DefaultZoom": 3,
"Spread": 6, "Spread": 6,
"RecoilX": 0.007, "RecoilX": 0.007,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:sks",
"Spread": 4.5, "Spread": 4.5,
"RecoilX": 0.004, "RecoilX": 0.004,
"RecoilY": 0.015, "RecoilY": 0.015,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:svd",
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,
"Spread": 5.5, "Spread": 5.5,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:taser",
"Spread": 2, "Spread": 2,
"RecoilX": 0.0001, "RecoilX": 0.0001,
"RecoilY": 0.002, "RecoilY": 0.002,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:trachelium",
"Spread": 3, "Spread": 3,
"RecoilX": 0.005, "RecoilX": 0.005,
"RecoilY": 0.032, "RecoilY": 0.032,

View file

@ -1,4 +1,5 @@
{ {
"ID": "superbwarfare:vector",
"Spread": 2.3, "Spread": 2.3,
"RecoilX": 0, "RecoilX": 0,
"RecoilY": 0.007, "RecoilY": 0.007,