From 80a53089a4685191b87effe67990032930a0ad4f Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Mon, 10 Mar 2025 02:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BAgetAllWeapons=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/vehicle/base/VehicleEntity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 295a85de2..5f694b55e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -234,7 +234,7 @@ public abstract class VehicleEntity extends Entity { this.entityData.define(LAST_ATTACKER_UUID, "undefined"); this.entityData.define(LAST_DRIVER_UUID, "undefined"); - if (this instanceof WeaponVehicleEntity weaponVehicle) { + if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { this.availableWeapons = new VehicleWeapon[this.getMaxPassengers()][]; var weapons = weaponVehicle.getAllWeapons(); @@ -256,7 +256,7 @@ public abstract class VehicleEntity extends Entity { this.entityData.set(LAST_DRIVER_UUID, compound.getString("LastDriver")); this.entityData.set(HEALTH, compound.getFloat("Health")); - if (this instanceof WeaponVehicleEntity) { + if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { var selected = compound.getIntArray("SelectedWeapon"); this.entityData.set(SELECTED_WEAPON, IntList.of(selected)); } @@ -268,7 +268,7 @@ public abstract class VehicleEntity extends Entity { compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID)); compound.putString("LastDriver", this.entityData.get(LAST_DRIVER_UUID)); - if (this instanceof WeaponVehicleEntity) { + if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { compound.putIntArray("SelectedWeapon", this.entityData.get(SELECTED_WEAPON).toIntArray()); } }