制作固定翼HUD
This commit is contained in:
parent
feafd5a54d
commit
e0a148a30e
8 changed files with 125 additions and 104 deletions
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.client.ClickHandler;
|
|||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.AircraftEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
|
@ -23,7 +22,6 @@ import net.minecraft.client.renderer.GameRenderer;
|
|||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -31,8 +29,6 @@ import net.neoforged.api.distmarker.Dist;
|
|||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
|
||||
|
@ -73,7 +69,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
scopeScale = Mth.lerp(partialTick, scopeScale, 1F);
|
||||
scopeScale = Mth.lerp(partialTick, scopeScale, 0.75F);
|
||||
float f = (float) Math.min(screenWidth, screenHeight);
|
||||
float f1 = Math.min((float) screenWidth / f, (float) screenHeight / f) * scopeScale;
|
||||
float i = Mth.floor(f * f1);
|
||||
|
@ -81,42 +77,55 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
float k = ((screenWidth - i) / 2);
|
||||
float l = ((screenHeight - j) / 2);
|
||||
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_base.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
renderDriverAngle(guiGraphics, player, mobileVehicle, k, l, i, j, partialTick);
|
||||
float diffY = Mth.wrapDegrees(Mth.lerp(partialTick, player.yHeadRotO, player.getYHeadRot()) - Mth.lerp(partialTick, mobileVehicle.yRotO, mobileVehicle.getYRot())) * 0.5f;
|
||||
float diffX = Mth.wrapDegrees(Mth.lerp(partialTick, player.xRotO, player.getXRot()) - Mth.lerp(partialTick, mobileVehicle.xRotO, mobileVehicle.getXRot())) * 0.5f;
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass.png"), (float) screenWidth / 2 - 128, (float) 6, 128 + ((float) 64 / 45 * mobileVehicle.getYRot()), 0, 256, 16, 512, 16);
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
double zoom = 0.96 * 3 + 0.06 * fovAdjust2;
|
||||
|
||||
Vec3 pos = aircraftEntity.shootPos(partialTick).add(mobileVehicle.getViewVector(partialTick).scale(192));
|
||||
Vec3 posCross = aircraftEntity.shootPos(partialTick).add(aircraftEntity.shootVec(partialTick).scale(192));
|
||||
Vec3 lookAngle = player.getViewVector(partialTick).normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
|
||||
var cPos = cameraPos.add(lookAngle);
|
||||
|
||||
Vec3 p = RenderHelper.worldToScreen(pos, ClientEventHandler.zoomVehicle ? cPos : cameraPos);
|
||||
Vec3 pCross = RenderHelper.worldToScreen(posCross, ClientEventHandler.zoomVehicle ? cPos : cameraPos);
|
||||
|
||||
if (p != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_base.png"), x - 128, y - 128, 0, 0, 256, 256, 256, 256);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass.png"), x - 128, (float) 6, 128 + ((float) 64 / 45 * mobileVehicle.getYRot()), 0, 256, 16, 512, 16);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(-aircraftEntity.getRotZ(partialTick)), screenWidth / 2f, screenHeight / 2f, 0);
|
||||
float pitch = aircraftEntity.getRotX(partialTick);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_line.png"), (float) screenWidth / 2 - 128, (float) screenHeight / 2 - 512 - 5.475f * pitch, 0, 0, 256, 1024, 256, 1024);
|
||||
poseStack.popPose();
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), screenWidth / 2f, screenHeight / 2f - 56, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/roll_ind.png"), (float) screenWidth / 2 - 8, (float) screenHeight / 2 - 88, 0, 0, 16, 16, 16, 16);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/roll_ind.png"), x - 8, y + 112, 0, 0, 16, 16, 16, 16);
|
||||
poseStack.popPose();
|
||||
|
||||
guiGraphics.blit(Mod.loc("textures/screens/helicopter/heli_power_ruler.png"), screenWidth / 2 + 100, screenHeight / 2 - 64, 0, 0, 64, 128, 64, 128);
|
||||
|
||||
double height = mobileVehicle.position().distanceTo((Vec3.atLowerCornerOf(mobileVehicle.level().clip(new ClipContext(mobileVehicle.position(), mobileVehicle.position().add(new Vec3(0, -1, 0).scale(100)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.ANY, mobileVehicle)).getBlockPos())));
|
||||
double blockInWay = mobileVehicle.position().distanceTo((Vec3.atLowerCornerOf(mobileVehicle.level().clip(new ClipContext(mobileVehicle.position(), mobileVehicle.position().add(new Vec3(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y + 0.06, mobileVehicle.getDeltaMovement().z).normalize().scale(100)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.ANY, mobileVehicle)).getBlockPos())));
|
||||
|
||||
float power = aircraftEntity.getPower();
|
||||
lerpPower = Mth.lerp(0.001f * partialTick, lerpPower, power);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_power.png"), (float) screenWidth / 2 + 130f, ((float) screenHeight / 2 - 64 + 124 - power * 980), 0, 0, 4, power * 980, 4, power * 980);
|
||||
lerpVy = (float) Mth.lerp(0.021f * partialTick, lerpVy, mobileVehicle.getDeltaMovement().y());
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_vy_move.png"), (float) screenWidth / 2 + 138, ((float) screenHeight / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5f), 0, 0, 8, 8, 8, 8);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(lerpVy * 20, "m/s")),
|
||||
screenWidth / 2 + 146, (int) (screenHeight / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5), (lerpVy * 20 < -24 || ((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36) || (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72) ? -65536 : 0x66FF00), false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getY())),
|
||||
screenWidth / 2 + 104, screenHeight / 2, 0x66FF00, false);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/speed_frame.png"), (float) screenWidth / 2 - 144, (float) screenHeight / 2 - 6, 0, 0, 50, 18, 50, 18);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72, "km/h")),
|
||||
screenWidth / 2 - 140, screenHeight / 2, 0x66FF00, false);
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(lerpVy * 20, "m/s")), (int) x + 146, (int) y, 0x66FF00, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getY())), (int) x + 104, (int) y, 0x66FF00, false);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/speed_frame.png"), x - 144, y, 0, 0, 50, 18, 50, 18);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getDeltaMovement().dot(mobileVehicle.getViewVector(1)) * 72, "km/h")), (int) x - 140, (int) y, 0x66FF00, false);
|
||||
|
||||
// if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||
// if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
|
@ -127,52 +136,63 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
// }
|
||||
// }
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + aircraftEntity.getDecoy()), screenWidth / 2 - 160, screenHeight / 2 - 50, 0x66FF00, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + aircraftEntity.getDecoy()), (int) x - 160, (int) y - 50, 0x66FF00, false);
|
||||
|
||||
if (lerpVy * 20 < -24) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SINK RATE,PULL UP!"),
|
||||
screenWidth / 2 - 53, screenHeight / 2 + 24, -65536, false);
|
||||
(int) x - 53, (int) y + 24, -65536, false);
|
||||
} else if (((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36)
|
||||
|| (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72)) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TERRAIN TERRAIN"),
|
||||
screenWidth / 2 - 42, screenHeight / 2 + 24, -65536, false);
|
||||
(int) x - 42, (int) y + 24, -65536, false);
|
||||
}
|
||||
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
screenWidth / 2 - 144, screenHeight / 2 + 14, -65536, false);
|
||||
(int) x - 144, (int) y + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
screenWidth / 2 - 144, screenHeight / 2 + 14, 0xFF6B00, false);
|
||||
(int) x - 144, (int) y + 14, 0xFF6B00, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Matrix4f transform = getVehicleTransform(mobileVehicle, partialTick);
|
||||
float x0 = 0f;
|
||||
float y0 = 0.65f;
|
||||
float z0 = 0.8f;
|
||||
|
||||
Vector4f worldPosition = transformPosition(transform, x0, y0, z0);
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
double zoom = 0.96 * 3 + 0.06 * fovAdjust2;
|
||||
|
||||
Vec3 pos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(partialTick).scale(192));
|
||||
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
|
||||
var cPos = cameraPos.add(lookAngle);
|
||||
|
||||
Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(partialTick).scale(192)), ClientEventHandler.zoomVehicle ? cPos : cameraPos);
|
||||
|
||||
if (p != null) {
|
||||
//角度
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(-aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||
float pitch = aircraftEntity.getRotX(partialTick);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_line.png"), x - 128 + diffY, y - 512 - 5.475f * pitch, 0, 0, 256, 1024, 256, 1024);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_line2.png"), x - 128 + diffY, y - 512 - 5.475f * pitch + diffX, 0, 0, 256, 1024, 256, 1024);
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
// 准星
|
||||
if (pCross != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) pCross.x;
|
||||
float y = (float) pCross.y;
|
||||
|
||||
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_base2.png"), x - 96 + diffX, y - 96 + diffY, 0, 0, 192, 192, 192, 192);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/crosshair_ind.png"), x - 16, y - 16, 0, 0, 32, 32, 32, 32);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
} else if (mc.options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||
|
@ -210,26 +230,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
VehicleHudOverlay.renderKillIndicator3P(guiGraphics, posX, posY);
|
||||
}
|
||||
|
||||
private static void renderDriverAngle(GuiGraphics guiGraphics, Player player, Entity heli, float k, float l, float i, float j, float ticks) {
|
||||
float diffY = Mth.wrapDegrees(Mth.lerp(ticks, player.yHeadRotO, player.getYHeadRot()) - Mth.lerp(ticks, heli.yRotO, heli.getYRot())) * 0.35f;
|
||||
float diffX = Mth.wrapDegrees(Mth.lerp(ticks, player.xRotO, player.getXRot()) - Mth.lerp(ticks, heli.xRotO, heli.getXRot())) * 0.072f;
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_driver_angle.png"), k + diffY, l + diffX, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
||||
public static Matrix4f getVehicleTransform(VehicleEntity vehicle, float partialTicks) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) Mth.lerp(partialTicks, vehicle.xo, vehicle.getX()), (float) Mth.lerp(partialTicks, vehicle.yo + 1.45, vehicle.getY() + 1.45), (float) Mth.lerp(partialTicks, vehicle.zo, vehicle.getZ()));
|
||||
transform.rotate(Axis.YP.rotationDegrees(-vehicle.getYRot()));
|
||||
transform.rotate(Axis.XP.rotationDegrees(vehicle.getXRot()));
|
||||
transform.rotate(Axis.ZP.rotationDegrees(vehicle.getRoll()));
|
||||
return transform;
|
||||
}
|
||||
|
||||
public static Vector4f transformPosition(Matrix4f transform, float x, float y, float z) {
|
||||
return transform.transform(new Vector4f(x, y, z, 1));
|
||||
}
|
||||
|
||||
public static double length(double x, double y, double z) {
|
||||
return Math.sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
|
@ -198,8 +197,11 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onGround()) {
|
||||
this.terrainCompact(4f, 4f);
|
||||
} else {
|
||||
this.setZRot(this.roll * 0.99f);
|
||||
}
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
@ -254,14 +256,14 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
}
|
||||
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.002f, onGround() ? -0.04f : 0.01f));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.002f, onGround() ? -0.005f : 0.01f));
|
||||
}
|
||||
|
||||
if (!onGround()) {
|
||||
if (rightInputDown) {
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 0.2f);
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 0.3f);
|
||||
} else if (this.leftInputDown) {
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.2f);
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.3f);
|
||||
}
|
||||
} else {
|
||||
// 刹车
|
||||
|
@ -277,7 +279,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
|
||||
|
||||
float addY = Mth.clamp(Math.max((this.onGround() ? 0.1f : 0.2f) * (float) Math.max(getDeltaMovement().dot(getViewVector(1)), 0.05), 0f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), -1.5f * (roll + 1), 1.5f * (roll + 1));
|
||||
float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.2, 0.02), 0.5f) * diffX, -1.3f, 1.3f);
|
||||
float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.17, 0.02), 0.5f) * diffX, -1.8f, 1.8f);
|
||||
float addZ = this.entityData.get(DELTA_ROT) - (this.onGround() ? 0 : 0.01f) * diffY * (float) getDeltaMovement().dot(getViewVector(1));
|
||||
|
||||
float i = getXRot() / 90;
|
||||
|
@ -318,8 +320,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
} else {
|
||||
entityData.set(GEAR_ROT, Math.max(entityData.get(GEAR_ROT) - 5, 0));
|
||||
}
|
||||
|
||||
player.displayClientMessage(Component.literal("speed: " + FormatTool.format2D(getDeltaMovement().dot(getViewVector(1)) * 72)), true);
|
||||
}
|
||||
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.99f);
|
||||
|
@ -515,6 +515,23 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 shootPos(float tickDelta) {
|
||||
Matrix4f transform = getVehicleTransform(tickDelta);
|
||||
Vector4f worldPosition;
|
||||
if (getWeaponIndex(0) == 0) {
|
||||
worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
||||
} else {
|
||||
worldPosition = transformPosition(transform, 0f, -1.76f, 1.87f);
|
||||
}
|
||||
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 shootVec(float tickDelta) {
|
||||
return new Vec3(getViewVector(tickDelta).x, getViewVector(tickDelta).y - 0.08, getViewVector(tickDelta).z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vehicleShoot(Player player, int type) {
|
||||
Matrix4f transform = getVehicleTransform(1);
|
||||
|
@ -530,7 +547,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
||||
|
||||
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y - 0.01, getLookAngle().z, 20, 0.5f);
|
||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y - 0.062, getLookAngle().z, 20, 0.5f);
|
||||
level().addFreshEntity(entityToSpawn);
|
||||
|
||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0, 0, 0, 0, false);
|
||||
|
@ -589,7 +606,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
shootAngle = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).vectorTo(new Vec3(worldPosition2.x, worldPosition2.y, worldPosition2.z)).normalize();
|
||||
|
||||
heliRocketEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
heliRocketEntity.shoot(shootAngle.x, shootAngle.y - 0.01, shootAngle.z, 8, 0.5f);
|
||||
heliRocketEntity.shoot(shootAngle.x, shootAngle.y - 0.07, shootAngle.z, 8, 0.5f);
|
||||
player.level().addFreshEntity(heliRocketEntity);
|
||||
|
||||
this.level().playSound(null, BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z)), ModSounds.HELICOPTER_ROCKET_FIRE_3P.get(), SoundSource.PLAYERS, 5, 1);
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.atsuishio.superbwarfare.entity.vehicle.base;
|
||||
|
||||
public interface AircraftEntity extends AirEntity {
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public interface AircraftEntity extends AirEntity {
|
||||
Vec3 shootPos(float tickDelta);
|
||||
|
||||
Vec3 shootVec(float tickDelta);
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 205 B |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Loading…
Add table
Reference in a new issue