camera mixin now checks for vehicle inside forge tag "hvf_camera_affected_vehicle", added an enum type for physics presets, added seat positions to the build info, fixed some tag related bugs, updated mappings to be more modern
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ archivesBaseName = 'hals_vehicle_framework'
|
|||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
mappings channel: 'snapshot', version: '20210309-1.16.5'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.halbear.hvf.Entity.Renderer;
|
||||||
|
|
||||||
|
public enum PhysicsPreset {
|
||||||
|
SimpleMinecraft,
|
||||||
|
AdvancedMinecraft,
|
||||||
|
SimpleReal,
|
||||||
|
AdvancedReal
|
||||||
|
}
|
||||||
@@ -44,30 +44,39 @@ public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityMo
|
|||||||
return OriginOffset;
|
return OriginOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EventBeforeRender(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EventAfterRender(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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();
|
EventBeforeRender(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
||||||
|
|
||||||
Vector3d OriginPosition = OriginOffset;
|
matrixStack.push();
|
||||||
|
Vector3d OriginPosition = new Vector3d(0,0,0).add(OriginOffset);
|
||||||
|
Vector3f Rotations = new Vector3f(180.0F - entity.GetVehicleYaw(),entity.GetVehiclePitch(),entity.GetVehicleRoll());
|
||||||
switch(OriginType) {
|
switch(OriginType) {
|
||||||
case PilotSeat:
|
case PilotSeat:
|
||||||
OriginPosition.add(entity.GetPilotSeat().x,entity.GetPilotSeat().y,entity.GetPilotSeat().z);
|
OriginPosition = OriginPosition.add(entity.GetPilotSeat().x,entity.GetPilotSeat().y,entity.GetPilotSeat().z);
|
||||||
break;
|
break;
|
||||||
case EntityPosition:
|
case EntityPosition:
|
||||||
break;
|
break;
|
||||||
case RelativeToEntityCenter:
|
case RelativeToEntityCenter:
|
||||||
OriginPosition.add(new Vector3d(0, entity.getHeight()/2, 0));
|
OriginPosition = OriginPosition.add(new Vector3d(0, entity.getHeight()/2, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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(180.0F - entity.GetVehicleYaw()));
|
matrixStack.rotate(Vector3f.YP.rotationDegrees(Rotations.getX()));
|
||||||
matrixStack.rotate(Vector3f.XP.rotationDegrees(entity.GetVehiclePitch()));
|
matrixStack.rotate(Vector3f.XP.rotationDegrees(Rotations.getY()));
|
||||||
matrixStack.rotate(Vector3f.ZP.rotationDegrees(entity.GetVehicleRoll()));
|
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);
|
||||||
|
|
||||||
Arrays.asList(models).forEach(model->{
|
Arrays.asList(models).forEach(model->{
|
||||||
IVertexBuilder vertexBuilder = buffer.getBuffer(model.getRenderType(getEntityTexture(entity)));
|
IVertexBuilder vertexBuilder = buffer.getBuffer(model.getRenderType(getEntityTexture(entity)));
|
||||||
model.setRotationAngles(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
|
model.setRotationAngles(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||||
@@ -75,6 +84,8 @@ public class VehicleBaseRenderer<T extends VehicleBaseEntity, M extends EntityMo
|
|||||||
});
|
});
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
super.render(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
super.render(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
||||||
|
|
||||||
|
EventAfterRender(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package net.halbear.hvf.Entity;
|
package net.halbear.hvf.Entity;
|
||||||
|
|
||||||
import net.halbear.hvf.Entity.Renderer.VehicleAnimationManager;
|
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;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.MoverType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.IPacket;
|
import net.minecraft.network.IPacket;
|
||||||
@@ -15,17 +16,21 @@ import net.minecraft.network.datasync.DataSerializers;
|
|||||||
import net.minecraft.network.datasync.EntityDataManager;
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class VehicleBaseEntity extends Entity {
|
public class VehicleBaseEntity extends Entity {
|
||||||
|
|
||||||
public static final DataParameter<CompoundNBT> VEHICLE_SYNCHED_PARAMETERS = EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.COMPOUND_NBT);
|
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 static final VehicleAnimationManager<VehicleBaseEntity> ANIMATION_MANAGER = new VehicleAnimationManager<>();
|
||||||
|
private Map<String, Double> BASE_DOUBLE_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_BOOL_PARAMETERS = new HashMap<>();
|
private Map<String, Boolean> BASE_BOOL_PARAMETERS = new HashMap<>();
|
||||||
@@ -42,12 +47,20 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
|
|
||||||
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, VehicleBuildInfo vehicleBuildInfo) {
|
||||||
super(entityTypeIn, worldIn);
|
super(entityTypeIn, worldIn);
|
||||||
this.VehicleSeatOffsets = VehicleSeatOffsets;
|
this.setNoGravity(vehicleBuildInfo.GetAdheresToGravity());
|
||||||
|
List<Vector3d> VehicleSeats = new ArrayList<Vector3d>();
|
||||||
|
VehicleSeats.add(vehicleBuildInfo.GetPilotSeat());
|
||||||
|
VehicleSeats.addAll(vehicleBuildInfo.GetPassengerSeats());
|
||||||
|
this.VehicleSeatOffsets = VehicleSeats.toArray(new Vector3d[0]);
|
||||||
vehicleClassification = vehicleBuildInfo.GetVehicleClassification();
|
vehicleClassification = vehicleBuildInfo.GetVehicleClassification();
|
||||||
EngineType = vehicleBuildInfo.GetEngineType();
|
EngineType = vehicleBuildInfo.GetEngineType();
|
||||||
float PropRotation = (float)(360 * Math.random());
|
float PropRotation = (float)(360 * Math.random());
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("GRAVITY",!vehicleBuildInfo.GetAdheresToGravity() ? 0 : vehicleBuildInfo.GetGravityStrength());
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_X",vehicleBuildInfo.GetCentreOfMass().x);
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_Y",vehicleBuildInfo.GetCentreOfMass().y);
|
||||||
|
BASE_DOUBLE_PARAMETERS.put("CENTRE_OF_MASS_Z",vehicleBuildInfo.GetCentreOfMass().z);
|
||||||
BASE_FLOAT_PARAMETERS.put("ORIENTATION_YAW",0f);
|
BASE_FLOAT_PARAMETERS.put("ORIENTATION_YAW",0f);
|
||||||
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("ORIENTATION_ROLL",0f);
|
||||||
@@ -66,8 +79,8 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
break;
|
break;
|
||||||
case Zepplin:
|
case Zepplin:
|
||||||
BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount());
|
BASE_INT_PARAMETERS.put("ENGINE_COUNT",(Integer) vehicleBuildInfo.GetEngineCount());
|
||||||
BASE_FLOAT_PARAMETERS.put("GAS_CEL_CAPACITY",(float)vehicleBuildInfo.GetGasCelCapacity());
|
BASE_FLOAT_PARAMETERS.put("FLUID_COMPARTMENT_CAPACITY",(float)vehicleBuildInfo.GetGasCelCapacity());
|
||||||
BASE_FLOAT_PARAMETERS.put("GAS_CEL_COUNT",(float)vehicleBuildInfo.GetGasCelCount());
|
BASE_FLOAT_PARAMETERS.put("FLUID_COMPARTMENT_COUNT",(float)vehicleBuildInfo.GetGasCelCount());
|
||||||
break;
|
break;
|
||||||
case Ship:
|
case Ship:
|
||||||
break;
|
break;
|
||||||
@@ -75,6 +88,7 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
|
|
||||||
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
||||||
BASE_FLOAT_PARAMETERS.forEach(SyncedData::putFloat);
|
BASE_FLOAT_PARAMETERS.forEach(SyncedData::putFloat);
|
||||||
|
BASE_DOUBLE_PARAMETERS.forEach(SyncedData::putDouble);
|
||||||
BASE_INT_PARAMETERS.forEach(SyncedData::putInt);
|
BASE_INT_PARAMETERS.forEach(SyncedData::putInt);
|
||||||
BASE_STRING_PARAMETERS.forEach(SyncedData::putString);
|
BASE_STRING_PARAMETERS.forEach(SyncedData::putString);
|
||||||
BASE_BOOL_PARAMETERS.forEach(SyncedData::putBoolean);
|
BASE_BOOL_PARAMETERS.forEach(SyncedData::putBoolean);
|
||||||
@@ -97,6 +111,14 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
public String GetStringDataValue(String ValueName){
|
public String GetStringDataValue(String ValueName){
|
||||||
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getString(ValueName);
|
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getString(ValueName);
|
||||||
}
|
}
|
||||||
|
public void SetDoubleDataValue(String ValueName, Double Value){
|
||||||
|
CompoundNBT SyncedData = this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).copy();
|
||||||
|
SyncedData.putDouble(ValueName,Value);
|
||||||
|
this.dataManager.set(VEHICLE_SYNCHED_PARAMETERS,SyncedData);
|
||||||
|
}
|
||||||
|
public Double GetDoubleDataValue(String ValueName){
|
||||||
|
return this.dataManager.get(VEHICLE_SYNCHED_PARAMETERS).getDouble(ValueName);
|
||||||
|
}
|
||||||
public void SetFloatDataValue(String ValueName, Float Value){
|
public void SetFloatDataValue(String ValueName, Float Value){
|
||||||
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);
|
||||||
@@ -157,10 +179,18 @@ public class VehicleBaseEntity extends Entity {
|
|||||||
if(this.world.isRemote()){
|
if(this.world.isRemote()){
|
||||||
ClientSideTickEvent();
|
ClientSideTickEvent();
|
||||||
} else{
|
} else{
|
||||||
|
float CurrentPropRotation = GetFloatDataValue("TARGET_PROPELLER_ROTATION");
|
||||||
|
float PropIncrementAmount = GetFloatDataValue("PROPELLER_ROTATION_SPEED");
|
||||||
|
SetFloatDataValue("TARGET_PROPELLER_ROTATION",(CurrentPropRotation + PropIncrementAmount) % 36000);
|
||||||
|
SetFloatDataValue("PROPELLER_ROTATION",CurrentPropRotation);
|
||||||
ServerSideTickEvent();
|
ServerSideTickEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyForce(double dx, double dy, double dz){
|
||||||
|
this.setMotion(this.getMotion().add(dx,dy,dz));
|
||||||
|
}
|
||||||
|
|
||||||
public void ServerSideTickEvent(){
|
public void ServerSideTickEvent(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ public class Aeroplane extends VehicleBaseEntity {
|
|||||||
.SetEngineType(EngineCategories.Aircraft_Propeller)
|
.SetEngineType(EngineCategories.Aircraft_Propeller)
|
||||||
.SetMaxEngineRPM(3000)
|
.SetMaxEngineRPM(3000)
|
||||||
.SetWingSpan(2)
|
.SetWingSpan(2)
|
||||||
.SetMaxSpeedMS(70);
|
.SetMaxSpeedMS(70)
|
||||||
|
.SetCentreOfMass(new Vector3d(0,0,2))
|
||||||
|
.SetPilotSeat(new Vector3d(0.0D, -1D, 0.0D));
|
||||||
|
|
||||||
public Aeroplane(EntityType<?> Type, World WorldIn) {
|
public Aeroplane(EntityType<?> Type, World WorldIn) {
|
||||||
super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -1D, 0.0D)}, buildInfo);
|
super(Type, WorldIn, buildInfo);
|
||||||
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));
|
||||||
@@ -36,12 +38,7 @@ 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
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ public class Airboat extends VehicleBaseEntity {
|
|||||||
.SetMaxEngineRPM(3000)
|
.SetMaxEngineRPM(3000)
|
||||||
.SetMaxSpeedMS(70)
|
.SetMaxSpeedMS(70)
|
||||||
.SetGasCelCount(8)
|
.SetGasCelCount(8)
|
||||||
.SetGasCelCapacity(1000);
|
.SetGasCelCapacity(1000)
|
||||||
|
.SetPilotSeat(new Vector3d(0.0D, -2D, 0.0D))
|
||||||
|
.AddPassengerSeat(new Vector3d(0.0D, -2D, 2.0D))
|
||||||
|
.AddPassengerSeat(new Vector3d(0.0D, -2D, -2.0D));
|
||||||
|
|
||||||
public Airboat(EntityType<?> Type, World WorldIn) {
|
public Airboat(EntityType<?> Type, World WorldIn) {
|
||||||
super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -2D, 0.0D)}, buildInfo);
|
super(Type, WorldIn, 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));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.minecraft.tags.ITag;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class ModEntityTags {
|
public class ModEntityTags {
|
||||||
public static final ITag.INamedTag<EntityType<?>> CAMERA_AFFECTED_VEHICLE = EntityTypeTags.createOptional(new ResourceLocation("forge:hvf_camera_affected_vehicle"));
|
public static final ITag.INamedTag<EntityType<?>> CAMERA_AFFECTED_VEHICLE = EntityTypeTags.createOptional(new ResourceLocation("forge","hvf_camera_affected_vehicle"));
|
||||||
|
|
||||||
public static boolean doesEntityHaveCameraPreset(EntityType<?> EntityType){
|
public static boolean doesEntityHaveCameraPreset(EntityType<?> EntityType){
|
||||||
return EntityType.isContained(CAMERA_AFFECTED_VEHICLE);
|
return EntityType.isContained(CAMERA_AFFECTED_VEHICLE);
|
||||||
|
|||||||
@@ -5,25 +5,37 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
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.tags.EntityTypeTags;
|
||||||
|
import net.minecraft.tags.ITag;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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 java.util.Arrays;
|
||||||
|
|
||||||
|
import static net.halbear.hvf.Registry.ModEntityTags.doesEntityHaveCameraPreset;
|
||||||
import static net.halbear.hvf.Util.Client.VehicleCameraSettings.GetCameraOffsets;
|
import static net.halbear.hvf.Util.Client.VehicleCameraSettings.GetCameraOffsets;
|
||||||
|
|
||||||
@Mixin(ActiveRenderInfo.class)
|
@Mixin(ActiveRenderInfo.class)
|
||||||
public abstract class CameraMixin {
|
public abstract class CameraMixin {
|
||||||
@Inject(method = {"update", "func_216772_a"}, at = @At(value = "TAIL"),cancellable = true, remap = true)
|
@Inject(method = {"update", "func_216772_a"}, 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() && Minecraft.getInstance().gameSettings.getPointOfView() != PointOfView.FIRST_PERSON && entity.getRidingEntity().getType().getRegistryName().getNamespace().equals(Halsvehicleframework.MOD_ID)){
|
ITag<EntityType<?>> myEntityTag = EntityTypeTags.getTagById(new ResourceLocation("forge", "hvf_camera_affected_vehicle").toString());
|
||||||
Vector3f Position = GetCameraOffsets();
|
boolean entityHaveCameraPreset = myEntityTag.contains(entity.getRidingEntity().getType());
|
||||||
this.movePosition(-this.calcCameraDistance(Position.getZ()), Position.getY(), Position.getX());
|
if (entityHaveCameraPreset) {
|
||||||
|
Vector3f Position = GetCameraOffsets();
|
||||||
|
this.movePosition(-this.calcCameraDistance(Position.getZ()), Position.getY(), Position.getX());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@Shadow(aliases = {"move", "func_216782_a"})
|
@Shadow(aliases = {"move", "func_216782_a"})
|
||||||
protected abstract void movePosition(double p_216782_1_, double p_216782_3_, double p_216782_5_);
|
protected abstract void movePosition(double p_216782_1_, double p_216782_3_, double p_216782_5_);
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package net.halbear.hvf.Util.VehicleData;
|
package net.halbear.hvf.Util.VehicleData;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class VehicleBuildInfo {
|
public class VehicleBuildInfo {
|
||||||
private VehicleClassification vehicleClassification;
|
private VehicleClassification vehicleClassification;
|
||||||
|
private Vector3d CentreOfMassOffset = new Vector3d(0,0,0);
|
||||||
private int EngineCount;
|
private int EngineCount;
|
||||||
private EngineCategories EngineType;
|
private EngineCategories EngineType;
|
||||||
private int GasCelCount;
|
private int GasCelCount;
|
||||||
@@ -9,7 +16,19 @@ public class VehicleBuildInfo {
|
|||||||
private float MaxEngineRPM;
|
private float MaxEngineRPM;
|
||||||
private float WingSpanMeters;
|
private float WingSpanMeters;
|
||||||
private float GasCelCapacity;
|
private float GasCelCapacity;
|
||||||
|
private double Gravity = 4.9f;
|
||||||
|
private boolean AdheresToGravity = true;
|
||||||
|
private Vector3d PilotSeat;
|
||||||
|
private List<Vector3d> PassengerSeats = new ArrayList<>();
|
||||||
|
|
||||||
|
public VehicleBuildInfo AddPassengerSeat(Vector3d SeatIn){
|
||||||
|
PassengerSeats.add(SeatIn);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VehicleBuildInfo SetPilotSeat(Vector3d SeatIn){
|
||||||
|
PilotSeat = SeatIn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public VehicleBuildInfo(VehicleClassification vehicleClassification){
|
public VehicleBuildInfo(VehicleClassification vehicleClassification){
|
||||||
this.vehicleClassification = vehicleClassification;
|
this.vehicleClassification = vehicleClassification;
|
||||||
}
|
}
|
||||||
@@ -17,6 +36,14 @@ public class VehicleBuildInfo {
|
|||||||
this.EngineType = EngineType;
|
this.EngineType = EngineType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public VehicleBuildInfo SetCentreOfMass(Vector3d CentreOfMassOffset){
|
||||||
|
this.CentreOfMassOffset = CentreOfMassOffset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VehicleBuildInfo SetGravityStrength(double Gravity){
|
||||||
|
this.Gravity = Gravity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public VehicleBuildInfo SetGasCelCount(int GasCelCount){
|
public VehicleBuildInfo SetGasCelCount(int GasCelCount){
|
||||||
this.GasCelCount = GasCelCount;
|
this.GasCelCount = GasCelCount;
|
||||||
return this;
|
return this;
|
||||||
@@ -41,6 +68,10 @@ public class VehicleBuildInfo {
|
|||||||
this.GasCelCapacity = GasCelCapacity;
|
this.GasCelCapacity = GasCelCapacity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public VehicleBuildInfo AdhereToGravity(boolean AffectedByGravity){
|
||||||
|
this.AdheresToGravity = AffectedByGravity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public VehicleClassification GetVehicleClassification(){
|
public VehicleClassification GetVehicleClassification(){
|
||||||
@@ -49,14 +80,19 @@ public class VehicleBuildInfo {
|
|||||||
public int GetEngineCount(){
|
public int GetEngineCount(){
|
||||||
return EngineCount;
|
return EngineCount;
|
||||||
}
|
}
|
||||||
public EngineCategories GetEngineType(){
|
public Vector3d GetCentreOfMass(){
|
||||||
return EngineType;
|
return CentreOfMassOffset;
|
||||||
}
|
}
|
||||||
|
public EngineCategories GetEngineType(){return EngineType;}
|
||||||
public int GetGasCelCount(){
|
public int GetGasCelCount(){
|
||||||
return GasCelCount;
|
return GasCelCount;
|
||||||
}
|
}
|
||||||
|
public double GetGravityStrength(){return Gravity;}
|
||||||
|
public Vector3d GetPilotSeat(){return PilotSeat;}
|
||||||
|
public List<Vector3d> GetPassengerSeats(){return PassengerSeats;}
|
||||||
public float GetMaxSpeedMS(){return MaxSpeedMS;}
|
public float GetMaxSpeedMS(){return MaxSpeedMS;}
|
||||||
public float GetMaxEngineRPM(){return MaxEngineRPM;}
|
public float GetMaxEngineRPM(){return MaxEngineRPM;}
|
||||||
public float GetWingSpan(){return WingSpanMeters;}
|
public float GetWingSpan(){return WingSpanMeters;}
|
||||||
public float GetGasCelCapacity(){return GasCelCapacity;}
|
public float GetGasCelCapacity(){return GasCelCapacity;}
|
||||||
|
public boolean GetAdheresToGravity(){return AdheresToGravity;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"hals_vehicle_framework:aeroplane"
|
"hals_vehicle_framework:aeroplane",
|
||||||
|
"hals_vehicle_framework:airboat"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user