fixing server side syncing

This commit is contained in:
Halbear
2026-05-20 21:42:41 +01:00
parent 571a8c3327
commit f69d83df64
13 changed files with 191 additions and 146 deletions
@@ -1,6 +1,6 @@
package net.halbear.hvf.Entity.Renderer; package net.halbear.hvf.Entity.Renderer;
public enum AnimationAxis { public enum AxisType {
MINECRAFT, MINECRAFT,
EULER, EULER,
CARTESIAN CARTESIAN
@@ -1,38 +1,20 @@
package net.halbear.hvf.Entity.Renderer; package net.halbear.hvf.Entity.Renderer;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.halbear.hvf.Entity.*; import net.halbear.hvf.Entity.*;
import net.halbear.hvf.Halsvehicleframework;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.model.ModelRenderer;
import javax.annotation.Nonnull; import static net.halbear.hvf.Entity.Renderer.AnimationAxis.*;
import java.util.Arrays;
public class VehicleAnimationManager<T extends VehicleBaseEntity> { public class VehicleAnimationManager<T extends VehicleBaseEntity> {
public static float DegToRad = (float)Math.PI/180.0F; public static float DegToRad = (float)Math.PI/180.0F;
public static ModelRenderer PropellerAnimation(ModelRenderer BoneIn, T entity, AnimationAxis axis, boolean invertAnimation){ public ModelRenderer PropellerAnimation(ModelRenderer BoneIn, T entity, AnimationAxis axis, boolean invertAnimation){
float TargetPropRotation = entity.GetFloatValue("TARGET_PROPELLER_ROTATION"); float PartialTick = entity.GetPartialTick();
float CurrentPropRotation = entity.GetFloatValue("PROPELLER_ROTATION"); float TargetPropRotation = entity.GetFloatDataValue("TARGET_PROPELLER_ROTATION");
float CurrentPropRotationRadians = CurrentPropRotation * (invertAnimation ? -DegToRad : DegToRad); float CurrentPropRotation = entity.GetFloatDataValue("PROPELLER_ROTATION");
float PropIncrementAmount = entity.GetFloatValue("PROPELLER_ROTATION_SPEED"); float Addition = (TargetPropRotation - CurrentPropRotation) * PartialTick;
boolean modifiedAngle = false; float CurrentPropRotationRadians = ((CurrentPropRotation + Addition)% 36000) * (invertAnimation ? -DegToRad : DegToRad);
if(TargetPropRotation < CurrentPropRotation){
CurrentPropRotation = Math.max(CurrentPropRotation - PropIncrementAmount, TargetPropRotation) % 360;
modifiedAngle = true;
}
if(TargetPropRotation > CurrentPropRotation){
CurrentPropRotation = modifiedAngle ? TargetPropRotation : Math.min(CurrentPropRotation + PropIncrementAmount,TargetPropRotation) % 360;
}
entity.SetFloatValue("PROPELLER_ROTATION",CurrentPropRotation);
switch(axis){ switch(axis){
case X_AXIS: case X_AXIS:
BoneIn.rotateAngleX = CurrentPropRotationRadians; BoneIn.rotateAngleX = CurrentPropRotationRadians;
@@ -47,88 +29,52 @@ public class VehicleAnimationManager<T extends VehicleBaseEntity> {
return BoneIn; return BoneIn;
} }
public static Vector3f ConvertCartesianToEuler(Vector3f VectorIn){ public static Vector3f ConvertCartesianToEuler(Vector3f VectorIn){ return new Vector3f(VectorIn.getZ(),VectorIn.getY(),VectorIn.getX());}
Vector3f NewAxis = new Vector3f(VectorIn.z,VectorIn.y,VectorIn,x);
return NewAxis;
}
public static Vector3f ConvertEulerToCartesian(Vector3f VectorIn){ public static Vector3f ConvertEulerToCartesian(Vector3f VectorIn){
return ConvertCartesianToEuler(VectorIn); return ConvertCartesianToEuler(VectorIn);
} }
public static Vector3f ConvertCartesianToMinecraft(Vector3f VectorIn){ return ConvertEulerToMinecraft(VectorIn);}
public static Vector3f ConvertCartesianToMinecraft(Vector3f VectorIn){ public static Vector3f ConvertMinecraftToCartesian(Vector3f VectorIn){return ConvertMinecraftToCartesian(VectorIn); }
Vector3f NewAxis = new Vector3f(VectorIn.y,VectorIn.x,VectorIn,z); public static Vector3f ConvertMinecraftToEuler(Vector3f VectorIn){return new Vector3f(VectorIn.getZ(),VectorIn.getX(),VectorIn.getY()); }
return NewAxis; public static Vector3f ConvertEulerToMinecraft(Vector3f VectorIn){return new Vector3f(VectorIn.getY(),VectorIn.getX(),VectorIn.getZ());}
} public static AnimationAxis ConvertCartesianToMinecraft(AnimationAxis axisIn){ return ConvertMinecraftToCartesian(axisIn);}
public static Vector3f ConvertMinecraftToCartesian(Vector3f VectorIn){
return ConvertMinecraftToCartesian(VectorIn);
}
public static Vector3f ConvertMinecraftToEuler(Vector3f VectorIn){
Vector3f NewAxis = new Vector3f(VectorIn.z,VectorIn.x,VectorIn,y);
return NewAxis;
}
public static Vector3f ConvertEulerToMinecraft(Vector3f VectorIn){
Vector3f NewAxis = new Vector3f(VectorIn.y,VectorIn.x,VectorIn.z);
return NewAxis;
}
public static AnimationAxis ConvertMinecraftToCartesian(AnimationAxis axisIn){ public static AnimationAxis ConvertMinecraftToCartesian(AnimationAxis axisIn){
switch(axis){ switch(axisIn){
case X_AXIS: case X_AXIS :
return Y_AXIS; return Y_AXIS;
break; case Y_AXIS :
case Y_AXIS: return X_AXIS;
return X_AXIS case Z_AXIS :
break; return Z_AXIS;
case Z_AXIS: default :
return Z_AXIS return null;
break;
} }
} }
public static AnimationAxis ConvertEulerToCartesian(AnimationAxis axisIn){ public static AnimationAxis ConvertEulerToCartesian(AnimationAxis axisIn){
switch(axis){ switch(axisIn){
case X_AXIS: case X_AXIS :
return Z_AXIS; return Z_AXIS;
break; case Y_AXIS :
case Y_AXIS:
return Y_AXIS
break;
case Z_AXIS:
return X_AXIS
break;
}
}
public static AnimationAxis ConvertCartesianToMinecraft(AnimationAxis axisIn){
switch(axis){
case X_AXIS:
return Y_AXIS; return Y_AXIS;
break; case Z_AXIS :
case Y_AXIS: return X_AXIS;
return X_AXIS default :
break; return null;
case Z_AXIS:
return Z_AXIS
break;
} }
} }
public static AnimationAxis ConvertCartesianToEuler(AnimationAxis axisIn){ public static AnimationAxis ConvertCartesianToEuler(AnimationAxis axisIn){
switch(axis){ switch(axisIn){
case X_AXIS: case X_AXIS :
return Z_AXIS; return Z_AXIS;
break; case Y_AXIS :
case Y_AXIS: return Y_AXIS;
return Y_AXIS case Z_AXIS :
break; return X_AXIS;
case Z_AXIS: default :
return X_AXIS return null;
break;
} }
} }
} }
@@ -17,6 +17,9 @@ import java.util.Arrays;
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 M[] models; private M[] models;
private final String TextureLocation; private final String TextureLocation;
protected VehicleBaseRenderer(EntityRendererManager renderManager, M[] models, String TextureLocation) { protected VehicleBaseRenderer(EntityRendererManager renderManager, M[] models, String TextureLocation) {
@@ -29,6 +32,7 @@ public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityMo
public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) { public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
matrixStack.push(); matrixStack.push();
entity.SetPartialTick(partialTicks);
matrixStack.translate( entity.GetPilotSeat().x, -entity.GetPilotSeat().y, entity.GetPilotSeat().z); matrixStack.translate( entity.GetPilotSeat().x, -entity.GetPilotSeat().y, entity.GetPilotSeat().z);
matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F - entity.GetVehicleYaw())); matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F - entity.GetVehicleYaw()));
matrixStack.rotate(Vector3f.XP.rotationDegrees(entity.GetVehiclePitch())); matrixStack.rotate(Vector3f.XP.rotationDegrees(entity.GetVehiclePitch()));
@@ -1,5 +1,7 @@
package net.halbear.hvf.Entity; package net.halbear.hvf.Entity;
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
import net.halbear.hvf.Example.Aeroplane;
import net.halbear.hvf.Util.VehicleData.EngineCategories; import net.halbear.hvf.Util.VehicleData.EngineCategories;
import net.halbear.hvf.Util.VehicleData.VehicleBuildInfo; import net.halbear.hvf.Util.VehicleData.VehicleBuildInfo;
import net.halbear.hvf.Util.VehicleData.VehicleClassification; import net.halbear.hvf.Util.VehicleData.VehicleClassification;
@@ -22,16 +24,22 @@ import java.util.Map;
public class VehicleBaseEntity extends Entity { public class VehicleBaseEntity extends Entity {
private Map<String, DataParameter<Float>> VEHICLE_SYNCHED_FLOAT_PARAMETERS = new HashMap<>(); public static final DataParameter<CompoundNBT> VEHICLE_SYNCHED_PARAMETERS = EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.COMPOUND_NBT);
private Map<String, DataParameter<Integer>> VEHICLE_SYNCHED_INT_PARAMETERS = new HashMap<>(); private static final VehicleAnimationManager<VehicleBaseEntity> ANIMATION_MANAGER = new VehicleAnimationManager<>();
private Map<String, DataParameter<Boolean>> VEHICLE_SYNCHED_BOOLEAN_PARAMETERS = new HashMap<>();
private Map<String, Float> BASE_FLOAT_PARAMETERS = new HashMap<>(); private Map<String, Float> BASE_FLOAT_PARAMETERS = new HashMap<>();
private Map<String, Integer> BASE_INT_PARAMETERS = new HashMap<>(); private Map<String, Integer> BASE_INT_PARAMETERS = new HashMap<>();
private Map<String, Boolean> BASE_BOOLEAN_PARAMETERS = new HashMap<>(); private Map<String, Boolean> BASE_BOOL_PARAMETERS = new HashMap<>();
private Map<String, String> BASE_STRING_PARAMETERS = new HashMap<>();
private final VehicleClassification vehicleClassification; private final VehicleClassification vehicleClassification;
private final Vector3d[] VehicleSeatOffsets; private final Vector3d[] VehicleSeatOffsets;
private float PartialTick = 1.0f;
private EngineCategories EngineType; private EngineCategories EngineType;
public void SetPartialTick(float PartialTick){this.PartialTick = PartialTick;}
public float GetPartialTick(){return PartialTick;}
public VehicleAnimationManager GetAnimationManager(){return ANIMATION_MANAGER;}
public Vector3d GetPilotSeat(){return VehicleSeatOffsets.length > 0 ? VehicleSeatOffsets[0] : new Vector3d(0,0,0);} public Vector3d GetPilotSeat(){return VehicleSeatOffsets.length > 0 ? VehicleSeatOffsets[0] : new Vector3d(0,0,0);}
public VehicleBaseEntity(EntityType<?> entityTypeIn, World worldIn, Vector3d[] VehicleSeatOffsets, VehicleBuildInfo vehicleBuildInfo) { public VehicleBaseEntity(EntityType<?> entityTypeIn, World worldIn, Vector3d[] VehicleSeatOffsets, VehicleBuildInfo vehicleBuildInfo) {
@@ -39,58 +47,72 @@ public class VehicleBaseEntity extends Entity {
this.VehicleSeatOffsets = VehicleSeatOffsets; this.VehicleSeatOffsets = VehicleSeatOffsets;
vehicleClassification = vehicleBuildInfo.GetVehicleClassification(); vehicleClassification = vehicleBuildInfo.GetVehicleClassification();
EngineType = vehicleBuildInfo.GetEngineType(); EngineType = vehicleBuildInfo.GetEngineType();
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("ORIENTATION_ROLL", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("ORIENTATION_ROLL",0f);
float PropRotation = (float)(360 * Math.random()); float PropRotation = (float)(360 * Math.random());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("PROPELLER_ROTATION", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("PROPELLER_ROTATION",PropRotation);
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("TARGET_PROPELLER_ROTATION", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("TARGET_PROPELLER_ROTATION",PropRotation);
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("PROPELLER_ROTATION_SPEED", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("PROPELLER_ROTATION_SPEED",0F);
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("ORIENTATION_YAW", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("ORIENTATION_YAW",0f); BASE_FLOAT_PARAMETERS.put("ORIENTATION_YAW",0f);
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("ORIENTATION_PITCH", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("ORIENTATION_PITCH",0f); BASE_FLOAT_PARAMETERS.put("ORIENTATION_PITCH",0f);
BASE_FLOAT_PARAMETERS.put("ORIENTATION_ROLL",0f);
BASE_FLOAT_PARAMETERS.put("PROPELLER_ROTATION",PropRotation);
BASE_FLOAT_PARAMETERS.put("TARGET_PROPELLER_ROTATION",PropRotation);
BASE_FLOAT_PARAMETERS.put("PROPELLER_ROTATION_SPEED",0F);
BASE_FLOAT_PARAMETERS.put("MAX_ENGINE_RPM",(float)vehicleBuildInfo.GetMaxEngineRPM());
BASE_INT_PARAMETERS.put("THROTTLE",0);
BASE_INT_PARAMETERS.put("YAW_CONTROL_INPUT",0);
BASE_INT_PARAMETERS.put("ROLL_CONTROL_INPUT",0);
BASE_INT_PARAMETERS.put("PITCH_CONTROL_INPUT",0);
switch (vehicleClassification){ switch (vehicleClassification){
case Aeroplane: case Aeroplane:
VEHICLE_SYNCHED_INT_PARAMETERS.put("ENGINE_COUNT", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.VARINT));
BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount()); BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("MAX_ENGINE_RPM", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT)); BASE_FLOAT_PARAMETERS.put("WING_SPAN",vehicleBuildInfo.GetWingSpan());
BASE_FLOAT_PARAMETERS.put("MAX_ENGINE_RPM",(float)vehicleBuildInfo.GetMaxEngineRPM());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("WING_SPAN", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("WING_SPAN",(float)vehicleBuildInfo.GetWingSpan());
break; break;
case Zepplin: case Zepplin:
VEHICLE_SYNCHED_INT_PARAMETERS.put("ENGINE_COUNT", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.VARINT));
BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount()); BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount());
VEHICLE_SYNCHED_INT_PARAMETERS.put("GAS_CEL_COUNT", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.VARINT));
BASE_INT_PARAMETERS.put("GAS_CEL_COUNT",(Integer)vehicleBuildInfo.GetGasCelCount());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("MAX_ENGINE_RPM", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("MAX_ENGINE_RPM",(float)vehicleBuildInfo.GetMaxEngineRPM());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("GAS_CEL_CAPACITY", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("GAS_CEL_CAPACITY",(float)vehicleBuildInfo.GetGasCelCapacity()); BASE_FLOAT_PARAMETERS.put("GAS_CEL_CAPACITY",(float)vehicleBuildInfo.GetGasCelCapacity());
BASE_FLOAT_PARAMETERS.put("GAS_CEL_COUNT",(float)vehicleBuildInfo.GetGasCelCount());
break; break;
case Ship: case Ship:
break; break;
} }
VEHICLE_SYNCHED_INT_PARAMETERS.forEach((VariableName, VehicleParameters)->{
this.dataManager.register(VehicleParameters, BASE_INT_PARAMETERS.get(VariableName)); CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
}); BASE_FLOAT_PARAMETERS.forEach(SyncedData::putFloat);
VEHICLE_SYNCHED_FLOAT_PARAMETERS.forEach((VariableName, VehicleParameters)->{ BASE_INT_PARAMETERS.forEach(SyncedData::putInt);
this.dataManager.register(VehicleParameters, BASE_FLOAT_PARAMETERS.get(VariableName)); BASE_STRING_PARAMETERS.forEach(SyncedData::putString);
}); BASE_BOOL_PARAMETERS.forEach(SyncedData::putBoolean);
VEHICLE_SYNCHED_BOOLEAN_PARAMETERS.forEach((VariableName, VehicleParameters)->{ this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
this.dataManager.register(VehicleParameters, BASE_BOOLEAN_PARAMETERS.get(VariableName));
});
} }
public void SetIntDataValue(String ValueName, Integer Value){if(VEHICLE_SYNCHED_INT_PARAMETERS.containsKey(ValueName)) this.dataManager.set(VEHICLE_SYNCHED_INT_PARAMETERS.get(ValueName),Value);} public void SetIntDataValue(String ValueName, Integer Value){
public Integer GetIntDataValue(String ValueName){return this.dataManager.get(VEHICLE_SYNCHED_INT_PARAMETERS.get(ValueName)); } CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
public void SetFloatDataValue(String ValueName, Float Value){if(VEHICLE_SYNCHED_FLOAT_PARAMETERS.containsKey(ValueName)) this.dataManager.set(VEHICLE_SYNCHED_FLOAT_PARAMETERS.get(ValueName),Value);} SyncedData.putInt(ValueName,Value);
public Float GetFloatDataValue(String ValueName){ return this.dataManager.get(VEHICLE_SYNCHED_FLOAT_PARAMETERS.get(ValueName));} this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
public void SetBooleanDataValue(String ValueName, Boolean Value){ if(VEHICLE_SYNCHED_BOOLEAN_PARAMETERS.containsKey(ValueName)) this.dataManager.set(VEHICLE_SYNCHED_BOOLEAN_PARAMETERS.get(ValueName),Value); } }
public Boolean GetBooleanDataValue(String ValueName){ return this.dataManager.get(VEHICLE_SYNCHED_BOOLEAN_PARAMETERS.get(ValueName));} public Integer GetIntDataValue(String ValueName){
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getInt(ValueName);
}
public void SetStringDataValue(String ValueName, String Value){
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
SyncedData.putString(ValueName,Value);
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
}
public String GetStringDataValue(String ValueName){
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getString(ValueName);
}
public void SetFloatDataValue(String ValueName, Float Value){
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
SyncedData.putFloat(ValueName,Value);
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
}
public Float GetFloatDataValue(String ValueName){
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getFloat(ValueName);
}
public void SetBooleanDataValue(String ValueName, Boolean Value){
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
SyncedData.putBoolean(ValueName,Value);
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
}
public Boolean GetBooleanDataValue(String ValueName){
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getBoolean(ValueName);
}
public void SetVehicleRoll(float value){ public void SetVehicleRoll(float value){
SetFloatDataValue("ORIENTATION_ROLL",value); SetFloatDataValue("ORIENTATION_ROLL",value);
} }
@@ -110,7 +132,7 @@ public class VehicleBaseEntity extends Entity {
@Override @Override
protected void registerData() { protected void registerData() {
this.dataManager.register(VEHICLE_SYNCHED_PARAMETERS, new CompoundNBT());
} }
@Override @Override
@@ -1,5 +1,6 @@
package net.halbear.hvf.Example; package net.halbear.hvf.Example;
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
import net.halbear.hvf.Entity.VehicleBaseEntity; import net.halbear.hvf.Entity.VehicleBaseEntity;
import net.halbear.hvf.Util.Client.VehicleCameraPreset; import net.halbear.hvf.Util.Client.VehicleCameraPreset;
import net.halbear.hvf.Util.Client.VehicleCameraSettings; import net.halbear.hvf.Util.Client.VehicleCameraSettings;
@@ -25,6 +26,7 @@ public class Aeroplane extends VehicleBaseEntity {
VehicleCameraSettings.AddEntityCameraPreset(this.getType(), VehicleCameraSettings.AddEntityCameraPreset(this.getType(),
new VehicleCameraPreset(new Vector3f(0,0,4.5f), new VehicleCameraPreset(new Vector3f(0,0,4.5f),
new Vector3f(0,0,0),70,60)); new Vector3f(0,0,0),70,60));
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
} }
@Override @Override
@@ -34,7 +36,12 @@ public class Aeroplane extends VehicleBaseEntity {
@Override @Override
public void ServerSideTickEvent(){ public void ServerSideTickEvent(){
float CurrentPropRotation = GetFloatDataValue("TARGET_PROPELLER_ROTATION");
float PropIncrementAmount = GetFloatDataValue("PROPELLER_ROTATION_SPEED");
SetFloatDataValue("TARGET_PROPELLER_ROTATION",(CurrentPropRotation + PropIncrementAmount) % 36000);
SetFloatDataValue("ORIENTATION_ROLL",(GetFloatDataValue("ORIENTATION_ROLL") + (PropIncrementAmount < 10 ? (float)(Math.random()): -(float)(Math.random()))) % 360);
SetFloatDataValue("ORIENTATION_PITCH",(GetFloatDataValue("ORIENTATION_PITCH")+ (PropIncrementAmount < 10 ? (float)(Math.random()): -(float)(Math.random()))) % 360);
SetFloatDataValue("PROPELLER_ROTATION",CurrentPropRotation);
} }
@Override @Override
@@ -43,3 +50,4 @@ public class Aeroplane extends VehicleBaseEntity {
} }
} }
@@ -22,10 +22,11 @@ public class Airboat extends VehicleBaseEntity {
.SetGasCelCapacity(1000); .SetGasCelCapacity(1000);
public Airboat(EntityType<?> Type, World WorldIn) { public Airboat(EntityType<?> Type, World WorldIn) {
super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -1D, 0.0D)}, buildInfo); super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -2D, 0.0D)}, buildInfo);
VehicleCameraSettings.AddEntityCameraPreset(this.getType(), VehicleCameraSettings.AddEntityCameraPreset(this.getType(),
new VehicleCameraPreset(new Vector3f(0,4.0f, 16.0f), new VehicleCameraPreset(new Vector3f(0,4.0f, 16.0f),
new Vector3f(0,0,0),70,65f)); new Vector3f(0,0,0),70,65f));
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
} }
@Override @Override
@@ -35,7 +36,10 @@ public class Airboat extends VehicleBaseEntity {
@Override @Override
public void ServerSideTickEvent(){ public void ServerSideTickEvent(){
float CurrentPropRotation = GetFloatDataValue("TARGET_PROPELLER_ROTATION");
float PropIncrementAmount = GetFloatDataValue("PROPELLER_ROTATION_SPEED");
SetFloatDataValue("TARGET_PROPELLER_ROTATION",(CurrentPropRotation + PropIncrementAmount) % 36000);
SetFloatDataValue("PROPELLER_ROTATION",CurrentPropRotation);
} }
@Override @Override
@@ -2,6 +2,8 @@ package net.halbear.hvf.Example.Renderer.Models;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.halbear.hvf.Entity.Renderer.AnimationAxis;
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
import net.halbear.hvf.Example.Aeroplane; import net.halbear.hvf.Example.Aeroplane;
import net.halbear.hvf.Entity.VehicleBaseEntity; import net.halbear.hvf.Entity.VehicleBaseEntity;
import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.EntityModel;
@@ -309,8 +311,6 @@ public class AeroplaneModel extends EntityModel<VehicleBaseEntity> {
@Override @Override
public void setRotationAngles(VehicleBaseEntity entity, float f, float f1, float f2, float f3, float f4) { public void setRotationAngles(VehicleBaseEntity entity, float f, float f1, float f2, float f3, float f4) {
Aeroplane aeroplane = (Aeroplane)entity; Aeroplane aeroplane = (Aeroplane)entity;
Body.rotateAngleY = (float)Math.toRadians((aeroplane.GetVehicleYaw()) ); aeroplane.GetAnimationManager().PropellerAnimation(propeller, aeroplane, AnimationAxis.Z_AXIS, false);
Body.rotateAngleX = (float)Math.toRadians((aeroplane.GetVehiclePitch()));
Body.rotateAngleZ = (float)Math.toRadians((aeroplane.GetVehicleRoll()));
} }
} }
@@ -2,7 +2,10 @@ package net.halbear.hvf.Example.Renderer.Models;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.halbear.hvf.Entity.Renderer.AnimationAxis;
import net.halbear.hvf.Entity.VehicleBaseEntity; import net.halbear.hvf.Entity.VehicleBaseEntity;
import net.halbear.hvf.Example.Aeroplane;
import net.halbear.hvf.Example.Airboat;
import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.model.ModelRenderer;
@@ -3177,7 +3180,9 @@ public class AirboatModel extends EntityModel<VehicleBaseEntity> {
@Override @Override
public void setRotationAngles(VehicleBaseEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ public void setRotationAngles(VehicleBaseEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
//previously the render function, render code was moved to a method below Airboat airboat = (Airboat)entity;
airboat.GetAnimationManager().PropellerAnimation(Propeller, airboat, AnimationAxis.Z_AXIS, false);
airboat.GetAnimationManager().PropellerAnimation(Propeller2, airboat, AnimationAxis.Z_AXIS, true);
} }
@Override @Override
@@ -0,0 +1,12 @@
package net.halbear.hvf.Registry.Input;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.common.util.Lazy;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class ModKeybinds {
public static Lazy<KeyBinding> W_KEY_INPUT = Lazy.of(()->{
return null;
});
}
@@ -0,0 +1,30 @@
package net.halbear.hvf.Registry.PlayerVariables;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PlayerBooleanProvider implements ICapabilitySerializable<CompoundNBT> {
private final PlayerBooleanVariable VariableInstance = new PlayerBooleanVariable();
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
return null;
}
@Override
public CompoundNBT serializeNBT() {
return null;
}
@Override
public void deserializeNBT(CompoundNBT nbt) {
}
}
@@ -0,0 +1,18 @@
package net.halbear.hvf.Registry.PlayerVariables;
public class PlayerBooleanVariable {
private boolean bool = false;
public boolean GetValue(){
return bool;
}
public void SetValue(boolean Value){
bool = Value;
}
public void sync(){
}
}
+3 -7
View File
@@ -9,7 +9,7 @@ modLoader = "javafml" #mandatory
loaderVersion = "[36,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. loaderVersion = "[36,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license = "${mod_license}" license = "ARR"
# A URL to refer people to when problems occur with this mod # A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional #issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader # A list of mods - how many allowed here is determined by the individual mod loader
@@ -24,14 +24,10 @@ displayName = "Hals Vehicle Framework" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional #updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI # A URL for the "homepage" for this mod, displayed in the mod UI
displayURL = "https://halbear.net/" #optional displayURL = "https://halbear.net/" #optional
# A file name (in the root of the mod JAR) containing a logo for display logoFile="logo.png"
#logoFile="hals_vehicle_framework.png" #optional
# A text field displayed in the mod UI
#credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors = "halbear1" #optional authors = "halbear1" #optional
# The description text for the mod (multi line!) (#mandatory) # The description text for the mod (multi line!) (#mandatory)
description = '''${mod_description}''' description = '''A complex and comprehensive vehicle framework'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies."hals_vehicle_framework"]] #optional [[dependencies."hals_vehicle_framework"]] #optional
# the modid of the dependency # the modid of the dependency
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB