修复一个可能导致崩溃的问题

This commit is contained in:
17146 2025-05-04 18:40:47 +08:00 committed by Light_Quanta
parent a66d34468c
commit 03a94a0917
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
6 changed files with 15 additions and 4 deletions

View file

@ -3,7 +3,8 @@ package com.atsuishio.superbwarfare.entity.projectile;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
public interface DecoyEntity { public interface DecoyEntity {
String getStringUUID();
String getDecoyUUID();
Vec3 getPosition(); Vec3 getPosition();
} }

View file

@ -62,6 +62,11 @@ public class FlareDecoyEntity extends Entity implements DecoyEntity {
this.xRotO = this.getXRot(); this.xRotO = this.getXRot();
} }
@Override
public String getDecoyUUID() {
return this.getStringUUID();
}
@Override @Override
public Vec3 getPosition() { public Vec3 getPosition() {
return position(); return position();

View file

@ -219,7 +219,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity && !distracted) { if (e instanceof DecoyEntity decoyEntity && !distracted) {
this.entityData.set(TARGET_UUID, decoyEntity.getStringUUID()); this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID());
distracted = true; distracted = true;
} }
} }

View file

@ -69,4 +69,9 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity {
public Vec3 getPosition() { public Vec3 getPosition() {
return position(); return position();
} }
@Override
public String getDecoyUUID() {
return this.getStringUUID();
}
} }

View file

@ -197,7 +197,7 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity && !distracted) { if (e instanceof DecoyEntity decoyEntity && !distracted) {
this.entityData.set(TARGET_UUID, decoyEntity.getStringUUID()); this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID());
distracted = true; distracted = true;
} }
} }

View file

@ -122,7 +122,7 @@ public class JavelinItem extends GunItem implements GeoItem {
List<Entity> decoy = SeekTool.seekLivingEntities(player, player.level(), 512, 8); List<Entity> decoy = SeekTool.seekLivingEntities(player, player.level(), 512, 8);
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity) { if (e instanceof DecoyEntity decoyEntity) {
tag.putString("TargetEntity", decoyEntity.getStringUUID()); tag.putString("TargetEntity", decoyEntity.getDecoyUUID());
tag.putDouble("TargetPosX", decoyEntity.getPosition().x); tag.putDouble("TargetPosX", decoyEntity.getPosition().x);
tag.putDouble("TargetPosY", decoyEntity.getPosition().y); tag.putDouble("TargetPosY", decoyEntity.getPosition().y);
tag.putDouble("TargetPosZ", decoyEntity.getPosition().z); tag.putDouble("TargetPosZ", decoyEntity.getPosition().z);