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 43e0ebe63..406f37e4c 100644 Binary files a/src/main/resources/assets/superbwarfare/textures/screens/cannon/cannon_crosshair.png and b/src/main/resources/assets/superbwarfare/textures/screens/cannon/cannon_crosshair.png differ