From 77741a3b37fcb1910b5f21a8366f525e7eaf0d7e Mon Sep 17 00:00:00 2001 From: Halbear Date: Wed, 3 Jun 2026 15:09:45 +0100 Subject: [PATCH] Fixed save data resetting --- .../net/halbear/hvf/Entity/VehicleBaseEntity.java | 11 +++++++---- .../hvf/Util/Client/VehicleCameraSettings.java | 4 ++-- .../hvf/Util/VehicleData/VehicleBuildInfo.java | 7 +++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/halbear/hvf/Entity/VehicleBaseEntity.java b/src/main/java/net/halbear/hvf/Entity/VehicleBaseEntity.java index addc380..7c80a08 100644 --- a/src/main/java/net/halbear/hvf/Entity/VehicleBaseEntity.java +++ b/src/main/java/net/halbear/hvf/Entity/VehicleBaseEntity.java @@ -65,6 +65,7 @@ public class VehicleBaseEntity extends Entity { BASE_DOUBLE_PARAMETERS.put("GRAVITY",!vehicleBuildInfo.GetAdheresToGravity() ? 0 : vehicleBuildInfo.GetGravityStrength()/200.0); BASE_BOOL_PARAMETERS.put("ADHERES_TO_GRAVITY",vehicleBuildInfo.GetAdheresToGravity()); BASE_BOOL_PARAMETERS.put("ON_GROUND",true); + BASE_BOOL_PARAMETERS.put("WHEEL_FRICTION",vehicleBuildInfo.doWheelsDrag()); BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_X",vehicleBuildInfo.GetCentreOfMass().x); BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_Y",vehicleBuildInfo.GetCentreOfMass().y); BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_Z",vehicleBuildInfo.GetCentreOfMass().z); @@ -257,14 +258,15 @@ public class VehicleBaseEntity extends Entity { @Override protected void readAdditional(CompoundNBT compound) { - if (compound.contains("CustomNBTData")) { + if (compound.contains("VehicleData")) { this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS, compound.getCompound("VehicleData")); } } @Override protected void writeAdditional(CompoundNBT compound) { - compound.put("VehicleData", this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS)); + CompoundNBT SynchedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy(); + compound.put("VehicleData", SynchedData); } @Override @@ -278,7 +280,7 @@ public class VehicleBaseEntity extends Entity { this.baseTick(); this.LastPositionVector = CurrentPositionVector; CurrentPositionVector = getPositionVec(); - PhysicsTick(); + PhysicsTick(!this.world.isRemote()); this.setPosition(this.getPosX(), this.getPosY(), this.getPosZ()); Controller.PollInputs(GetByteArrayValue("INPUT_DATA")); SubClassTickUpdateEvent(); @@ -315,7 +317,8 @@ public class VehicleBaseEntity extends Entity { VehicleVelocity = new Vector3(GetDoubleDataValue("VELOCITY_X"),GetDoubleDataValue("VELOCITY_Y"),GetDoubleDataValue("VELOCITY_Z")); } public boolean TouchingGround(){return GetBooleanDataValue("ON_GROUND");} - public void PhysicsTick(){ + + public void PhysicsTick(boolean ServerSided){ VehicleVelocity = new Vector3(GetDoubleDataValue("VELOCITY_X"),GetDoubleDataValue("VELOCITY_Y"),GetDoubleDataValue("VELOCITY_Z")); Vector3d Velocity = Vector3.Positive(VehicleVelocity).GetDouble(); Vector3d NormalisedVelocity = Velocity.normalize(); diff --git a/src/main/java/net/halbear/hvf/Util/Client/VehicleCameraSettings.java b/src/main/java/net/halbear/hvf/Util/Client/VehicleCameraSettings.java index 0becdad..24ad0b2 100644 --- a/src/main/java/net/halbear/hvf/Util/Client/VehicleCameraSettings.java +++ b/src/main/java/net/halbear/hvf/Util/Client/VehicleCameraSettings.java @@ -81,8 +81,8 @@ public class VehicleCameraSettings { PointOfView Cam = minecraftInstance.gameSettings.getPointOfView(); if (Cam == PointOfView.FIRST_PERSON) { //event.setRoll(event.getRoll() - CurrentPreset.GetCameraTransformations().getZ()); - //event.setYaw(event.getYaw() + (180F - CurrentPreset.GetCameraTransformations().getX())); - //event.setPitch(event.getPitch() - CurrentPreset.GetCameraTransformations().getY()); + event.setYaw(event.getYaw() + (180F - CurrentPreset.GetCameraTransformations().getX())); + event.setPitch(event.getPitch() - CurrentPreset.GetCameraTransformations().getY()); } } } diff --git a/src/main/java/net/halbear/hvf/Util/VehicleData/VehicleBuildInfo.java b/src/main/java/net/halbear/hvf/Util/VehicleData/VehicleBuildInfo.java index c02f385..eaf056a 100644 --- a/src/main/java/net/halbear/hvf/Util/VehicleData/VehicleBuildInfo.java +++ b/src/main/java/net/halbear/hvf/Util/VehicleData/VehicleBuildInfo.java @@ -21,6 +21,7 @@ public class VehicleBuildInfo { private float GasCelCapacity; private double Gravity = 4.9f; private boolean AdheresToGravity = true; + private boolean WheelsHaveDragAndFriction = true; private Vector3d PilotSeat; private List BuiltInVehicleInputActions = new ArrayList<>(); private List PassengerSeats = new ArrayList<>(); @@ -33,6 +34,12 @@ public class VehicleBuildInfo { private Vector3d OriginOffset = new Vector3d(0,0,0); private PhysicsPreset physicsPreset = PhysicsPreset.AdvancedMinecraft; + public boolean doWheelsDrag(){return WheelsHaveDragAndFriction;} + public VehicleBuildInfo SetWheelDrag(boolean WheelsDrag){ + this.WheelsHaveDragAndFriction = WheelsDrag; + return this; + } + public VehicleBuildInfo SetOrigin(PivotOrigin OriginType, Vector3d OriginOffset){ this.OriginType = OriginType; this.OriginOffset = OriginOffset;