雷达制导模式会引导1130射击
This commit is contained in:
parent
2d6dd4cf35
commit
585b97247d
2 changed files with 15 additions and 6 deletions
|
@ -166,6 +166,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
entityData.set(TARGET_UUID, "none");
|
||||||
return super.interact(player, hand);
|
return super.interact(player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.network.message.send;
|
package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.LaserTowerEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.LaserTowerEntity;
|
||||||
import com.atsuishio.superbwarfare.menu.FuMO25Menu;
|
import com.atsuishio.superbwarfare.menu.FuMO25Menu;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
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.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -33,12 +35,18 @@ public record RadarSetTargetMessage(UUID target) implements CustomPacketPayload
|
||||||
if (!player.containerMenu.stillValid(player)) {
|
if (!player.containerMenu.stillValid(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fuMO25Menu.getSelfPos().ifPresent(pos -> {
|
fuMO25Menu.getSelfPos().ifPresent(pos -> StreamSupport.stream(EntityFindUtil.getEntities(player.level()).getAll().spliterator(), false)
|
||||||
var entities = StreamSupport.stream(EntityFindUtil.getEntities(player.level()).getAll().spliterator(), false)
|
.filter(e -> (e instanceof LaserTowerEntity towerEntity && towerEntity.getOwner() == player && towerEntity.distanceTo(player) <= 16)
|
||||||
.filter(e -> e instanceof LaserTowerEntity towerEntity && towerEntity.getOwner() == player && towerEntity.distanceTo(player) <= 16)
|
|| (e instanceof Hpj11Entity hpj11Entity && hpj11Entity.getOwner() == player && hpj11Entity.distanceTo(player) <= 16))
|
||||||
.toList();
|
.forEach(e -> setTarget(e, message.target.toString())));
|
||||||
entities.forEach(e -> e.getEntityData().set(LaserTowerEntity.TARGET_UUID, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue