From 740b810168193d22e4cc71446222cb37684c4615 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Wed, 9 Apr 2025 17:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E4=BA=BA=E6=9C=BAsh?= =?UTF-8?q?ader=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=82=AE=E5=BC=B9=E9=87=8D?= =?UTF-8?q?=E5=8A=9B=EF=BC=8C=E9=87=8D=E5=88=B6=E7=81=AB=E7=82=AE=E6=A0=87?= =?UTF-8?q?=E5=B0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/overlay/CannonHudOverlay.java | 11 ++- .../client/overlay/DroneHudOverlay.java | 4 ++ .../client/renderer/entity/Mk42Renderer.java | 15 +++- .../renderer/entity/Mle1934Renderer.java | 15 +++- .../entity/projectile/CannonShellEntity.java | 6 +- .../entity/vehicle/Bmp2Entity.java | 1 + .../entity/vehicle/Lav150Entity.java | 1 + .../entity/vehicle/Mk42Entity.java | 41 ++++++++--- .../entity/vehicle/Mle1934Entity.java | 43 +++++++++--- .../entity/vehicle/PrismTankEntity.java | 1 + .../entity/vehicle/SpeedboatEntity.java | 1 + .../entity/vehicle/Yx100Entity.java | 3 + .../entity/vehicle/base/VehicleEntity.java | 4 ++ .../vehicle/weapon/CannonShellWeapon.java | 10 ++- .../event/ClientEventHandler.java | 14 +--- .../superbwarfare/mixins/CameraMixin.java | 8 ++- .../shaders/post/scan_pincushion.json | 17 ----- .../shaders/program/scan_pincushion.fsh | 66 ------------------ .../shaders/program/scan_pincushion.json | 18 ----- .../screens/cannon/cannon_crosshair.png | Bin 5894 -> 6095 bytes 20 files changed, 137 insertions(+), 142 deletions(-) delete mode 100644 src/main/resources/assets/superbwarfare/shaders/post/scan_pincushion.json delete mode 100644 src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.fsh delete mode 100644 src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.json diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java index 4d1307871..1aacc6a4d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java @@ -97,10 +97,17 @@ public class CannonHudOverlay implements LayeredDraw.Layer { int k = (w - i) / 2; int l = (h - j) / 2; if (ClientEventHandler.zoomVehicle) { - Entity lookingEntity = TraceTool.findLookingEntity(player, 512); + + Vec3 shootPos = player.getEyePosition(deltaTracker.getRealtimeDeltaTicks()); + + if (!(cannon instanceof AnnihilatorEntity)) { + shootPos = cannon.driverZoomPos(deltaTracker.getRealtimeDeltaTicks()); + } + + Entity lookingEntity = TraceTool.vehiclefFindLookingEntity(cannon, shootPos, 512); boolean lookAtEntity = false; - BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getViewVector(1).scale(512)), + BlockHitResult result = player.level().clip(new ClipContext(shootPos, shootPos.add(player.getViewVector(1).scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)); Vec3 hitPos = result.getLocation(); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/DroneHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/DroneHudOverlay.java index a891473c3..2e0ea0cce 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/DroneHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/DroneHudOverlay.java @@ -43,6 +43,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer { public static int MAX_DISTANCE = 256; 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"); @Override @ParametersAreNonnullByDefault @@ -72,6 +73,9 @@ public class DroneHudOverlay implements LayeredDraw.Layer { if (stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) { guiGraphics.blit(Mod.loc("textures/screens/drone.png"), w / 2 - 16, h / 2 - 16, 0, 0, 32, 32, 32, 32); guiGraphics.blit(Mod.loc("textures/screens/drone_fov.png"), w / 2 + 100, h / 2 - 64, 0, 0, 64, 129, 64, 129); + int addW = (w / h) * 48; + 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); guiGraphics.drawString(mc.font, Component.literal(FormatTool.format1D(ClientEventHandler.droneFovLerp, "x")), diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java index de64220e8..48547590b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java @@ -3,15 +3,19 @@ package com.atsuishio.superbwarfare.client.renderer.entity; import com.atsuishio.superbwarfare.client.layer.vehicle.Mk42Layer; import com.atsuishio.superbwarfare.client.model.entity.Mk42Model; import com.atsuishio.superbwarfare.entity.vehicle.Mk42Entity; +import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import net.minecraft.world.entity.player.Player; import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.cache.object.GeoBone; import software.bernie.geckolib.renderer.GeoEntityRenderer; public class Mk42Renderer extends GeoEntityRenderer { @@ -44,7 +48,14 @@ public class Mk42Renderer extends GeoEntityRenderer { } @Override - protected float getDeathMaxRotation(Mk42Entity entityLivingBaseIn) { - return 0.0F; + public void renderRecursively(PoseStack poseStack, Mk42Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) { + String name = bone.getName(); + + if (name.equals("bone")) { + Player player = Minecraft.getInstance().player; + bone.setHidden(ClientEventHandler.zoomVehicle && animatable.getFirstPassenger() == player); + } + + super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java index 3127a63d6..382e77402 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java @@ -3,15 +3,19 @@ package com.atsuishio.superbwarfare.client.renderer.entity; import com.atsuishio.superbwarfare.client.layer.vehicle.Mle1934Layer; import com.atsuishio.superbwarfare.client.model.entity.Mle1934Model; import com.atsuishio.superbwarfare.entity.vehicle.Mle1934Entity; +import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import net.minecraft.world.entity.player.Player; import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.cache.object.GeoBone; import software.bernie.geckolib.renderer.GeoEntityRenderer; public class Mle1934Renderer extends GeoEntityRenderer { @@ -44,7 +48,14 @@ public class Mle1934Renderer extends GeoEntityRenderer { } @Override - protected float getDeathMaxRotation(Mle1934Entity entityLivingBaseIn) { - return 0.0F; + public void renderRecursively(PoseStack poseStack, Mle1934Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) { + String name = bone.getName(); + + if (name.equals("bone")) { + Player player = Minecraft.getInstance().player; + bone.setHidden(ClientEventHandler.zoomVehicle && animatable.getFirstPassenger() == player); + } + + super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java index c7e900d31..4b861137d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java @@ -51,19 +51,21 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt private int durability = 40; private boolean firstHit = true; public Set loadedChunks = new HashSet<>(); + private float gravity = 0.1f; public CannonShellEntity(EntityType type, Level world) { super(type, world); this.noCulling = true; } - public CannonShellEntity(LivingEntity entity, Level world, float damage, float radius, float explosionDamage, float fireProbability, int fireTime) { + public CannonShellEntity(LivingEntity entity, Level world, float damage, float radius, float explosionDamage, float fireProbability, int fireTime, float gravity) { super(ModEntities.CANNON_SHELL.get(), entity, world); this.damage = damage; this.radius = radius; this.explosionDamage = explosionDamage; this.fireProbability = fireProbability; this.fireTime = fireTime; + this.gravity = gravity; } public CannonShellEntity durability(int durability) { @@ -310,7 +312,7 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt @Override protected double getDefaultGravity() { - return 0.2F; + return gravity; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 214c3cf9a..0219f005e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -494,6 +494,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit return 5; } + @Override public Vec3 driverZoomPos(float ticks) { Matrix4f transform = getTurretTransform(ticks); Vector4f worldPosition = transformPosition(transform, 0, 0, 0.75f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index dbb6c768f..0f81d5b59 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -418,6 +418,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt return 5; } + @Override public Vec3 driverZoomPos(float ticks) { Matrix4f transform = getTurretTransform(ticks); Vector4f worldPosition = transformPosition(transform, 0.3f, 0.75f, 0.56f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 92d095e6e..6973e263f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -60,6 +60,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity public static final EntityDataAccessor PITCH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor YAW = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); + private final float shellGravity = 0.1f; public Mk42Entity(EntityType type, Level world) { super(type, world); @@ -82,6 +83,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity .explosionDamage(VehicleConfig.MK42_AP_EXPLOSION_DAMAGE.get()) .explosionRadius(VehicleConfig.MK42_AP_EXPLOSION_RADIUS.get().floatValue()) .durability(60) + .gravity(shellGravity) .sound(ModSounds.CANNON_RELOAD.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")), new CannonShellWeapon() @@ -91,6 +93,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity .durability(0) .fireProbability(0.18F) .fireTime(2) + .gravity(shellGravity) .sound(ModSounds.CANNON_RELOAD.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")), } @@ -150,18 +153,25 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity int targetX = pos.getX(); int targetY = pos.getY(); int targetZ = pos.getZ(); + var isDepressed = parameters.isDepressed(); - if (!RangeTool.canReach(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), -14.9, 85, parameters.isDepressed())) + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0f, 2.16f, 0.5175f); + Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + + if (!RangeTool.canReach(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), -14.9, 85, isDepressed)) return; this.look(new Vec3(targetX, targetY, targetZ)); - entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), parameters.isDepressed())); + entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), isDepressed)); } private void look(Vec3 pTarget) { - Vec3 vec3 = this.getEyePosition(); - double d0 = pTarget.x - vec3.x; - double d2 = pTarget.z - vec3.z; + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0f, 2.16f, 0.5175f); + Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + double d0 = pTarget.x - shootPos.x; + double d2 = pTarget.z - shootPos.z; entityData.set(YAW, Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F)); } @@ -274,6 +284,13 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z); } + @Override + public Vec3 driverZoomPos(float ticks) { + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0f, 2.16f + 1.4f, 0.5175f); + return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + } + @Override public void vehicleShoot(Player player, int type) { if (this.entityData.get(COOL_DOWN) > 0) return; @@ -346,7 +363,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity Entity passenger = this.getFirstPassenger(); if (passenger != null) { entityData.set(YAW, passenger.getYHeadRot()); - entityData.set(PITCH, passenger.getXRot() - 1.3f); + entityData.set(PITCH, passenger.getXRot() - 2f); } float diffY = Mth.wrapDegrees(entityData.get(YAW) - this.getYRot()); @@ -355,12 +372,12 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity turretTurnSound(diffX, diffY, 0.95f); this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY, -1.75f, 1.75f)); - this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -3f, 3f), -85, 16.3f)); + this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -3f, 3f), -85, 15f)); } protected void clampRotation(Entity entity) { float f = Mth.wrapDegrees(entity.getXRot()); - float f1 = Mth.clamp(f, -85.0F, 16.3F); + float f1 = Mth.clamp(f, -85.0F, 17F); entity.xRotO += f1 - f; entity.setXRot(entity.getXRot() + f1 - f); } @@ -418,6 +435,14 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity return 5; } + @Override + public Vec3 getBarrelVector(float pPartialTicks) { + if (getFirstPassenger() != null) { + return getFirstPassenger().getViewVector(pPartialTicks); + } + return super.getBarrelVector(pPartialTicks); + } + @Override public ResourceLocation getVehicleIcon() { return Mod.loc("textures/vehicle_icon/sherman_icon.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index 56c05bdec..f2fe3d7c2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -60,6 +60,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt public static final EntityDataAccessor PITCH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor YAW = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); + private final float shellGravity = 0.1f; public Mle1934Entity(EntityType type, Level world) { super(type, world); @@ -74,6 +75,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt .explosionDamage(VehicleConfig.MLE1934_AP_EXPLOSION_DAMAGE.get()) .explosionRadius(VehicleConfig.MLE1934_AP_EXPLOSION_RADIUS.get().floatValue()) .durability(70) + .gravity(shellGravity) .sound(ModSounds.CANNON_RELOAD.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")), new CannonShellWeapon() @@ -83,6 +85,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt .durability(0) .fireProbability(0.24F) .fireTime(5) + .gravity(shellGravity) .sound(ModSounds.CANNON_RELOAD.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")), } @@ -153,18 +156,27 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt int targetX = pos.getX(); int targetY = pos.getY(); int targetZ = pos.getZ(); + var isDepressed = parameters.isDepressed(); - if (!RangeTool.canReach(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), -2.7, 30, parameters.isDepressed())) + this.look(new Vec3(targetX, targetY, targetZ)); + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f, 1.52065f); + Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + + if (!RangeTool.canReach(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), -2.7, 30, isDepressed)) return; this.look(new Vec3(targetX, targetY, targetZ)); - entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), parameters.isDepressed())); + entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), isDepressed)); } private void look(Vec3 pTarget) { - Vec3 vec3 = this.getEyePosition(); - double d0 = pTarget.x - vec3.x; - double d2 = pTarget.z - vec3.z; + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f, 1.52065f); + Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + + double d0 = pTarget.x - shootPos.x; + double d2 = pTarget.z - shootPos.z; entityData.set(YAW, Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F)); } @@ -282,6 +294,13 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt this.discard(); } + @Override + public Vec3 driverZoomPos(float ticks) { + Matrix4f transform = getVehicleFlatTransform(1); + Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f + 1.4f, 1.52065f); + return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); + } + @Override public void vehicleShoot(Player player, int type) { if (this.entityData.get(COOL_DOWN) > 0) return; @@ -404,7 +423,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt Entity passenger = this.getFirstPassenger(); if (passenger != null) { entityData.set(YAW, passenger.getYHeadRot()); - entityData.set(PITCH, passenger.getXRot() - 1.2f); + entityData.set(PITCH, passenger.getXRot() - 2f); } float diffY = Mth.wrapDegrees(entityData.get(YAW) - this.getYRot()); @@ -413,12 +432,12 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt turretTurnSound(diffX, diffY, 0.95f); this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY, -1.25f, 1.25f)); - this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -2f, 2f), -30, 4f)); + this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -2f, 2f), -30, 5f)); } protected void clampRotation(Entity entity) { float f = Mth.wrapDegrees(entity.getXRot()); - float f1 = Mth.clamp(f, -30.0F, 4.0F); + float f1 = Mth.clamp(f, -30.0F, 7.0F); entity.xRotO += f1 - f; entity.setXRot(entity.getXRot() + f1 - f); } @@ -485,6 +504,14 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt return 5; } + @Override + public Vec3 getBarrelVector(float pPartialTicks) { + if (getFirstPassenger() != null) { + return getFirstPassenger().getViewVector(pPartialTicks); + } + return super.getBarrelVector(pPartialTicks); + } + @Override public ResourceLocation getVehicleIcon() { return Mod.loc("textures/vehicle_icon/mle1934_icon.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java index 7629959d9..c3aa96fc9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -556,6 +556,7 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); } + @Override public Vec3 driverZoomPos(float ticks) { Matrix4f transform = getBarrelTransform(ticks); Vector4f worldPosition = transformPosition(transform, 0, 0.95f, 0f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index 8c32b6cea..bd01c904e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -428,6 +428,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo this.clampRotation(entity); } + @Override public Vec3 driverZoomPos(float ticks) { Matrix4f transform = getBarrelTransform(ticks); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index 46bd360fe..5c0535159 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -104,6 +104,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti .fireTime(0) .durability(100) .velocity(40) + .gravity(0.1f) .sound(ModSounds.INTO_MISSILE.get()) .ammo(ModItems.AP_5_INCHES.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")), @@ -116,6 +117,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti .fireTime(2) .durability(0) .velocity(25) + .gravity(0.1f) .sound(ModSounds.INTO_CANNON.get()) .ammo(ModItems.HE_5_INCHES.get()) .icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")), @@ -763,6 +765,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti } } + @Override public Vec3 driverZoomPos(float ticks) { Matrix4f transform = getTurretTransform(ticks); Vector4f worldPosition = transformPosition(transform, 0, 1.2f, 0.6076875f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index dc850c79c..0824cfb2b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -947,6 +947,10 @@ public abstract class VehicleEntity extends Entity { this.gunXRot = pGunXRot; } + public Vec3 driverZoomPos(float ticks) { + return getEyePosition(); + } + public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) { if (!(this instanceof WeaponVehicleEntity weaponVehicle)) return; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java index b39b30cae..04a84a758 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import net.minecraft.world.entity.player.Player; public class CannonShellWeapon extends VehicleWeapon { - public float hitDamage, explosionRadius, explosionDamage, fireProbability, velocity; + public float hitDamage, explosionRadius, explosionDamage, fireProbability, velocity, gravity; public int fireTime, durability; public CannonShellWeapon hitDamage(float hitDamage) { @@ -42,6 +42,11 @@ public class CannonShellWeapon extends VehicleWeapon { return this; } + public CannonShellWeapon gravity(float gravity) { + this.gravity = gravity; + return this; + } + public CannonShellEntity create(Player player) { return new CannonShellEntity(player, player.level(), @@ -49,7 +54,8 @@ public class CannonShellWeapon extends VehicleWeapon { this.explosionRadius, this.explosionDamage, this.fireProbability, - this.fireTime + this.fireTime, + this.gravity ).durability(this.durability); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 597355cbc..744ae8a3e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -876,11 +876,6 @@ public class ClientEventHandler { && tag.getBoolean("Linked")) ) { handleDroneCamera(event, living, tag); - } else { - var effect = Minecraft.getInstance().gameRenderer.currentEffect(); - if (effect != null && effect.getName().equals(Mod.MODID + ":shaders/post/scan_pincushion.json")) { - Minecraft.getInstance().gameRenderer.shutdownEffect(); - } } LocalPlayer player = Minecraft.getInstance().player; @@ -931,19 +926,12 @@ public class ClientEventHandler { handleShockCamera(event, living); } - public static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity, final CompoundTag tag) { + private static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity, final CompoundTag tag) { DroneEntity drone = EntityFindUtil.findDrone(entity.level(), tag.getString("LinkedDrone")); if (drone != null) { event.setRoll(drone.getRoll((float) event.getPartialTick()) * (1 - (drone.getPitch((float) event.getPartialTick()) / 90))); } - - if (drone != null && tag.getBoolean("Using")) { - if (Minecraft.getInstance().gameRenderer.currentEffect() == null) { - // TODO 无人机 shader -// Minecraft.getInstance().gameRenderer.loadEffect(Mod.loc("shaders/post/scan_pincushion.json")); - } - } } @SubscribeEvent(priority = EventPriority.HIGHEST) diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java index aeca14e4f..7952aab6d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java @@ -140,9 +140,13 @@ public abstract class CameraMixin { return; } - if (player.getVehicle() instanceof CannonEntity && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) { + if (player.getVehicle() instanceof VehicleEntity vehicle && vehicle instanceof CannonEntity cannon && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) { setRotation(Mth.lerp(partialTicks, player.yRotO, player.getYRot()), Mth.lerp(partialTicks, player.xRotO, player.getXRot())); - setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ())); + if (!(cannon instanceof AnnihilatorEntity) && ClientEventHandler.zoomVehicle) { + setPosition(vehicle.driverZoomPos(partialTicks).x, vehicle.driverZoomPos(partialTicks).y, vehicle.driverZoomPos(partialTicks).z); + } else { + setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ())); + } info.cancel(); } } diff --git a/src/main/resources/assets/superbwarfare/shaders/post/scan_pincushion.json b/src/main/resources/assets/superbwarfare/shaders/post/scan_pincushion.json deleted file mode 100644 index b5d0a3ed2..000000000 --- a/src/main/resources/assets/superbwarfare/shaders/post/scan_pincushion.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "targets": [ - "swap" - ], - "passes": [ - { - "name": "scan_pincushion", - "intarget": "minecraft:main", - "outtarget": "swap" - }, - { - "name": "blit", - "intarget": "swap", - "outtarget": "minecraft:main" - } - ] -} diff --git a/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.fsh b/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.fsh deleted file mode 100644 index 847c9da49..000000000 --- a/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.fsh +++ /dev/null @@ -1,66 +0,0 @@ -#version 150 - -uniform sampler2D DiffuseSampler; - -in vec2 texCoord; -in vec2 oneTexel; - -uniform vec2 InSize; - -const vec4 Zero = vec4(0.0); -const vec4 Half = vec4(0.5); -const vec4 One = vec4(1.0); -const vec4 Two = vec4(2.0); - -const float Pi = 3.1415926535; -const float PincushionAmount = 0.02; -const float CurvatureAmount = 0.02; -const float ScanlineAmount = 0.8; -const float ScanlineScale = 1.0; -const float ScanlineHeight = 1.0; -const float ScanlineBrightScale = 1.0; -const float ScanlineBrightOffset = 0.0; -const float ScanlineOffset = 0.0; -const vec3 Floor = vec3(0.05, 0.05, 0.05); -const vec3 Power = vec3(0.8, 0.8, 0.8); - -out vec4 fragColor; - -void main() { - vec4 InTexel = texture(DiffuseSampler, texCoord); - - vec2 PinUnitCoord = texCoord * Two.xy - One.xy; - float PincushionR2 = pow(length(PinUnitCoord), 2.0); - vec2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2; - vec2 ScanCoord = texCoord; - - ScanCoord *= One.xy - PincushionAmount * 0.2; - ScanCoord += PincushionAmount * 0.1; - ScanCoord += PincushionCurve; - - vec2 CurvatureClipCurve = PinUnitCoord * CurvatureAmount * PincushionR2; - vec2 ScreenClipCoord = texCoord; - ScreenClipCoord -= Half.xy; - ScreenClipCoord *= One.xy - CurvatureAmount * 0.2; - ScreenClipCoord += Half.xy; - ScreenClipCoord += CurvatureClipCurve; - - // -- Alpha Clipping -- - if (ScanCoord.x < 0.0) discard; - if (ScanCoord.y < 0.0) discard; - if (ScanCoord.x > 1.0) discard; - if (ScanCoord.y > 1.0) discard; - - // -- Scanline Simulation -- - float InnerSine = ScanCoord.y * InSize.y * ScanlineScale * 0.25; - float ScanBrightMod = sin(InnerSine * Pi + ScanlineOffset * InSize.y * 0.25); - float ScanBrightness = mix(1.0, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0) * 0.5, ScanlineAmount); - vec3 ScanlineTexel = InTexel.rgb * ScanBrightness; - - // -- Color Compression (increasing the floor of the signal without affecting the ceiling) -- - ScanlineTexel = Floor + (One.xyz - Floor) * ScanlineTexel; - - ScanlineTexel.rgb = pow(ScanlineTexel.rgb, Power); - - fragColor = vec4(ScanlineTexel.rgb, 1.0); -} diff --git a/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.json b/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.json deleted file mode 100644 index 9c7f9a3d8..000000000 --- a/src/main/resources/assets/superbwarfare/shaders/program/scan_pincushion.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "blend": { - "func": "add", - "srcrgb": "one", - "dstrgb": "zero" - }, - "vertex": "sobel", - "fragment": "scan_pincushion", - "attributes": [ "Position" ], - "samplers": [ - { "name": "DiffuseSampler" } - ], - "uniforms": [ - { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, - { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } - ] -} diff --git a/src/main/resources/assets/superbwarfare/textures/screens/cannon/cannon_crosshair.png b/src/main/resources/assets/superbwarfare/textures/screens/cannon/cannon_crosshair.png index 43e0ebe63497c78af3ec4987fd6e8a19af84eba6..406f37e4c0922063f89b41211d457790b1e80411 100644 GIT binary patch literal 6095 zcmeHKdr*^C7C%WC2`B^AZG+lSMq6=e3%G2BMMBapRH+nbMQTfh4A!x&yC_;K1R)=5 zwZouwcj%xYaSQ19;%02XJTMP0C-k2X9{6R=>FeVD>!n zW5MU8{s6p!xR@7{vrF%Gy_VU%`WO4!jxH_Q_xPa=xoO?=#eu9RZ+~vnhK%9>kH7%Oq)Sq27ws_W)PS`U4zI=njvHnESXs;u+#qQZTL~r5K zhDg28|H3LWDIutPc_~|A{igS8WI1KNw}p2dh8qFjICJ%?oek1se5O%5ptM?PGu@@DTc>3D&0E&dDv7{Q<#Z(1rB_LqD<<7hz0@obhb|!t0x2&zcghl$ zPdDb*^gG@dpHtOvzEEtYDm5#ILmn^b|6%Xo;+C*EmTyImQs>1*B zB{zl1uaQUR2nN56Co@Epb7T$0SLA%{dAUzn-WV{@8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