Entities visually rotate with vehicle
This commit is contained in:
@@ -4,6 +4,8 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
import net.halbear.hvf.Halsvehicleframework;
|
import net.halbear.hvf.Halsvehicleframework;
|
||||||
|
import net.halbear.hvf.Util.Client.VehicleCameraPreset;
|
||||||
|
import net.halbear.hvf.Util.Client.VehicleCameraSettings;
|
||||||
import net.halbear.hvf.Util.Math.ExtendedVectors.Vector3;
|
import net.halbear.hvf.Util.Math.ExtendedVectors.Vector3;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
@@ -20,6 +22,9 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.halbear.hvf.Entity.Renderer.VehicleAnimationManager.DegToRad;
|
||||||
|
import static net.halbear.hvf.Util.Math.CommonFunctions.getRotationMatrix4f;
|
||||||
|
|
||||||
public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityModel<VehicleBaseEntity>> extends EntityRenderer<T> {
|
public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityModel<VehicleBaseEntity>> extends EntityRenderer<T> {
|
||||||
|
|
||||||
private Vector3f LastRotations = new Vector3f(0,0,0);
|
private Vector3f LastRotations = new Vector3f(0,0,0);
|
||||||
@@ -85,12 +90,14 @@ public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityMo
|
|||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
EventBeforeRender(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
EventBeforeRender(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
||||||
Vector3d OriginPosition = new Vector3d(0,0,0).add(OriginOffset);
|
Vector3d OriginPosition = new Vector3d(0,0,0).add(OriginOffset);
|
||||||
Vector3f RotationsToAdd = new Vector3f(entity.GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") * partialTicks,entity.GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK") * partialTicks,entity.GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") * partialTicks);
|
Vector3f RotationsToAdd = new Vector3f(-entity.GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") * partialTicks,entity.GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK") * partialTicks,entity.GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") * partialTicks);
|
||||||
Vector3 Offsets = entity.TouchingGround() ? new Vector3(entity.GetDoubleDataValue("ANGLE_OFFSET_YAW"),entity.GetDoubleDataValue("ANGLE_OFFSET_PITCH"),entity.GetDoubleDataValue("ANGLE_OFFSET_ROLL")) : new Vector3(0,0,0);
|
Vector3 Offsets = entity.TouchingGround() ? new Vector3(entity.GetDoubleDataValue("ANGLE_OFFSET_YAW"),entity.GetDoubleDataValue("ANGLE_OFFSET_PITCH"),entity.GetDoubleDataValue("ANGLE_OFFSET_ROLL")) : new Vector3(0,0,0);
|
||||||
float PitchModifier = (float)Math.cos(entity.GetFloatDataValue("ORIENTATION_ROLL") * VehicleAnimationManager.DegToRad);
|
float PitchModifier = (float)Math.cos(entity.GetFloatDataValue("ORIENTATION_ROLL") * DegToRad);
|
||||||
Offsets.multiply(new Vector3(1,PitchModifier,1));
|
Offsets.multiply(new Vector3(1,PitchModifier,1));
|
||||||
Vector3f Rotations = new Vector3f(180.0F - entity.GetVehicleYaw() + Offsets.GetXF(),entity.GetVehiclePitch()+ Offsets.GetYF(),entity.GetVehicleRoll()+ Offsets.GetZF());
|
Vector3f Rotations = new Vector3f(entity.GetVehicleYaw() + Offsets.GetXF(),entity.GetVehiclePitch()+ Offsets.GetYF(),entity.GetVehicleRoll()+ Offsets.GetZF());
|
||||||
Rotations.add(RotationsToAdd);
|
Rotations.add(RotationsToAdd);
|
||||||
|
VehicleCameraSettings.CameraPresets.get(entity.getType()).SetCameraTransformations(Rotations);
|
||||||
|
VehicleCameraSettings.RefreshPreset();
|
||||||
switch(OriginType) {
|
switch(OriginType) {
|
||||||
case PilotSeat:
|
case PilotSeat:
|
||||||
OriginPosition = OriginPosition.add(entity.GetPilotSeat().x,entity.GetPilotSeat().y,entity.GetPilotSeat().z);
|
OriginPosition = OriginPosition.add(entity.GetPilotSeat().x,entity.GetPilotSeat().y,entity.GetPilotSeat().z);
|
||||||
@@ -103,9 +110,7 @@ public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityMo
|
|||||||
}
|
}
|
||||||
entity.SetPartialTick(partialTicks);
|
entity.SetPartialTick(partialTicks);
|
||||||
matrixStack.translate( OriginPosition.x, OriginPosition.y, OriginPosition.z);
|
matrixStack.translate( OriginPosition.x, OriginPosition.y, OriginPosition.z);
|
||||||
matrixStack.rotate(Vector3f.YP.rotationDegrees(Rotations.getX()));
|
matrixStack.getLast().getMatrix().mul(getRotationMatrix4f(Rotations.getX() * DegToRad,Rotations.getY() * DegToRad,Rotations.getZ() * DegToRad));
|
||||||
matrixStack.rotate(Vector3f.XP.rotationDegrees(Rotations.getY()));
|
|
||||||
matrixStack.rotate(Vector3f.ZP.rotationDegrees(Rotations.getZ()));
|
|
||||||
matrixStack.translate( -OriginPosition.x, -OriginPosition.y, -OriginPosition.z);
|
matrixStack.translate( -OriginPosition.x, -OriginPosition.y, -OriginPosition.z);
|
||||||
matrixStack.scale(-1.0F, -1.0F, 1.0F);
|
matrixStack.scale(-1.0F, -1.0F, 1.0F);
|
||||||
matrixStack.translate(0.0D, -1.5D, 0.0D);
|
matrixStack.translate(0.0D, -1.5D, 0.0D);
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_YAW",vehicleBuildInfo.GetAtRestAngleOffsets().x);
|
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_YAW",vehicleBuildInfo.GetAtRestAngleOffsets().x);
|
||||||
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_PITCH",vehicleBuildInfo.GetAtRestAngleOffsets().y);
|
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_PITCH",vehicleBuildInfo.GetAtRestAngleOffsets().y);
|
||||||
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_ROLL",vehicleBuildInfo.GetAtRestAngleOffsets().z);
|
BASE_DOUBLE_PARAMETERS.put("AT_REST_ANGLE_OFFSET_ROLL",vehicleBuildInfo.GetAtRestAngleOffsets().z);
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("VELOCITY_X",0d);
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("VELOCITY_Y",0d);
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("VELOCITY_Z",0d);
|
||||||
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_YAW",0d);
|
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_YAW",0d);
|
||||||
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_PITCH",0d);
|
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_PITCH",0d);
|
||||||
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_ROLL",0d);
|
BASE_DOUBLE_PARAMETERS.put("ANGLE_OFFSET_ROLL",0d);
|
||||||
@@ -157,6 +160,13 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
Diff = Diff.mul(Diff);
|
Diff = Diff.mul(Diff);
|
||||||
return Math.sqrt(Diff.x + Diff.y+ Diff.z);
|
return Math.sqrt(Diff.x + Diff.y+ Diff.z);
|
||||||
}
|
}
|
||||||
|
private static String getCallerMethodName()
|
||||||
|
{
|
||||||
|
StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
|
||||||
|
StackTraceElement e = stacktrace[3];
|
||||||
|
String methodName = e.getMethodName();
|
||||||
|
return methodName;
|
||||||
|
}
|
||||||
public void SetRenderState(String NewState){
|
public void SetRenderState(String NewState){
|
||||||
SetStringDataValue("RENDER_STATE",NewState);
|
SetStringDataValue("RENDER_STATE",NewState);
|
||||||
}
|
}
|
||||||
@@ -188,6 +198,7 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getDouble(ValueName);
|
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getDouble(ValueName);
|
||||||
}
|
}
|
||||||
public void SetFloatDataValue(String ValueName, Float Value){
|
public void SetFloatDataValue(String ValueName, Float Value){
|
||||||
|
System.out.println("VALUE TO CHANGE: " + ValueName + " VALUE:" + Value + " METHOD CALLER: " + getCallerMethodName());
|
||||||
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
||||||
SyncedData.putFloat(ValueName,Value);
|
SyncedData.putFloat(ValueName,Value);
|
||||||
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
|
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
|
||||||
@@ -228,6 +239,8 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
SetVehiclePitch(Pitch);
|
SetVehiclePitch(Pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3d[] GetVehicleSeatOffsets(){return VehicleSeatOffsets;}
|
||||||
|
|
||||||
public UUID GetPilot(){
|
public UUID GetPilot(){
|
||||||
if(this.isBeingRidden() && this.getPassengers().get(0) instanceof ServerPlayerEntity){
|
if(this.isBeingRidden() && this.getPassengers().get(0) instanceof ServerPlayerEntity){
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) this.getPassengers().get(0);
|
ServerPlayerEntity player = (ServerPlayerEntity) this.getPassengers().get(0);
|
||||||
@@ -261,15 +274,16 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
System.out.println("\nNEW TICK\n");
|
||||||
this.baseTick();
|
this.baseTick();
|
||||||
this.LastPositionVector = CurrentPositionVector;
|
this.LastPositionVector = CurrentPositionVector;
|
||||||
CurrentPositionVector = getPositionVec();
|
CurrentPositionVector = getPositionVec();
|
||||||
Controller.PollInputs(GetByteArrayValue("INPUT_DATA"));
|
|
||||||
PhysicsTick();
|
PhysicsTick();
|
||||||
this.setPosition(this.getPosX(), this.getPosY(), this.getPosZ());
|
this.setPosition(this.getPosX(), this.getPosY(), this.getPosZ());
|
||||||
|
Controller.PollInputs(GetByteArrayValue("INPUT_DATA"));
|
||||||
SubClassTickUpdateEvent();
|
SubClassTickUpdateEvent();
|
||||||
TickUpdateEvent();
|
TickUpdateEvent();
|
||||||
SetBooleanDataValue("ON_GROUND",getMotion().y == 0);
|
SetBooleanDataValue("ON_GROUND",Math.abs(CurrentPositionVector.y - LastPositionVector.y) < 0.05D);
|
||||||
if(this.world.isRemote()){
|
if(this.world.isRemote()){
|
||||||
SubClassClientSideTickEvent();
|
SubClassClientSideTickEvent();
|
||||||
ClientSideTickEvent();
|
ClientSideTickEvent();
|
||||||
@@ -281,18 +295,28 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void RotationTick(){
|
public void RotationTick(){
|
||||||
SetFloatDataValue("ORIENTATION_PITCH",(GetFloatDataValue("ORIENTATION_PITCH") + GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK"))%360);
|
if(GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK") != 0) {
|
||||||
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK",0f);
|
SetFloatDataValue("ORIENTATION_PITCH", (GetFloatDataValue("ORIENTATION_PITCH") + GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK")) % 360);
|
||||||
|
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK", 0f);
|
||||||
|
}
|
||||||
|
if(GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") != 0) {
|
||||||
SetFloatDataValue("ORIENTATION_ROLL",(GetFloatDataValue("ORIENTATION_ROLL") + GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK"))%360);
|
SetFloatDataValue("ORIENTATION_ROLL",(GetFloatDataValue("ORIENTATION_ROLL") + GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK"))%360);
|
||||||
SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK",0f);
|
SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK",0f);
|
||||||
|
}
|
||||||
|
if(GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") != 0) {
|
||||||
SetFloatDataValue("ORIENTATION_YAW",(GetFloatDataValue("ORIENTATION_YAW") + GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK"))%360);
|
SetFloatDataValue("ORIENTATION_YAW",(GetFloatDataValue("ORIENTATION_YAW") + GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK"))%360);
|
||||||
SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK",0f);
|
SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK",0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void AddVelocity(double x, double y, double z){
|
public void AddVelocity(double x, double y, double z){
|
||||||
VehicleVelocity.add(x,y,z);
|
SetDoubleDataValue("VELOCITY_Y",GetDoubleDataValue("VELOCITY_Y") + y);
|
||||||
|
SetDoubleDataValue("VELOCITY_X",GetDoubleDataValue("VELOCITY_X") + x);
|
||||||
|
SetDoubleDataValue("VELOCITY_Z",GetDoubleDataValue("VELOCITY_Z") + z);
|
||||||
|
VehicleVelocity = new Vector3(GetDoubleDataValue("VELOCITY_X"),GetDoubleDataValue("VELOCITY_Y"),GetDoubleDataValue("VELOCITY_Z"));
|
||||||
}
|
}
|
||||||
public boolean TouchingGround(){return GetBooleanDataValue("ON_GROUND");}
|
public boolean TouchingGround(){return GetBooleanDataValue("ON_GROUND");}
|
||||||
public void PhysicsTick(){
|
public void PhysicsTick(){
|
||||||
|
VehicleVelocity = new Vector3(GetDoubleDataValue("VELOCITY_X"),GetDoubleDataValue("VELOCITY_Y"),GetDoubleDataValue("VELOCITY_Z"));
|
||||||
Vector3d Velocity = Vector3.Positive(VehicleVelocity).GetDouble();
|
Vector3d Velocity = Vector3.Positive(VehicleVelocity).GetDouble();
|
||||||
Vector3d NormalisedVelocity = Velocity.normalize();
|
Vector3d NormalisedVelocity = Velocity.normalize();
|
||||||
double OverallVelocity = Velocity.x * NormalisedVelocity.x + Velocity.z * NormalisedVelocity.z;
|
double OverallVelocity = Velocity.x * NormalisedVelocity.x + Velocity.z * NormalisedVelocity.z;
|
||||||
@@ -305,26 +329,22 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
SetDoubleDataValue("ANGLE_OFFSET_ROLL",AngleOffsets.z);
|
SetDoubleDataValue("ANGLE_OFFSET_ROLL",AngleOffsets.z);
|
||||||
if(GetBooleanDataValue("ADHERES_TO_GRAVITY")) {
|
if(GetBooleanDataValue("ADHERES_TO_GRAVITY")) {
|
||||||
if (!this.isOnGround()) {
|
if (!this.isOnGround()) {
|
||||||
VehicleVelocity.add(0, -GetDoubleDataValue("GRAVITY"), 0);
|
SetDoubleDataValue("VELOCITY_Y",GetDoubleDataValue("VELOCITY_Y") - GetDoubleDataValue("GRAVITY"));
|
||||||
} else {
|
} else {
|
||||||
if (GetFloatDataValue("ORIENTATION_PITCH") % 90 != 0) {
|
if (GetFloatDataValue("ORIENTATION_PITCH") % 90 != 0) {
|
||||||
SetFloatDataValue("ORIENTATION_PITCH", Math.round(GetFloatDataValue("ORIENTATION_PITCH") / 90.0f) * 90.0f);
|
SetFloatDataValue("ORIENTATION_PITCH", Math.round(GetFloatDataValue("ORIENTATION_PITCH") / 90.0f) * 90.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector3d currentMotion;
|
VehicleVelocity = new Vector3(GetDoubleDataValue("VELOCITY_X"),GetDoubleDataValue("VELOCITY_Y"),GetDoubleDataValue("VELOCITY_Z"));
|
||||||
//!!!!!
|
|
||||||
//REMINDER FOR NEXT TIME
|
|
||||||
//MAKE VehicleVelocity SERVER SIDED
|
|
||||||
//BIG SYNC ISSUES IN MULTIPLAYER
|
|
||||||
//!!!!!
|
|
||||||
setMotion(VehicleVelocity.GetDouble());
|
setMotion(VehicleVelocity.GetDouble());
|
||||||
this.move(net.minecraft.entity.MoverType.SELF, VehicleVelocity.GetDouble());
|
this.move(net.minecraft.entity.MoverType.SELF, VehicleVelocity.GetDouble());
|
||||||
VehicleVelocity = new Vector3(this.getMotion());
|
SetDoubleDataValue("VELOCITY_Y",this.getMotion().y * 0.98d);
|
||||||
VehicleVelocity.multiply(0.98);
|
SetDoubleDataValue("VELOCITY_X",this.getMotion().x * 0.98d);
|
||||||
|
SetDoubleDataValue("VELOCITY_Z",this.getMotion().z * 0.98d);
|
||||||
markVelocityChanged();
|
markVelocityChanged();
|
||||||
RotationTick();
|
RotationTick();
|
||||||
if(Scalar < 1&& VehicleVelocity.y < 0){
|
if(Scalar < 1&& !GetBooleanDataValue("ON_GROUND") && GetDoubleDataValue("VELOCITY_Y") < 0.015){
|
||||||
double CenterOfMass = GetDoubleDataValue("CENTRE_OF_MASS_Z");
|
double CenterOfMass = GetDoubleDataValue("CENTRE_OF_MASS_Z");
|
||||||
float CenterOfMassFloat = (float) CenterOfMass;
|
float CenterOfMassFloat = (float) CenterOfMass;
|
||||||
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK", (float) (-CenterOfMassFloat * (Math.max(1-Scalar,0))));
|
SetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK", (float) (-CenterOfMassFloat * (Math.max(1-Scalar,0))));
|
||||||
@@ -344,6 +364,7 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
public boolean canBePushed() {
|
public boolean canBePushed() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPunchedEvent(){}
|
public void OnPunchedEvent(){}
|
||||||
public void ServerSideTickEvent(){}
|
public void ServerSideTickEvent(){}
|
||||||
public void ClientSideTickEvent(){}
|
public void ClientSideTickEvent(){}
|
||||||
@@ -382,6 +403,7 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
@Override
|
@Override
|
||||||
public void updatePassenger(Entity passenger) {
|
public void updatePassenger(Entity passenger) {
|
||||||
if (this.isPassenger(passenger)) {
|
if (this.isPassenger(passenger)) {
|
||||||
|
|
||||||
int seatIndex = this.getPassengers().indexOf(passenger);
|
int seatIndex = this.getPassengers().indexOf(passenger);
|
||||||
if (seatIndex >= 0 && seatIndex < VehicleSeatOffsets.length) {
|
if (seatIndex >= 0 && seatIndex < VehicleSeatOffsets.length) {
|
||||||
Vector3d localOffset = VehicleSeatOffsets[seatIndex];
|
Vector3d localOffset = VehicleSeatOffsets[seatIndex];
|
||||||
@@ -397,10 +419,13 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
OriginPosition = OriginPosition.add(new Vector3d(0, getHeight()/2, 0));
|
OriginPosition = OriginPosition.add(new Vector3d(0, getHeight()/2, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float yawRad = (float) Math.toRadians(GetFloatDataValue("ORIENTATION_YAW"));
|
float AddYaw = GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK");
|
||||||
float pitchRad = (float) Math.toRadians(GetFloatDataValue("ORIENTATION_PITCH"));
|
float AddPitch = GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK");
|
||||||
float rollRad = (float) Math.toRadians(GetFloatDataValue("ORIENTATION_ROLL"));
|
float AddRoll = GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK");
|
||||||
|
float yawRad = (float) Math.toRadians(180F - (GetFloatDataValue("ORIENTATION_YAW") + AddYaw));
|
||||||
|
float pitchRad = (float) Math.toRadians(GetFloatDataValue("ORIENTATION_PITCH")+ AddPitch);
|
||||||
|
float rollRad = (float) Math.toRadians(GetFloatDataValue("ORIENTATION_ROLL")+ AddRoll);
|
||||||
|
System.out.println((passenger.world.isRemote() ? "CLIENT: " : "SERVER: ") + "AddedValues: " + AddYaw +"_"+AddPitch+"_"+AddRoll);
|
||||||
Matrix4f TransformationMatrix = getRotationMatrix4f(yawRad, pitchRad, rollRad);
|
Matrix4f TransformationMatrix = getRotationMatrix4f(yawRad, pitchRad, rollRad);
|
||||||
|
|
||||||
Vector4f SeatPosition = new Vector4f(
|
Vector4f SeatPosition = new Vector4f(
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
package net.halbear.hvf.Registry.EventHandlers;
|
package net.halbear.hvf.Registry.EventHandlers;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
|
||||||
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
import net.halbear.hvf.UsageExamples.Aeroplane.Renderer.AeroplaneRenderer;
|
import net.halbear.hvf.UsageExamples.Aeroplane.Renderer.AeroplaneRenderer;
|
||||||
import net.halbear.hvf.UsageExamples.Airboat.Renderer.AirboatRenderer;
|
import net.halbear.hvf.UsageExamples.Airboat.Renderer.AirboatRenderer;
|
||||||
import net.halbear.hvf.Halsvehicleframework;
|
import net.halbear.hvf.Halsvehicleframework;
|
||||||
import net.halbear.hvf.Registry.*;
|
import net.halbear.hvf.Registry.*;
|
||||||
|
import net.halbear.hvf.Util.Math.ExtendedVectors.Vector3;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||||
@@ -12,6 +19,7 @@ import net.minecraftforge.fml.common.Mod;
|
|||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
|
||||||
import static net.halbear.hvf.Registry.Input.ModKeybinds.*;
|
import static net.halbear.hvf.Registry.Input.ModKeybinds.*;
|
||||||
|
import static net.halbear.hvf.Util.Math.CommonFunctions.getRotationMatrix4f;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = Halsvehicleframework.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(modid = Halsvehicleframework.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||||
public class ClientEventHandler {
|
public class ClientEventHandler {
|
||||||
|
|||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package net.halbear.hvf.Registry.EventHandlers;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import net.halbear.hvf.Entity.Renderer.PivotOrigin;
|
||||||
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
|
import net.halbear.hvf.Halsvehicleframework;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import static net.halbear.hvf.Util.Math.CommonFunctions.getRotationMatrix4f;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = Halsvehicleframework.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
|
||||||
|
public class ClientEventHandlerForgeEventBus {
|
||||||
|
public static float DegToRad = (float)Math.PI/180.0F;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRenderVehiclePassenger(RenderLivingEvent.Pre<LivingEntity, ?> event){
|
||||||
|
LivingEntity Passenger = event.getEntity();
|
||||||
|
float partialTicks = event.getPartialRenderTick();
|
||||||
|
if(Passenger.isPassenger() && Passenger.getRidingEntity() instanceof VehicleBaseEntity){
|
||||||
|
VehicleBaseEntity vehicle = (VehicleBaseEntity) Passenger.getRidingEntity();
|
||||||
|
Vector3d OriginPosition = new Vector3d(0,0,0).add(vehicle.getBuildInfo().GetOriginOffset());
|
||||||
|
PivotOrigin OriginType = vehicle.getBuildInfo().GetOriginType();
|
||||||
|
switch(OriginType) {
|
||||||
|
case PilotSeat:
|
||||||
|
OriginPosition = OriginPosition.add(vehicle.GetPilotSeat().x,vehicle.GetPilotSeat().y,vehicle.GetPilotSeat().z);
|
||||||
|
break;
|
||||||
|
case EntityPosition:
|
||||||
|
break;
|
||||||
|
case RelativeToEntityCenter:
|
||||||
|
OriginPosition = OriginPosition.add(new Vector3d(0, vehicle.getHeight()/2, 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Vector3f RotationsToAdd = new Vector3f(-vehicle.GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") * partialTicks,vehicle.GetFloatDataValue("ADD_ORIENTATION_PITCH_NEXT_TICK") * partialTicks,vehicle.GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") * partialTicks);
|
||||||
|
Vector3f Rotations = new Vector3f(vehicle.GetVehicleYaw() ,vehicle.GetVehiclePitch(),vehicle.GetVehicleRoll());
|
||||||
|
Rotations.add(RotationsToAdd);
|
||||||
|
MatrixStack matrixStack = event.getMatrixStack();
|
||||||
|
matrixStack.push();
|
||||||
|
float hipHeight = (float) Passenger.getHeight()/2;
|
||||||
|
matrixStack.translate(0.0D, hipHeight, 0.0D);
|
||||||
|
matrixStack.rotate(net.minecraft.util.math.vector.Vector3f.YP.rotationDegrees(180.0F));
|
||||||
|
matrixStack.getLast().getMatrix().mul(getRotationMatrix4f(Rotations.getX() * DegToRad,-Rotations.getY() * DegToRad,-Rotations.getZ() * DegToRad));
|
||||||
|
matrixStack.translate(0.0D, -hipHeight, 0.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRenderVehiclePassengerPost(RenderLivingEvent.Post<LivingEntity, ?> event) {
|
||||||
|
if (event.getEntity().getRidingEntity() instanceof VehicleBaseEntity) {
|
||||||
|
event.getMatrixStack().pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.halbear.hvf.UsageExamples.Aeroplane;
|
package net.halbear.hvf.UsageExamples.Aeroplane;
|
||||||
|
|
||||||
|
import net.halbear.hvf.Entity.Renderer.PivotOrigin;
|
||||||
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
import net.halbear.hvf.Registry.Input.InputCategory;
|
import net.halbear.hvf.Registry.Input.InputCategory;
|
||||||
import net.halbear.hvf.Util.Client.VehicleCameraPreset;
|
import net.halbear.hvf.Util.Client.VehicleCameraPreset;
|
||||||
@@ -24,8 +25,9 @@ public class Aeroplane extends VehicleBaseEntity {
|
|||||||
.SetPilotSeat(new Vector3d(0.0D, -1D, 0.0D))
|
.SetPilotSeat(new Vector3d(0.0D, -1D, 0.0D))
|
||||||
.AddPassengerSeat(new Vector3d(2.0D, 0.5D, 0.25D))
|
.AddPassengerSeat(new Vector3d(2.0D, 0.5D, 0.25D))
|
||||||
.AddPassengerSeat(new Vector3d(-2.0D, 0.5D, 0.25D))
|
.AddPassengerSeat(new Vector3d(-2.0D, 0.5D, 0.25D))
|
||||||
|
.SetOrigin(PivotOrigin.RelativeToEntityCenter, new Vector3d(0,0,0))
|
||||||
.SetGravityStrength(3.8)
|
.SetGravityStrength(3.8)
|
||||||
.SetAtRestAngleOffsets(new Vector3d(0,20,0))
|
.SetAtRestAngleOffsets(new Vector3d(0,15,0))
|
||||||
.SetRotateAngleOffsets(new Vector3d(0,0,0))
|
.SetRotateAngleOffsets(new Vector3d(0,0,0))
|
||||||
.SetRotateVelocity(0.7)
|
.SetRotateVelocity(0.7)
|
||||||
.AdhereToGravity(true);
|
.AdhereToGravity(true);
|
||||||
@@ -38,13 +40,10 @@ public class Aeroplane extends VehicleBaseEntity {
|
|||||||
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
|
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
|
||||||
GetVehicleController().AddInputFunction("Forward",0.029f, new Vector3d(1,90,1), InputCategory.MoveForward);
|
GetVehicleController().AddInputFunction("Forward",0.029f, new Vector3d(1,90,1), InputCategory.MoveForward);
|
||||||
GetVehicleController().AddInputFunction("Backward",0.049f, new Vector3d(1,90,1), InputCategory.MoveBackward);
|
GetVehicleController().AddInputFunction("Backward",0.049f, new Vector3d(1,90,1), InputCategory.MoveBackward);
|
||||||
GetVehicleController().AddInputFunction("StrafeLeft",0.049f, new Vector3d(1,90,1), InputCategory.StrafeLeft);
|
GetVehicleController().AddInputFunction("StrafeLeft",()-> SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK", GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") - 5));
|
||||||
GetVehicleController().AddInputFunction("StrafeRight",0.049f, new Vector3d(1,90,1), InputCategory.StrafeRight);
|
GetVehicleController().AddInputFunction("StrafeRight",()-> SetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK", GetFloatDataValue("ADD_ORIENTATION_ROLL_NEXT_TICK") + 5));
|
||||||
|
GetVehicleController().AddInputFunction("TurnLeft",()-> SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK", GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") - 5));
|
||||||
GetVehicleController().AddInputFunction("GearShiftUp",()-> SetFloatDataValue("ORIENTATION_ROLL", GetFloatDataValue("ORIENTATION_ROLL") + 5));
|
GetVehicleController().AddInputFunction("TurnRight",()-> SetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK", GetFloatDataValue("ADD_ORIENTATION_YAW_NEXT_TICK") + 5));
|
||||||
GetVehicleController().AddInputFunction("GearShiftDown",()-> SetFloatDataValue("ORIENTATION_ROLL", GetFloatDataValue("ORIENTATION_ROLL") - 5));
|
|
||||||
GetVehicleController().AddInputFunction("TurnLeft",()-> SetFloatDataValue("ORIENTATION_YAW", GetFloatDataValue("ORIENTATION_YAW") + 5));
|
|
||||||
GetVehicleController().AddInputFunction("TurnRight",()-> SetFloatDataValue("ORIENTATION_YAW", GetFloatDataValue("ORIENTATION_YAW") - 5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package net.halbear.hvf.Util.Client;
|
package net.halbear.hvf.Util.Client;
|
||||||
|
|
||||||
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.settings.PointOfView;
|
import net.minecraft.client.settings.PointOfView;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
@@ -13,6 +17,8 @@ import net.minecraftforge.fml.common.Mod;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.halbear.hvf.Util.Math.CommonFunctions.getRotationMatrix4f;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class VehicleCameraSettings {
|
public class VehicleCameraSettings {
|
||||||
private static VehicleCameraPreset CurrentPreset = null;
|
private static VehicleCameraPreset CurrentPreset = null;
|
||||||
@@ -22,6 +28,11 @@ public class VehicleCameraSettings {
|
|||||||
return CurrentPreset == null ? null : CurrentPreset.GetCameraOffsets();
|
return CurrentPreset == null ? null : CurrentPreset.GetCameraOffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RefreshPreset(){
|
||||||
|
if(HvfVehicle && CameraPresets.containsKey(CurrentEntity)) {
|
||||||
|
CurrentPreset = CameraPresets.get(CurrentEntity).Clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static Map<EntityType<?>, VehicleCameraPreset> CameraPresets = new HashMap<>();
|
public static Map<EntityType<?>, VehicleCameraPreset> CameraPresets = new HashMap<>();
|
||||||
|
|
||||||
public static void AddEntityCameraPreset(EntityType<?> entityType, VehicleCameraPreset vehicleCameraPreset){
|
public static void AddEntityCameraPreset(EntityType<?> entityType, VehicleCameraPreset vehicleCameraPreset){
|
||||||
@@ -34,14 +45,17 @@ public class VehicleCameraSettings {
|
|||||||
if (event.phase != TickEvent.Phase.END) {
|
if (event.phase != TickEvent.Phase.END) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.player != null && event.player.isPassenger() && event.player.getRidingEntity() != null
|
if (event.player != null && event.player.isPassenger() && event.player.getRidingEntity() != null) {
|
||||||
&& CurrentEntity != event.player.getRidingEntity().getType()) {
|
|
||||||
Entity Current = event.player.getRidingEntity();
|
Entity Current = event.player.getRidingEntity();
|
||||||
CurrentEntity = Current.getType();
|
CurrentEntity = Current.getType();
|
||||||
HvfVehicle = CameraPresets.containsKey(CurrentEntity);
|
HvfVehicle = CameraPresets.containsKey(CurrentEntity);
|
||||||
if (HvfVehicle) {
|
if (HvfVehicle) {
|
||||||
CurrentPreset = CameraPresets.get(CurrentEntity).Clone();
|
CurrentPreset = CameraPresets.get(CurrentEntity).Clone();
|
||||||
}
|
}
|
||||||
|
} else{
|
||||||
|
HvfVehicle = false;
|
||||||
|
CurrentPreset = null;
|
||||||
|
CurrentEntity = null;
|
||||||
}
|
}
|
||||||
if(CurrentPreset == null) return;
|
if(CurrentPreset == null) return;
|
||||||
if ((!event.player.isPassenger() || !HvfVehicle)
|
if ((!event.player.isPassenger() || !HvfVehicle)
|
||||||
@@ -62,9 +76,15 @@ public class VehicleCameraSettings {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onCameraSetup(EntityViewRenderEvent.CameraSetup event) { // sets the Yaw, Roll, and Pitch for the camera, ONLY if its a HEM vehcile as to avoid unnecessary ticks
|
public static void onCameraSetup(EntityViewRenderEvent.CameraSetup event) { // sets the Yaw, Roll, and Pitch for the camera, ONLY if its a HEM vehcile as to avoid unnecessary ticks
|
||||||
if (HvfVehicle) {
|
if (HvfVehicle) {
|
||||||
event.setRoll(event.getRoll() + CurrentPreset.GetCameraTransformations().getX());
|
Minecraft minecraftInstance = Minecraft.getInstance();
|
||||||
event.setYaw(event.getYaw() + CurrentPreset.GetCameraTransformations().getY());
|
if (minecraftInstance.player != null && minecraftInstance.gameRenderer != null) {
|
||||||
event.setPitch(event.getPitch() + CurrentPreset.GetCameraTransformations().getZ());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.halbear.hvf.Util.Mixin;
|
package net.halbear.hvf.Util.Mixin;
|
||||||
|
|
||||||
|
import net.halbear.hvf.Entity.Renderer.PivotOrigin;
|
||||||
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||||
import net.halbear.hvf.Halsvehicleframework;
|
import net.halbear.hvf.Halsvehicleframework;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -10,7 +11,10 @@ import net.minecraft.entity.EntityType;
|
|||||||
import net.minecraft.tags.EntityTypeTags;
|
import net.minecraft.tags.EntityTypeTags;
|
||||||
import net.minecraft.tags.ITag;
|
import net.minecraft.tags.ITag;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
import net.minecraft.util.math.vector.Vector4f;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -19,18 +23,21 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import static net.halbear.hvf.Util.Client.VehicleCameraSettings.GetCameraOffsets;
|
import static net.halbear.hvf.Util.Client.VehicleCameraSettings.GetCameraOffsets;
|
||||||
|
import static net.halbear.hvf.Util.Math.CommonFunctions.getRotationMatrix4f;
|
||||||
|
|
||||||
@Mixin(ActiveRenderInfo.class)
|
@Mixin(ActiveRenderInfo.class)
|
||||||
public abstract class CameraMixin {
|
public abstract class CameraMixin {
|
||||||
@Inject(method = {"update", "func_216772_a","setup"}, at = @At(value = "TAIL"),cancellable = true, remap = true)
|
@Inject(method = {"update", "func_216772_a","setup"}, at = @At(value = "TAIL"),cancellable = true, remap = true)
|
||||||
private void update(IBlockReader currentRenderedLevel, Entity entity, boolean isDetached, boolean isMirrored, float partialTicks, CallbackInfo ci){
|
private void update(IBlockReader currentRenderedLevel, Entity entity, boolean isDetached, boolean isMirrored, float partialTicks, CallbackInfo ci){
|
||||||
if(entity.isPassenger() && Minecraft.getInstance().gameSettings.getPointOfView() != PointOfView.FIRST_PERSON) {
|
if(entity.isPassenger()) {
|
||||||
boolean entityHaveCameraPreset = entity.getRidingEntity() instanceof VehicleBaseEntity;
|
boolean entityHaveCameraPreset = entity.getRidingEntity() instanceof VehicleBaseEntity;
|
||||||
if (entityHaveCameraPreset) {
|
if (entityHaveCameraPreset) {
|
||||||
Vector3f Position = GetCameraOffsets() != null ? GetCameraOffsets() : new Vector3f(0,0,0);
|
if(Minecraft.getInstance().gameSettings.getPointOfView() != PointOfView.FIRST_PERSON) {
|
||||||
|
Vector3f Position = GetCameraOffsets() != null ? GetCameraOffsets() : new Vector3f(0, 0, 0);
|
||||||
this.movePosition(-this.calcCameraDistance(Position.getZ()), Position.getY(), Position.getX());
|
this.movePosition(-this.calcCameraDistance(Position.getZ()), Position.getY(), Position.getX());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@Shadow(aliases = {"move", "func_216782_a"})
|
@Shadow(aliases = {"move", "func_216782_a"})
|
||||||
|
|||||||
@@ -44,28 +44,28 @@ public class VehicleController<T extends VehicleBaseEntity> {
|
|||||||
switch(functionType){
|
switch(functionType){
|
||||||
case MoveForward:
|
case MoveForward:
|
||||||
AddInputFunction(Input,()->{ if(Vector3.inRange(Vector3.Negative(TerminalVelocity),TerminalVelocity, Parent.getMotion())){
|
AddInputFunction(Input,()->{ if(Vector3.inRange(Vector3.Negative(TerminalVelocity),TerminalVelocity, Parent.getMotion())){
|
||||||
Parent.AddVelocity(-ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
Parent.AddVelocity(-ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * -(float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case MoveBackward:
|
case MoveBackward:
|
||||||
AddInputFunction(Input,()-> {
|
AddInputFunction(Input,()-> {
|
||||||
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
||||||
Parent.AddVelocity(ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * -(float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
Parent.AddVelocity(ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case StrafeLeft:
|
case StrafeLeft:
|
||||||
AddInputFunction(Input,()-> {
|
AddInputFunction(Input,()-> {
|
||||||
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
||||||
Parent.AddVelocity(ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * -(float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
Parent.AddVelocity(ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case StrafeRight:
|
case StrafeRight:
|
||||||
AddInputFunction(Input,()-> {
|
AddInputFunction(Input,()-> {
|
||||||
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
if (Vector3.inRange(Vector3.Negative(TerminalVelocity), TerminalVelocity, Parent.getMotion())) {
|
||||||
Parent.AddVelocity(-ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * (float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
Parent.AddVelocity(-ChangeAmount * (float)Math.cos(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()),0,ChangeAmount * -(float)Math.sin(VehicleAnimationManager.DegToRad * Parent.GetVehicleYaw()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user