重写无人机控制距离获取
This commit is contained in:
parent
ade2ce3628
commit
152e3777b1
6 changed files with 9 additions and 52 deletions
|
@ -38,7 +38,11 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
public static final ResourceLocation ID = Mod.loc("drone_hud");
|
||||
|
||||
public static int MAX_DISTANCE = 256;
|
||||
public static int getMaxDistance() {
|
||||
var connection = Minecraft.getInstance().getConnection();
|
||||
return (connection == null ? 16 : connection.serverSimulationDistance) * 16;
|
||||
}
|
||||
|
||||
private static final ResourceLocation FRAME = Mod.loc("textures/screens/frame/frame.png");
|
||||
private static final ResourceLocation TV_FRAME = Mod.loc("textures/screens/land/tv_frame.png");
|
||||
|
||||
|
@ -76,7 +80,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
int addH = (w / h) * 27;
|
||||
preciseBlit(guiGraphics, TV_FRAME, (float) -addW / 2, (float) -addH / 2, 10, 0, 0.0F, w + addW, h + addH, w + addW, h + addH);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2 - 64 - ((ClientEventHandler.droneFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2f - 64 - ((ClientEventHandler.droneFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129);
|
||||
guiGraphics.drawString(mc.font, Component.literal(FormatTool.format1D(ClientEventHandler.droneFovLerp, "x")),
|
||||
w / 2 + 144, h / 2 + 56 - (int) ((ClientEventHandler.droneFovLerp - 1) * 23.8), -1, false);
|
||||
|
||||
|
@ -103,7 +107,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
int color = -1;
|
||||
|
||||
// 超出距离警告
|
||||
if (distance > MAX_DISTANCE - 48) {
|
||||
if (distance > getMaxDistance() - 48) {
|
||||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.warning"),
|
||||
w / 2 - 18, h / 2 - 47, -65536, false);
|
||||
color = -65536;
|
||||
|
@ -132,7 +136,6 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
if (lookAtEntity) {
|
||||
// 实体距离
|
||||
var displayName = lookingEntity.getDisplayName();
|
||||
if (displayName == null) displayName = Component.empty();
|
||||
|
||||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.range")
|
||||
.append(Component.literal(FormatTool.format1D(entityRange, "m ") + displayName.getString())),
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.data.gun.GunData;
|
|||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.SimulationDistanceMessage;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
|
@ -29,7 +28,6 @@ import net.neoforged.neoforge.event.AnvilUpdateEvent;
|
|||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
||||
|
@ -54,8 +52,6 @@ public class PlayerEventHandler {
|
|||
data.save();
|
||||
}
|
||||
}
|
||||
|
||||
handleSimulationDistance(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -98,13 +94,6 @@ public class PlayerEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleSimulationDistance(Player player) {
|
||||
if (player.level() instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) {
|
||||
var distance = serverLevel.getChunkSource().chunkMap.serverViewDistance;
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new SimulationDistanceMessage(distance));
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleRespawnReload(Player player) {
|
||||
if (!GameplayConfig.RESPAWN_RELOAD.get()) return;
|
||||
|
||||
|
|
|
@ -12,12 +12,6 @@ import java.util.Objects;
|
|||
|
||||
public class ClientPacketHandler {
|
||||
|
||||
// public static void handleSimulationDistanceMessage(int distance, final IPayloadContext context) {
|
||||
// if (context.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
// DroneUIOverlay.MAX_DISTANCE = distance * 16;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
public static void handleResetCameraType() {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
Player player = minecraft.player;
|
||||
|
|
|
@ -21,7 +21,6 @@ public class NetworkRegistry {
|
|||
registrar.playToClient(ResetCameraTypeMessage.TYPE, ResetCameraTypeMessage.STREAM_CODEC, ResetCameraTypeMessage::handler);
|
||||
registrar.playToClient(RadarMenuOpenMessage.TYPE, RadarMenuOpenMessage.STREAM_CODEC, RadarMenuOpenMessage::handler);
|
||||
registrar.playToClient(RadarMenuCloseMessage.TYPE, RadarMenuCloseMessage.STREAM_CODEC, RadarMenuCloseMessage::handler);
|
||||
registrar.playToClient(SimulationDistanceMessage.TYPE, SimulationDistanceMessage.STREAM_CODEC, SimulationDistanceMessage::handler);
|
||||
registrar.playToClient(ClientTacticalSprintSyncMessage.TYPE, ClientTacticalSprintSyncMessage.STREAM_CODEC, (msg, ctx) -> ClientTacticalSprintSyncMessage.handler(msg));
|
||||
registrar.playToClient(DogTagEditorMessage.TYPE, DogTagEditorMessage.STREAM_CODEC, (msg, ctx) -> DogTagEditorMessage.handler(msg));
|
||||
registrar.playToClient(VehiclesDataMessage.TYPE, VehiclesDataMessage.STREAM_CODEC, (msg, ctx) -> VehiclesDataMessage.handler(msg));
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.network.message.receive;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.overlay.DroneHudOverlay;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record SimulationDistanceMessage(int distance) implements CustomPacketPayload {
|
||||
public static final Type<SimulationDistanceMessage> TYPE = new Type<>(Mod.loc("simulation_distance"));
|
||||
|
||||
public static final StreamCodec<ByteBuf, SimulationDistanceMessage> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT,
|
||||
SimulationDistanceMessage::distance,
|
||||
SimulationDistanceMessage::new
|
||||
);
|
||||
|
||||
public static void handler(SimulationDistanceMessage message, final IPayloadContext context) {
|
||||
DroneHudOverlay.MAX_DISTANCE = message.distance * 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
|
@ -7,4 +7,5 @@ public net.minecraft.client.player.LocalPlayer handsBusy # handsBusy
|
|||
public net.minecraft.client.renderer.culling.Frustum matrix # matrix
|
||||
public net.minecraft.client.renderer.LevelRenderer renderBuffers # renderBuffers
|
||||
public net.minecraft.server.level.ChunkMap serverViewDistance # serverViewDistance
|
||||
public net.minecraft.world.entity.LivingEntity jumping # jumping
|
||||
public net.minecraft.world.entity.LivingEntity jumping # jumping
|
||||
public net.minecraft.client.multiplayer.ClientPacketListener serverSimulationDistance # serverSimulationDistance
|
Loading…
Add table
Reference in a new issue