添加简易队友标识
This commit is contained in:
parent
733d540645
commit
8efe96de2c
2 changed files with 31 additions and 4 deletions
|
@ -5,10 +5,7 @@ import com.atsuishio.superbwarfare.client.RenderHelper;
|
|||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
|
@ -27,6 +24,10 @@ import net.neoforged.api.distmarker.Dist;
|
|||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.SpyglassRangeOverlay.FRIENDLY_INDICATOR;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class VehicleTeamOverlay implements LayeredDraw.Layer {
|
||||
|
@ -100,5 +101,25 @@ public class VehicleTeamOverlay implements LayeredDraw.Layer {
|
|||
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
if (player.getVehicle() instanceof VehicleEntity) {
|
||||
List<Entity> entities = SeekTool.getPlayer(player, player.level());
|
||||
for (var e : entities) {
|
||||
if (e != null) {
|
||||
Vec3 pos = new Vec3(Mth.lerp(partialTick, e.xo, e.getX()), Mth.lerp(partialTick, e.yo + e.getBbHeight() / 2, e.getY() + e.getBbHeight() / 2), Mth.lerp(partialTick, e.zo, e.getZ()));
|
||||
Vec3 point = VectorUtil.worldToScreen(pos, cameraPos);
|
||||
if (point != null) {
|
||||
float xf = (float) point.x;
|
||||
float yf = (float) point.y;
|
||||
|
||||
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, screenWidth - 12), Mth.clamp(yf - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,12 @@ public class SeekTool {
|
|||
.toList();
|
||||
}
|
||||
|
||||
public static List<Entity> getPlayer(Player player, Level level) {
|
||||
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
|
||||
.filter(e -> e instanceof Player && e.getTeam() != null && !e.getTeam().getName().equals("TDM") && e.getTeam() == player.getTeam())
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static Entity seekEntity(Entity entity, Level level, double seekRange, double seekAngle) {
|
||||
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
|
||||
.filter(e -> {
|
||||
|
|
Loading…
Add table
Reference in a new issue