雷达制导模式会引导1130射击

This commit is contained in:
Atsuishio 2025-04-29 01:37:12 +08:00 committed by Light_Quanta
parent 2d6dd4cf35
commit 585b97247d
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 15 additions and 6 deletions

View file

@ -166,6 +166,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
entityData.set(TARGET_UUID, "none");
return super.interact(player, hand);
}

View file

@ -1,6 +1,7 @@
package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity;
import com.atsuishio.superbwarfare.entity.vehicle.LaserTowerEntity;
import com.atsuishio.superbwarfare.menu.FuMO25Menu;
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
@ -9,6 +10,7 @@ import net.minecraft.core.UUIDUtil;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.neoforged.neoforge.network.handling.IPayloadContext;
import org.jetbrains.annotations.NotNull;
@ -33,12 +35,18 @@ public record RadarSetTargetMessage(UUID target) implements CustomPacketPayload
if (!player.containerMenu.stillValid(player)) {
return;
}
fuMO25Menu.getSelfPos().ifPresent(pos -> {
var entities = StreamSupport.stream(EntityFindUtil.getEntities(player.level()).getAll().spliterator(), false)
.filter(e -> e instanceof LaserTowerEntity towerEntity && towerEntity.getOwner() == player && towerEntity.distanceTo(player) <= 16)
.toList();
entities.forEach(e -> e.getEntityData().set(LaserTowerEntity.TARGET_UUID, message.target.toString()));
});
fuMO25Menu.getSelfPos().ifPresent(pos -> StreamSupport.stream(EntityFindUtil.getEntities(player.level()).getAll().spliterator(), false)
.filter(e -> (e instanceof LaserTowerEntity towerEntity && towerEntity.getOwner() == player && towerEntity.distanceTo(player) <= 16)
|| (e instanceof Hpj11Entity hpj11Entity && hpj11Entity.getOwner() == player && hpj11Entity.distanceTo(player) <= 16))
.forEach(e -> setTarget(e, message.target.toString())));
}
}
public static void setTarget(Entity e, String uuid) {
if (e instanceof LaserTowerEntity laserTower) {
laserTower.getEntityData().set(LaserTowerEntity.TARGET_UUID, uuid);
} else if (e instanceof Hpj11Entity hpj11Entity) {
hpj11Entity.getEntityData().set(Hpj11Entity.TARGET_UUID, uuid);
}
}