优化投弹实体数据读取

This commit is contained in:
Light_Quanta 2025-07-04 00:42:43 +08:00
parent f510ca7d5d
commit 7b1a78560d
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 21 additions and 7 deletions

View file

@ -38,18 +38,34 @@ public class DroneAttachmentData implements IDBasedData {
return (this.dropPosition != null && this.dropPosition.length < 3) ? new float[]{0, -0.09f, 0} : this.dropPosition; return (this.dropPosition != null && this.dropPosition.length < 3) ? new float[]{0, -0.09f, 0} : this.dropPosition;
} }
@SerializedName("Data")
public JsonObject data;
/** /**
* 无人机显示的挂载实体的实体数据 * 无人机显示的挂载实体的实体数据
*/ */
@SerializedName("DisplayData") @SerializedName("DisplayData")
public JsonObject displayData; private JsonObject displayData;
/** /**
* 无人机投弹实体的实体数据 * 无人机投弹实体的实体数据
*/ */
@SerializedName("DropData") @SerializedName("DropData")
public JsonObject dropData; private JsonObject dropData;
public JsonObject displayData() {
if (this.data != null) {
return this.data;
}
return this.displayData != null ? this.displayData : this.dropData;
}
public JsonObject dropData() {
if (this.data != null) {
return this.data;
}
return this.dropData != null ? this.dropData : this.displayData;
}
@Override @Override
public String getId() { public String getId() {
@ -75,8 +91,6 @@ public class DroneAttachmentData implements IDBasedData {
@SerializedName("ExplosionRadius") @SerializedName("ExplosionRadius")
public float explosionRadius = 0; public float explosionRadius = 0;
// TODO 其他挂载设置
// display settings // display settings
@SerializedName("Scale") @SerializedName("Scale")

View file

@ -267,7 +267,7 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
projectile.setOwner(player); projectile.setOwner(player);
} }
var tag = TagDataParser.parse(data.dropData, name -> { var tag = TagDataParser.parse(data.dropData(), name -> {
if (player == null) return StringTag.valueOf(name); if (player == null) return StringTag.valueOf(name);
var uuid = player.getUUID(); var uuid = player.getUUID();
@ -412,8 +412,8 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
var offset = attachmentData.offset(); var offset = attachmentData.offset();
var rotation = attachmentData.rotation(); var rotation = attachmentData.rotation();
if (attachmentData.displayData != null) { if (attachmentData.displayData() != null) {
this.entityData.set(DISPLAY_ENTITY_TAG, TagDataParser.parse(attachmentData.displayData)); this.entityData.set(DISPLAY_ENTITY_TAG, TagDataParser.parse(attachmentData.displayData()));
} }
this.entityData.set(DISPLAY_DATA, List.of( this.entityData.set(DISPLAY_DATA, List.of(