Split Tick update into RotationTick, Tick and PhysicsTick so i can override specific parts in sub classes such as Aeroplane template and Train Template

This commit is contained in:
Halbear
2026-05-31 21:02:40 +01:00
parent b1d5563a39
commit 6dd92f5c16
@@ -242,6 +242,34 @@ public class VehicleBaseEntity extends Entity {
CurrentPositionVector = getPositionVec(); CurrentPositionVector = getPositionVec();
super.tick(); super.tick();
Controller.PollInputs(GetByteArrayValue("INPUT_DATA")); Controller.PollInputs(GetByteArrayValue("INPUT_DATA"));
PhysicsTick();
float CurrentPropRotation = GetFloatDataValue("TARGET_PROPELLER_ROTATION");
float PropIncrementAmount = GetFloatDataValue("PROPELLER_ROTATION_SPEED");
SetFloatDataValue("TARGET_PROPELLER_ROTATION",(CurrentPropRotation + PropIncrementAmount) % 360);
SetFloatDataValue("PROPELLER_ROTATION",CurrentPropRotation);
SubClassTickUpdateEvent();
TickUpdateEvent();
if(this.world.isRemote()){
SubClassServerSideTickEvent();
ClientSideTickEvent();
} else{
SubClassClientSideTickEvent();
ServerSideTickEvent();
}
}
public void RotationTick(){
SetFloatDataValue("ORIENTATION_PITCH",(GetFloatDataValue("ORIENTATION_PITCH") + GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK"))%360);
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK",0f);
SetFloatDataValue("ORIENTATION_ROLL",(GetFloatDataValue("ORIENTATION_ROLL") + GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK"))%360);
SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK",0f);
SetFloatDataValue("ORIENTATION_YAW",(GetFloatDataValue("ORIENTATION_YAW") + GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK"))%360);
SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK",0f);
}
public void PhysicsTick(){
if(GetBooleanDataValue("ADHERES_TO_GRAVITY")){ if(GetBooleanDataValue("ADHERES_TO_GRAVITY")){
if (!this.isOnGround()) { if (!this.isOnGround()) {
this.setMotion(this.getMotion().add(0, -GetDoubleDataValue("GRAVITY"), 0)); this.setMotion(this.getMotion().add(0, -GetDoubleDataValue("GRAVITY"), 0));
@@ -253,16 +281,7 @@ public class VehicleBaseEntity extends Entity {
this.move(net.minecraft.entity.MoverType.SELF, this.getMotion()); this.move(net.minecraft.entity.MoverType.SELF, this.getMotion());
this.setMotion(this.getMotion().mul(0.98D, 0.98D, 0.98D)); this.setMotion(this.getMotion().mul(0.98D, 0.98D, 0.98D));
} }
SetFloatDataValue("ORIENTATION_PITCH",(GetFloatDataValue("ORIENTATION_PITCH") + GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK"))%360); RotationTick();
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK",0f);
SetFloatDataValue("ORIENTATION_ROLL",(GetFloatDataValue("ORIENTATION_ROLL") + GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK"))%360);
SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK",0f);
SetFloatDataValue("ORIENTATION_YAW",(GetFloatDataValue("ORIENTATION_YAW") + GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK"))%360);
SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK",0f);
float CurrentPropRotation = GetFloatDataValue("TARGET_PROPELLER_ROTATION");
float PropIncrementAmount = GetFloatDataValue("PROPELLER_ROTATION_SPEED");
SetFloatDataValue("TARGET_PROPELLER_ROTATION",(CurrentPropRotation + PropIncrementAmount) % 360);
SetFloatDataValue("PROPELLER_ROTATION",CurrentPropRotation);
if(this.getMotion().z == 0 && this.getMotion().x == 0 && this.getMotion().y != 0){ if(this.getMotion().z == 0 && this.getMotion().x == 0 && this.getMotion().y != 0){
double CenterOfMass = GetDoubleDataValue("CENTRE_OF_MASS_Z"); double CenterOfMass = GetDoubleDataValue("CENTRE_OF_MASS_Z");
float CenterOfMassFloat = (float) CenterOfMass; float CenterOfMassFloat = (float) CenterOfMass;
@@ -288,15 +307,6 @@ public class VehicleBaseEntity extends Entity {
} }
} }
} }
SubClassTickUpdateEvent();
TickUpdateEvent();
if(this.world.isRemote()){
SubClassServerSideTickEvent();
ClientSideTickEvent();
} else{
SubClassClientSideTickEvent();
ServerSideTickEvent();
}
} }
public void ApplyForce(double dx, double dy, double dz){ public void ApplyForce(double dx, double dy, double dz){