优化飞行载具视角
This commit is contained in:
parent
5a00b40865
commit
d14710743c
4 changed files with 7 additions and 69 deletions
|
@ -87,10 +87,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
public int lockTime;
|
||||
public boolean locked;
|
||||
private boolean wasFiring = false;
|
||||
|
||||
public float delta_xo;
|
||||
public float delta_yo;
|
||||
|
||||
public float delta_x;
|
||||
public float delta_y;
|
||||
|
||||
|
@ -210,9 +206,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
|
||||
this.lockingTargetO = getTargetUuid();
|
||||
|
||||
delta_xo = delta_x;
|
||||
delta_yo = delta_y;
|
||||
|
||||
super.baseTick();
|
||||
float f = (float) Mth.clamp(Math.max((onGround() ? 0.819f : 0.82f) - 0.0035 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
||||
|
||||
|
@ -1067,7 +1060,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
@Override
|
||||
public @Nullable Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||
if (this.getSeatIndex(player) == 0) {
|
||||
return new Vec2((float) (getRotY(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getRotX(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
||||
return new Vec2((float) (getRotY(partialTicks) - freeCameraYaw), (float) (getRotX(partialTicks) + freeCameraPitch));
|
||||
}
|
||||
|
||||
return super.getCameraRotation(partialTicks, player, false, false);
|
||||
|
|
|
@ -70,9 +70,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
public int holdPowerTick;
|
||||
public float destroyRot;
|
||||
|
||||
public float delta_xo;
|
||||
public float delta_yo;
|
||||
|
||||
public float delta_x;
|
||||
public float delta_y;
|
||||
|
||||
|
@ -162,8 +159,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
delta_xo = delta_x;
|
||||
delta_yo = delta_y;
|
||||
super.baseTick();
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
|
@ -732,7 +727,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
@Override
|
||||
public @Nullable Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||
if (this.getSeatIndex(player) == 0) {
|
||||
return new Vec2((float) (getRotY(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getRotX(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
||||
return new Vec2((float) (getRotY(partialTicks) - freeCameraYaw), (float) (getRotX(partialTicks) + freeCameraPitch));
|
||||
}
|
||||
|
||||
return super.getCameraRotation(partialTicks, player, false, false);
|
||||
|
|
|
@ -6,10 +6,8 @@ import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
|||
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
||||
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.tools.CameraTool;
|
||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.mojang.math.Axis;
|
||||
|
@ -34,8 +32,6 @@ import net.minecraft.world.item.Items;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
|
@ -52,17 +48,11 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraPitch;
|
||||
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraYaw;
|
||||
|
||||
public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||
public static final EntityDataAccessor<Boolean> MELON = SynchedEntityData.defineId(Tom6Entity.class, EntityDataSerializers.BOOLEAN);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
private float yRotSync;
|
||||
|
||||
public float delta_xo;
|
||||
public float delta_yo;
|
||||
|
||||
public float delta_x;
|
||||
public float delta_y;
|
||||
|
||||
|
@ -117,8 +107,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
delta_xo = delta_x;
|
||||
delta_yo = delta_y;
|
||||
super.baseTick();
|
||||
|
||||
delta_x = entityData.get(MOUSE_SPEED_Y);
|
||||
|
@ -383,41 +371,4 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
public @Nullable ResourceLocation getVehicleItemIcon() {
|
||||
return Mod.loc("textures/gui/vehicle/type/aircraft.png");
|
||||
}
|
||||
|
||||
public Matrix4f getClientVehicleTransform(float ticks) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo + 0.5f, getY() + 0.5f), (float) Mth.lerp(ticks, zo, getZ()));
|
||||
transform.rotate(Axis.YP.rotationDegrees((float) (-Mth.lerp(ticks, yRotO, getYRot()) + freeCameraYaw)));
|
||||
transform.rotate(Axis.XP.rotationDegrees((float) (Mth.lerp(ticks, xRotO, getXRot()) + freeCameraPitch)));
|
||||
transform.rotate(Axis.ZP.rotationDegrees(Mth.lerp(ticks, prevRoll, getRoll())));
|
||||
return transform;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public @Nullable Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||
if (this.getSeatIndex(player) == 0 && Mth.abs((float) (freeCameraYaw * freeCameraPitch)) > 0.01) {
|
||||
return new Vec2((float) (getYaw(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getPitch(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
||||
}
|
||||
|
||||
return super.getCameraRotation(partialTicks, player, false, false);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public Vec3 getCameraPosition(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||
if (this.getSeatIndex(player) == 0 && Mth.abs((float) (freeCameraYaw * freeCameraPitch)) > 0.01) {
|
||||
Matrix4f transform = getClientVehicleTransform(partialTicks);
|
||||
|
||||
Vector4f maxCameraPosition = transformPosition(transform, 0, 2.5f, -6 - (float) ClientMouseHandler.custom3pDistanceLerp);
|
||||
Vec3 finalPos = CameraTool.getMaxZoom(transform, maxCameraPosition);
|
||||
|
||||
if (isFirstPerson) {
|
||||
return new Vec3(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
|
||||
} else {
|
||||
return finalPos;
|
||||
}
|
||||
}
|
||||
return super.getCameraPosition(partialTicks, player, false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,12 +128,11 @@ public class ClientMouseHandler {
|
|||
|
||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
|
||||
if (isFreeCam(player)) {
|
||||
freeCameraYaw -= 0.4f * times * lerpSpeedX;
|
||||
freeCameraPitch += 0.3f * times * lerpSpeedY;
|
||||
} else {
|
||||
freeCameraYaw = Mth.lerp(0.2 * times, freeCameraYaw, 0);
|
||||
freeCameraPitch = Mth.lerp(0.2 * times, freeCameraPitch, 0);
|
||||
freeCameraYaw -= 0.4f * times * lerpSpeedX;
|
||||
freeCameraPitch += 0.3f * times * lerpSpeedY;
|
||||
if (!isFreeCam(player)) {
|
||||
freeCameraYaw = Mth.lerp(0.4 * times, freeCameraYaw, 0);
|
||||
freeCameraPitch = Mth.lerp(0.4 * times, freeCameraPitch, 0);
|
||||
}
|
||||
|
||||
while (freeCameraYaw > 180F) {
|
||||
|
|
Loading…
Add table
Reference in a new issue