fixing server side syncing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package net.halbear.hvf.Entity.Renderer;
|
||||
|
||||
public enum AnimationAxis {
|
||||
public enum AxisType {
|
||||
MINECRAFT,
|
||||
EULER,
|
||||
CARTESIAN
|
||||
|
||||
@@ -1,38 +1,20 @@
|
||||
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.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.client.renderer.model.ModelRenderer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import static net.halbear.hvf.Entity.Renderer.AnimationAxis.*;
|
||||
|
||||
public class VehicleAnimationManager<T extends VehicleBaseEntity> {
|
||||
public static float DegToRad = (float)Math.PI/180.0F;
|
||||
|
||||
public static ModelRenderer PropellerAnimation(ModelRenderer BoneIn, T entity, AnimationAxis axis, boolean invertAnimation){
|
||||
float TargetPropRotation = entity.GetFloatValue("TARGET_PROPELLER_ROTATION");
|
||||
float CurrentPropRotation = entity.GetFloatValue("PROPELLER_ROTATION");
|
||||
float CurrentPropRotationRadians = CurrentPropRotation * (invertAnimation ? -DegToRad : DegToRad);
|
||||
float PropIncrementAmount = entity.GetFloatValue("PROPELLER_ROTATION_SPEED");
|
||||
boolean modifiedAngle = false;
|
||||
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);
|
||||
public ModelRenderer PropellerAnimation(ModelRenderer BoneIn, T entity, AnimationAxis axis, boolean invertAnimation){
|
||||
float PartialTick = entity.GetPartialTick();
|
||||
float TargetPropRotation = entity.GetFloatDataValue("TARGET_PROPELLER_ROTATION");
|
||||
float CurrentPropRotation = entity.GetFloatDataValue("PROPELLER_ROTATION");
|
||||
float Addition = (TargetPropRotation - CurrentPropRotation) * PartialTick;
|
||||
float CurrentPropRotationRadians = ((CurrentPropRotation + Addition)% 36000) * (invertAnimation ? -DegToRad : DegToRad);
|
||||
switch(axis){
|
||||
case X_AXIS:
|
||||
BoneIn.rotateAngleX = CurrentPropRotationRadians;
|
||||
@@ -47,88 +29,52 @@ public class VehicleAnimationManager<T extends VehicleBaseEntity> {
|
||||
return BoneIn;
|
||||
}
|
||||
|
||||
public static Vector3f ConvertCartesianToEuler(Vector3f VectorIn){
|
||||
Vector3f NewAxis = new Vector3f(VectorIn.z,VectorIn.y,VectorIn,x);
|
||||
return NewAxis;
|
||||
}
|
||||
|
||||
public static Vector3f ConvertCartesianToEuler(Vector3f VectorIn){ return new Vector3f(VectorIn.getZ(),VectorIn.getY(),VectorIn.getX());}
|
||||
public static Vector3f ConvertEulerToCartesian(Vector3f VectorIn){
|
||||
return ConvertCartesianToEuler(VectorIn);
|
||||
}
|
||||
|
||||
public static Vector3f ConvertCartesianToMinecraft(Vector3f VectorIn){
|
||||
Vector3f NewAxis = new Vector3f(VectorIn.y,VectorIn.x,VectorIn,z);
|
||||
return NewAxis;
|
||||
}
|
||||
|
||||
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 Vector3f ConvertCartesianToMinecraft(Vector3f VectorIn){ return ConvertEulerToMinecraft(VectorIn);}
|
||||
public static Vector3f ConvertMinecraftToCartesian(Vector3f VectorIn){return ConvertMinecraftToCartesian(VectorIn); }
|
||||
public static Vector3f ConvertMinecraftToEuler(Vector3f VectorIn){return new Vector3f(VectorIn.getZ(),VectorIn.getX(),VectorIn.getY()); }
|
||||
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 AnimationAxis ConvertMinecraftToCartesian(AnimationAxis axisIn){
|
||||
switch(axis){
|
||||
switch(axisIn){
|
||||
case X_AXIS :
|
||||
return Y_AXIS;
|
||||
break;
|
||||
case Y_AXIS :
|
||||
return X_AXIS
|
||||
break;
|
||||
return X_AXIS;
|
||||
case Z_AXIS :
|
||||
return Z_AXIS
|
||||
break;
|
||||
return Z_AXIS;
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static AnimationAxis ConvertEulerToCartesian(AnimationAxis axisIn){
|
||||
switch(axis){
|
||||
switch(axisIn){
|
||||
case X_AXIS :
|
||||
return Z_AXIS;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
case Y_AXIS:
|
||||
return X_AXIS
|
||||
break;
|
||||
case Z_AXIS :
|
||||
return Z_AXIS
|
||||
break;
|
||||
return X_AXIS;
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static AnimationAxis ConvertCartesianToEuler(AnimationAxis axisIn){
|
||||
switch(axis){
|
||||
switch(axisIn){
|
||||
case X_AXIS :
|
||||
return Z_AXIS;
|
||||
break;
|
||||
case Y_AXIS :
|
||||
return Y_AXIS
|
||||
break;
|
||||
return Y_AXIS;
|
||||
case Z_AXIS :
|
||||
return X_AXIS
|
||||
break;
|
||||
return X_AXIS;
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ import java.util.Arrays;
|
||||
|
||||
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 final 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) {
|
||||
matrixStack.push();
|
||||
|
||||
entity.SetPartialTick(partialTicks);
|
||||
matrixStack.translate( entity.GetPilotSeat().x, -entity.GetPilotSeat().y, entity.GetPilotSeat().z);
|
||||
matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F - entity.GetVehicleYaw()));
|
||||
matrixStack.rotate(Vector3f.XP.rotationDegrees(entity.GetVehiclePitch()));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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.VehicleBuildInfo;
|
||||
import net.halbear.hvf.Util.VehicleData.VehicleClassification;
|
||||
@@ -22,16 +24,22 @@ import java.util.Map;
|
||||
|
||||
public class VehicleBaseEntity extends Entity {
|
||||
|
||||
private Map<String, DataParameter<Float>> VEHICLE_SYNCHED_FLOAT_PARAMETERS = new HashMap<>();
|
||||
private Map<String, DataParameter<Integer>> VEHICLE_SYNCHED_INT_PARAMETERS = new HashMap<>();
|
||||
private Map<String, DataParameter<Boolean>> VEHICLE_SYNCHED_BOOLEAN_PARAMETERS = new HashMap<>();
|
||||
public static final DataParameter<CompoundNBT> VEHICLE_SYNCHED_PARAMETERS = EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.COMPOUND_NBT);
|
||||
private static final VehicleAnimationManager<VehicleBaseEntity> ANIMATION_MANAGER = new VehicleAnimationManager<>();
|
||||
private Map<String, Float> BASE_FLOAT_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 Vector3d[] VehicleSeatOffsets;
|
||||
private float PartialTick = 1.0f;
|
||||
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 VehicleBaseEntity(EntityType<?> entityTypeIn, World worldIn, Vector3d[] VehicleSeatOffsets, VehicleBuildInfo vehicleBuildInfo) {
|
||||
@@ -39,58 +47,72 @@ public class VehicleBaseEntity extends Entity {
|
||||
this.VehicleSeatOffsets = VehicleSeatOffsets;
|
||||
vehicleClassification = vehicleBuildInfo.GetVehicleClassification();
|
||||
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());
|
||||
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);
|
||||
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_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){
|
||||
case Aeroplane:
|
||||
VEHICLE_SYNCHED_INT_PARAMETERS.put("ENGINE_COUNT", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.VARINT));
|
||||
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("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());
|
||||
BASE_FLOAT_PARAMETERS.put("WING_SPAN",vehicleBuildInfo.GetWingSpan());
|
||||
break;
|
||||
case Zepplin:
|
||||
VEHICLE_SYNCHED_INT_PARAMETERS.put("ENGINE_COUNT", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.VARINT));
|
||||
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_COUNT",(float)vehicleBuildInfo.GetGasCelCount());
|
||||
break;
|
||||
case Ship:
|
||||
break;
|
||||
}
|
||||
VEHICLE_SYNCHED_INT_PARAMETERS.forEach((VariableName, VehicleParameters)->{
|
||||
this.dataManager.register(VehicleParameters, BASE_INT_PARAMETERS.get(VariableName));
|
||||
});
|
||||
VEHICLE_SYNCHED_FLOAT_PARAMETERS.forEach((VariableName, VehicleParameters)->{
|
||||
this.dataManager.register(VehicleParameters, BASE_FLOAT_PARAMETERS.get(VariableName));
|
||||
});
|
||||
VEHICLE_SYNCHED_BOOLEAN_PARAMETERS.forEach((VariableName, VehicleParameters)->{
|
||||
this.dataManager.register(VehicleParameters, BASE_BOOLEAN_PARAMETERS.get(VariableName));
|
||||
});
|
||||
|
||||
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
||||
BASE_FLOAT_PARAMETERS.forEach(SyncedData::putFloat);
|
||||
BASE_INT_PARAMETERS.forEach(SyncedData::putInt);
|
||||
BASE_STRING_PARAMETERS.forEach(SyncedData::putString);
|
||||
BASE_BOOL_PARAMETERS.forEach(SyncedData::putBoolean);
|
||||
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
|
||||
}
|
||||
|
||||
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 Integer GetIntDataValue(String ValueName){return this.dataManager.get(VEHICLE_SYNCHED_INT_PARAMETERS.get(ValueName)); }
|
||||
public void SetFloatDataValue(String ValueName, Float Value){if(VEHICLE_SYNCHED_FLOAT_PARAMETERS.containsKey(ValueName)) this.dataManager.set(VEHICLE_SYNCHED_FLOAT_PARAMETERS.get(ValueName),Value);}
|
||||
public Float GetFloatDataValue(String ValueName){ return this.dataManager.get(VEHICLE_SYNCHED_FLOAT_PARAMETERS.get(ValueName));}
|
||||
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 void SetIntDataValue(String ValueName, Integer Value){
|
||||
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
||||
SyncedData.putInt(ValueName,Value);
|
||||
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
|
||||
}
|
||||
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){
|
||||
SetFloatDataValue("ORIENTATION_ROLL",value);
|
||||
}
|
||||
@@ -110,7 +132,7 @@ public class VehicleBaseEntity extends Entity {
|
||||
|
||||
@Override
|
||||
protected void registerData() {
|
||||
|
||||
this.dataManager.register(VEHICLE_SYNCHED_PARAMETERS, new CompoundNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.halbear.hvf.Example;
|
||||
|
||||
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
|
||||
import net.halbear.hvf.Entity.VehicleBaseEntity;
|
||||
import net.halbear.hvf.Util.Client.VehicleCameraPreset;
|
||||
import net.halbear.hvf.Util.Client.VehicleCameraSettings;
|
||||
@@ -25,6 +26,7 @@ public class Aeroplane extends VehicleBaseEntity {
|
||||
VehicleCameraSettings.AddEntityCameraPreset(this.getType(),
|
||||
new VehicleCameraPreset(new Vector3f(0,0,4.5f),
|
||||
new Vector3f(0,0,0),70,60));
|
||||
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +36,12 @@ public class Aeroplane extends VehicleBaseEntity {
|
||||
|
||||
@Override
|
||||
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
|
||||
@@ -43,3 +50,4 @@ public class Aeroplane extends VehicleBaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,10 +22,11 @@ public class Airboat extends VehicleBaseEntity {
|
||||
.SetGasCelCapacity(1000);
|
||||
|
||||
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(),
|
||||
new VehicleCameraPreset(new Vector3f(0,4.0f, 16.0f),
|
||||
new Vector3f(0,0,0),70,65f));
|
||||
SetFloatDataValue("PROPELLER_ROTATION_SPEED",(float)(Math.random() * 40));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +36,10 @@ public class Airboat extends VehicleBaseEntity {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -2,6 +2,8 @@ package net.halbear.hvf.Example.Renderer.Models;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
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.Entity.VehicleBaseEntity;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
@@ -309,8 +311,6 @@ public class AeroplaneModel extends EntityModel<VehicleBaseEntity> {
|
||||
@Override
|
||||
public void setRotationAngles(VehicleBaseEntity entity, float f, float f1, float f2, float f3, float f4) {
|
||||
Aeroplane aeroplane = (Aeroplane)entity;
|
||||
Body.rotateAngleY = (float)Math.toRadians((aeroplane.GetVehicleYaw()) );
|
||||
Body.rotateAngleX = (float)Math.toRadians((aeroplane.GetVehiclePitch()));
|
||||
Body.rotateAngleZ = (float)Math.toRadians((aeroplane.GetVehicleRoll()));
|
||||
aeroplane.GetAnimationManager().PropellerAnimation(propeller, aeroplane, AnimationAxis.Z_AXIS, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.halbear.hvf.Example.Renderer.Models;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.halbear.hvf.Entity.Renderer.AnimationAxis;
|
||||
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.model.ModelRenderer;
|
||||
|
||||
@@ -3177,7 +3180,9 @@ public class AirboatModel extends EntityModel<VehicleBaseEntity> {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -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(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
# 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.
|
||||
license = "${mod_license}"
|
||||
license = "ARR"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#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
|
||||
@@ -24,14 +24,10 @@ displayName = "Hals Vehicle Framework" #mandatory
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
displayURL = "https://halbear.net/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
#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
|
||||
logoFile="logo.png"
|
||||
authors = "halbear1" #optional
|
||||
# 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.
|
||||
[[dependencies."hals_vehicle_framework"]] #optional
|
||||
# the modid of the dependency
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user