Initial Commit, has a working base class

This commit is contained in:
Halbear
2026-05-19 21:29:55 +01:00
commit 9b99becaf0
41 changed files with 1575 additions and 0 deletions
@@ -0,0 +1,40 @@
package net.halbear.hvf.Entity.Example;
import net.halbear.hvf.Entity.VehicleBaseEntity;
import net.halbear.hvf.Util.VehicleData.EngineCategories;
import net.halbear.hvf.Util.VehicleData.VehicleBuildInfo;
import net.halbear.hvf.Util.VehicleData.VehicleClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
public class Aeroplane extends VehicleBaseEntity {
private static final VehicleBuildInfo buildInfo = new VehicleBuildInfo(VehicleClassification.Aeroplane)
.SetEngineCount(1)
.SetEngineType(EngineCategories.Aircraft_Propeller)
.SetMaxEngineRPM(3000)
.SetWingSpan(2)
.SetMaxSpeedMS(70);
public Aeroplane(EntityType<?> Type, World WorldIn) {
super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -1D, 0.0D)}, buildInfo);
}
public void SetVehicleRoll(float value){
SetFloatDataValue("ORIENTATION_ROLL",value);
}
public void SetVehicleYaw(float value){SetFloatDataValue("ORIENTATION_YAW", value);}
public void SetVehiclePitch(float value){SetFloatDataValue("ORIENTATION_PITCH", value); }
public float GetVehicleRoll(){return GetFloatDataValue("ORIENTATION_ROLL"); }
public float GetVehicleYaw(){ return GetFloatDataValue("ORIENTATION_YAW"); }
public float GetVehiclePitch(){return GetFloatDataValue("ORIENTATION_PITCH"); }
public float[] GetVehicleRotations(){
return new float[]{GetVehicleYaw(),GetVehiclePitch(),GetVehicleRoll()};
}
public void SetVehicleRotations(float Yaw, float Pitch, float Roll){
SetVehicleRoll(Roll);
SetVehicleYaw(Yaw);
SetVehiclePitch(Pitch);
}
}
@@ -0,0 +1,84 @@
package net.halbear.hvf.Entity.Example.Renderer;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.halbear.hvf.Entity.Example.Renderer.Models.AeroplaneModel;
import net.halbear.hvf.Entity.VehicleBaseEntity;
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.texture.OverlayTexture;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nonnull;
@OnlyIn(Dist.CLIENT)
public class AeroplaneRenderer extends EntityRenderer<VehicleBaseEntity> {
private AeroplaneModel model = new AeroplaneModel();
public AeroplaneRenderer(EntityRendererManager renderManagerIn) {
super(renderManagerIn );
}
@Override
public void render(VehicleBaseEntity entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
matrixStack.push();
matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F - entityYaw));
matrixStack.scale(-1.0F, -1.0F, 1.0F);
matrixStack.translate(0.0D, -1.5D, 0.0D);
IVertexBuilder vertexBuilder = buffer.getBuffer(this.model.getRenderType(getEntityTexture(entity)));
this.model.setRotationAngles(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
this.model.render(matrixStack, vertexBuilder, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
super.render(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
}
@Override
@Nonnull
public ResourceLocation getEntityTexture(VehicleBaseEntity entity) {
return new ResourceLocation(Halsvehicleframework.MOD_ID,"textures/entities/biplaneupdated.png");
}
/* @Override
public boolean shouldRender(Aeroplane livingEntity, ClippingHelper camera, double camX, double camY, double camZ) {
return true;
}*/
//i can use this to render mutliple models on one entity
/*private List<EntityModel<Aeroplane>> modelParts = new ArrayList<>();
public AeroplaneRenderer(EntityRendererManager renderManagerIn) {
super(renderManagerIn );
}
@Override
public void render(Aeroplane entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
modelParts.add(new AeroplaneModel());
modelParts.add(new AeroplaneModel());
modelParts.add(new AeroplaneModel());
modelParts.add(new AeroplaneModel());
matrixStack.push();
matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F - entityYaw));
matrixStack.scale(-1.0F, -1.0F, 1.0F);
matrixStack.translate(0.0D, -1.5D, 0.0D);
for(int i = 0; i < modelParts.toArray().length; i++) {
IVertexBuilder vertexBuilder = buffer.getBuffer(this.modelParts.get(i).getRenderType(getEntityTexture(entity)));
this.modelParts.get(i).setRotationAngles(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
this.modelParts.get(i).render(matrixStack, vertexBuilder, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
matrixStack.pop();
super.render(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
}*/
}
@@ -0,0 +1,317 @@
package net.halbear.hvf.Entity.Example.Renderer.Models;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.halbear.hvf.Entity.Example.Aeroplane;
import net.halbear.hvf.Entity.VehicleBaseEntity;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.halbear.hvf.*;
public class AeroplaneModel extends EntityModel<VehicleBaseEntity> {
private final ModelRenderer Body;
private final ModelRenderer cube_r1;
private final ModelRenderer cube_r2;
private final ModelRenderer cube_r3;
private final ModelRenderer cube_r4;
private final ModelRenderer cube_r5;
private final ModelRenderer cube_r6;
private final ModelRenderer cube_r7;
private final ModelRenderer cube_r8;
private final ModelRenderer cube_r9;
private final ModelRenderer cube_r10;
private final ModelRenderer cube_r11;
private final ModelRenderer cube_r12;
private final ModelRenderer cube_r13;
private final ModelRenderer cube_r14;
private final ModelRenderer cube_r15;
private final ModelRenderer cube_r16;
private final ModelRenderer cube_r17;
private final ModelRenderer cube_r18;
private final ModelRenderer cube_r19;
private final ModelRenderer cube_r20;
private final ModelRenderer cube_r21;
private final ModelRenderer cube_r22;
private final ModelRenderer cube_r23;
private final ModelRenderer cube_r24;
private final ModelRenderer cube_r25;
private final ModelRenderer cube_r26;
private final ModelRenderer cube_r27;
private final ModelRenderer cube_r28;
private final ModelRenderer cube_r29;
private final ModelRenderer cube_r30;
private final ModelRenderer cube_r31;
private final ModelRenderer cube_r32;
private final ModelRenderer cube_r33;
private final ModelRenderer cube_r34;
private final ModelRenderer cube_r35;
private final ModelRenderer cube_r36;
private final ModelRenderer cube_r37;
private final ModelRenderer cube_r38;
private final ModelRenderer cube_r39;
private final ModelRenderer cube_r40;
private final ModelRenderer cube_r41;
private final ModelRenderer propeller;
private final ModelRenderer cube_r42;
public AeroplaneModel() {
textureWidth = 512;
textureHeight = 512;
Body = new ModelRenderer(this);
Body.setRotationPoint(0.0F, 3.0F, -9.0F);
Body.setTextureOffset(144, 0).addBox(-5.0F, 7.25F, -12.0F, 10.0F, 2.0F, 32.0F, 0.0F, false);
Body.setTextureOffset(96, 43).addBox(-2.0F, -6.0F, 34.0F, 4.0F, 2.0F, 10.0F, 0.0F, false);
Body.setTextureOffset(0, 92).addBox(-2.0F, -6.0F, 50.0F, 4.0F, 10.0F, 6.0F, 0.0F, false);
Body.setTextureOffset(0, 92).addBox(-26.0F, -18.0F, -7.0F, 52.0F, 2.0F, 24.0F, 0.0F, false);
Body.setTextureOffset(0, 92).addBox(-26.0F, 5.0F, -2.0F, 52.0F, 2.0F, 24.0F, 0.0F, false);
Body.setTextureOffset(292, 89).addBox(11.0F, 13.0F, -4.0F, 2.0F, 8.0F, 8.0F, 0.0F, false);
Body.setTextureOffset(9, 207).addBox(9.0F, 16.0F, -1.0F, 2.0F, 2.0F, 2.0F, 0.0F, false);
Body.setTextureOffset(292, 89).addBox(-13.0F, 13.0F, -4.0F, 2.0F, 8.0F, 8.0F, 0.0F, true);
Body.setTextureOffset(9, 207).addBox(-11.0F, 16.0F, -1.0F, 2.0F, 2.0F, 2.0F, 0.0F, true);
cube_r1 = new ModelRenderer(this);
cube_r1.setRotationPoint(-9.0F, 18.0F, 0.0F);
Body.addChild(cube_r1);
setRotationAngle(cube_r1, 0.0F, 0.0F, 0.4363F);
cube_r1.setTextureOffset(10, 205).addBox(-2.0F, -12.0F, -1.0F, 2.0F, 12.0F, 2.0F, 0.0F, true);
cube_r2 = new ModelRenderer(this);
cube_r2.setRotationPoint(9.0F, 18.0F, 0.0F);
Body.addChild(cube_r2);
setRotationAngle(cube_r2, 0.0F, 0.0F, -0.4363F);
cube_r2.setTextureOffset(10, 205).addBox(0.0F, -12.0F, -1.0F, 2.0F, 12.0F, 2.0F, 0.0F, false);
cube_r3 = new ModelRenderer(this);
cube_r3.setRotationPoint(-42.0F, 4.0F, 7.0F);
Body.addChild(cube_r3);
setRotationAngle(cube_r3, 0.1745F, 0.1745F, 0.0F);
cube_r3.setTextureOffset(52, 21).addBox(-1.0F, -22.0F, -6.0F, 2.0F, 23.0F, 2.0F, 0.0F, false);
cube_r4 = new ModelRenderer(this);
cube_r4.setRotationPoint(-39.0F, 4.0F, 26.0F);
Body.addChild(cube_r4);
setRotationAngle(cube_r4, 0.1745F, 0.1745F, 0.0F);
cube_r4.setTextureOffset(100, 203).addBox(-1.0F, -22.0F, -6.0F, 2.0F, 23.0F, 2.0F, 0.0F, false);
cube_r5 = new ModelRenderer(this);
cube_r5.setRotationPoint(39.0F, 4.0F, 26.0F);
Body.addChild(cube_r5);
setRotationAngle(cube_r5, 0.1745F, -0.1745F, 0.0F);
cube_r5.setTextureOffset(186, 177).addBox(-1.0F, -22.0F, -6.0F, 2.0F, 23.0F, 2.0F, 0.0F, false);
cube_r6 = new ModelRenderer(this);
cube_r6.setRotationPoint(-11.0F, 4.5F, 21.0F);
Body.addChild(cube_r6);
setRotationAngle(cube_r6, 0.2659F, 0.008F, -0.0169F);
cube_r6.setTextureOffset(162, 177).addBox(-1.0F, -22.5F, -2.0F, 2.0F, 24.0F, 2.0F, 0.0F, false);
cube_r7 = new ModelRenderer(this);
cube_r7.setRotationPoint(11.0F, 4.5F, 21.0F);
Body.addChild(cube_r7);
setRotationAngle(cube_r7, 0.2659F, -0.008F, 0.0169F);
cube_r7.setTextureOffset(170, 177).addBox(-1.0F, -22.5F, -2.0F, 2.0F, 24.0F, 2.0F, 0.0F, false);
cube_r8 = new ModelRenderer(this);
cube_r8.setRotationPoint(-11.1935F, -5.629F, -1.7596F);
Body.addChild(cube_r8);
setRotationAngle(cube_r8, 0.2223F, 0.008F, -0.0169F);
cube_r8.setTextureOffset(52, 21).addBox(-1.0F, -12.0F, -2.0F, 2.0F, 24.0F, 2.0F, 0.0F, false);
cube_r9 = new ModelRenderer(this);
cube_r9.setRotationPoint(11.1935F, -5.629F, -1.7596F);
Body.addChild(cube_r9);
setRotationAngle(cube_r9, 0.2223F, -0.008F, 0.0169F);
cube_r9.setTextureOffset(178, 177).addBox(-1.0F, -12.0F, -2.0F, 2.0F, 24.0F, 2.0F, 0.0F, false);
cube_r10 = new ModelRenderer(this);
cube_r10.setRotationPoint(42.0F, 4.0F, 7.0F);
Body.addChild(cube_r10);
setRotationAngle(cube_r10, 0.1745F, -0.1745F, 0.0F);
cube_r10.setTextureOffset(206, 177).addBox(-1.0F, -22.0F, -6.0F, 2.0F, 23.0F, 2.0F, 0.0F, false);
cube_r11 = new ModelRenderer(this);
cube_r11.setRotationPoint(-26.0F, -18.0F, -7.0F);
Body.addChild(cube_r11);
setRotationAngle(cube_r11, 0.0F, 0.1309F, 0.0F);
cube_r11.setTextureOffset(0, 118).addBox(-29.0F, -0.01F, 0.0F, 29.0F, 2.0F, 24.0F, 0.0F, false);
cube_r12 = new ModelRenderer(this);
cube_r12.setRotationPoint(26.0F, -18.0F, -7.0F);
Body.addChild(cube_r12);
setRotationAngle(cube_r12, 0.0F, -0.1309F, 0.0F);
cube_r12.setTextureOffset(0, 118).addBox(0.0F, -0.01F, 0.0F, 29.0F, 2.0F, 24.0F, 0.0F, true);
cube_r13 = new ModelRenderer(this);
cube_r13.setRotationPoint(-26.0F, 5.0F, -2.0F);
Body.addChild(cube_r13);
setRotationAngle(cube_r13, 0.0F, 0.1309F, 0.0F);
cube_r13.setTextureOffset(64, 177).addBox(-19.0F, -0.01F, 0.0F, 19.0F, 2.0F, 24.0F, 0.0F, false);
cube_r14 = new ModelRenderer(this);
cube_r14.setRotationPoint(26.0F, 5.0F, -2.0F);
Body.addChild(cube_r14);
setRotationAngle(cube_r14, 0.0F, -0.1309F, 0.0F);
cube_r14.setTextureOffset(64, 177).addBox(0.0F, -0.01F, 0.0F, 19.0F, 2.0F, 24.0F, 0.0F, true);
cube_r15 = new ModelRenderer(this);
cube_r15.setRotationPoint(-26.8737F, -5.0F, 6.9632F);
Body.addChild(cube_r15);
setRotationAngle(cube_r15, 0.1686F, 0.6551F, -0.0096F);
cube_r15.setTextureOffset(190, 90).addBox(-19.5F, -12.0F, 1.0F, 39.0F, 24.0F, 0.0F, 0.0F, true);
cube_r16 = new ModelRenderer(this);
cube_r16.setRotationPoint(-26.5867F, -6.1884F, 8.6681F);
Body.addChild(cube_r16);
setRotationAngle(cube_r16, 0.2164F, -0.4589F, -0.102F);
cube_r16.setTextureOffset(190, 90).addBox(-20.5F, -11.0F, 0.0F, 39.0F, 23.0F, 0.0F, 0.0F, true);
cube_r17 = new ModelRenderer(this);
cube_r17.setRotationPoint(26.5867F, -6.1884F, 8.6681F);
Body.addChild(cube_r17);
setRotationAngle(cube_r17, 0.2164F, 0.4589F, 0.102F);
cube_r17.setTextureOffset(190, 90).addBox(-18.5F, -11.0F, 0.0F, 39.0F, 23.0F, 0.0F, 0.0F, false);
cube_r18 = new ModelRenderer(this);
cube_r18.setRotationPoint(26.8737F, -5.0F, 6.9632F);
Body.addChild(cube_r18);
setRotationAngle(cube_r18, 0.1686F, -0.6551F, 0.0096F);
cube_r18.setTextureOffset(190, 90).addBox(-19.5F, -12.0F, 1.0F, 39.0F, 24.0F, 0.0F, 0.0F, false);
cube_r19 = new ModelRenderer(this);
cube_r19.setRotationPoint(0.0F, -1.5F, 0.0F);
Body.addChild(cube_r19);
setRotationAngle(cube_r19, -0.3491F, 0.0F, 0.0F);
cube_r19.setTextureOffset(0, 0).addBox(-0.5F, -2.5F, 1.0F, 1.0F, 9.0F, 1.0F, 0.0F, false);
cube_r20 = new ModelRenderer(this);
cube_r20.setRotationPoint(10.0F, -3.0F, 52.0F);
Body.addChild(cube_r20);
setRotationAngle(cube_r20, -0.3054F, 0.0F, 1.5708F);
cube_r20.setTextureOffset(144, 0).addBox(-1.0F, -9.0F, -6.0F, 2.0F, 18.0F, 12.0F, 0.0F, true);
cube_r21 = new ModelRenderer(this);
cube_r21.setRotationPoint(-10.0F, -3.0F, 52.0F);
Body.addChild(cube_r21);
setRotationAngle(cube_r21, -0.3054F, 0.0F, -1.5708F);
cube_r21.setTextureOffset(144, 0).addBox(-1.0F, -9.0F, -6.0F, 2.0F, 18.0F, 12.0F, 0.0F, false);
cube_r22 = new ModelRenderer(this);
cube_r22.setRotationPoint(0.0F, -15.0F, 50.0F);
Body.addChild(cube_r22);
setRotationAngle(cube_r22, -0.3054F, 0.0F, 0.0F);
cube_r22.setTextureOffset(54, 144).addBox(-1.0F, -6.0F, -4.0F, 2.0F, 18.0F, 12.0F, 0.0F, false);
cube_r23 = new ModelRenderer(this);
cube_r23.setRotationPoint(2.0F, 9.25F, 34.0F);
Body.addChild(cube_r23);
setRotationAngle(cube_r23, 0.2528F, -0.1733F, 0.5888F);
cube_r23.setTextureOffset(135, 133).addBox(-0.25F, -6.3007F, -0.9537F, 0.0F, 6.0F, 17.0F, 0.0F, true);
cube_r24 = new ModelRenderer(this);
cube_r24.setRotationPoint(-2.0F, 9.25F, 34.0F);
Body.addChild(cube_r24);
setRotationAngle(cube_r24, 0.2528F, 0.1733F, -0.5888F);
cube_r24.setTextureOffset(135, 133).addBox(0.25F, -6.3007F, -0.9537F, 0.0F, 6.0F, 17.0F, 0.0F, false);
cube_r25 = new ModelRenderer(this);
cube_r25.setRotationPoint(0.0F, 9.25F, 33.0F);
Body.addChild(cube_r25);
setRotationAngle(cube_r25, 0.2618F, 0.0F, 0.0F);
cube_r25.setTextureOffset(106, 144).addBox(-2.0F, -6.0F, 0.0F, 4.0F, 6.0F, 21.0F, 0.0F, false);
cube_r26 = new ModelRenderer(this);
cube_r26.setRotationPoint(-5.0F, 9.0F, 20.0F);
Body.addChild(cube_r26);
setRotationAngle(cube_r26, 0.0F, 0.1745F, 0.0F);
cube_r26.setTextureOffset(38, 201).addBox(0.0F, -1.75F, 0.0F, 5.0F, 2.0F, 14.0F, 0.0F, true);
cube_r27 = new ModelRenderer(this);
cube_r27.setRotationPoint(5.0F, 9.0F, 20.0F);
Body.addChild(cube_r27);
setRotationAngle(cube_r27, 0.0F, -0.1745F, 0.0F);
cube_r27.setTextureOffset(38, 201).addBox(-5.0F, -1.75F, 0.0F, 5.0F, 2.0F, 14.0F, 0.0F, false);
cube_r28 = new ModelRenderer(this);
cube_r28.setRotationPoint(-7.0F, -11.0F, 20.0F);
Body.addChild(cube_r28);
setRotationAngle(cube_r28, 0.3925F, -1.2393F, 1.1581F);
cube_r28.setTextureOffset(196, 64).addBox(0.0F, -7.0F, -5.0F, 18.0F, 7.0F, 5.0F, 0.0F, true);
cube_r29 = new ModelRenderer(this);
cube_r29.setRotationPoint(7.0F, -11.0F, 20.0F);
Body.addChild(cube_r29);
setRotationAngle(cube_r29, 0.3925F, 1.2393F, -1.1581F);
cube_r29.setTextureOffset(196, 64).addBox(-18.0F, -7.0F, -5.0F, 18.0F, 7.0F, 5.0F, 0.0F, false);
cube_r30 = new ModelRenderer(this);
cube_r30.setRotationPoint(0.0F, -6.0F, 9.0F);
Body.addChild(cube_r30);
setRotationAngle(cube_r30, 0.0F, 0.0F, -1.5708F);
cube_r30.setTextureOffset(42, 182).addBox(-10.0F, -7.0F, 6.0F, 15.0F, 14.0F, 5.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 239).addBox(-15.0F, -7.0F, -28.0F, 15.0F, 14.0F, 0.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 223).addBox(-15.0F, -7.0F, -27.0F, 15.0F, 14.0F, 0.0F, 0.0F, false);
cube_r30.setTextureOffset(96, 55).addBox(-9.0F, -2.0F, -28.0F, 4.0F, 4.0F, 7.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 201).addBox(-14.0F, -7.0F, -26.0F, 14.0F, 14.0F, 5.0F, 0.0F, false);
cube_r30.setTextureOffset(144, 34).addBox(-16.0F, -9.0F, -28.0F, 18.0F, 2.0F, 7.0F, 0.0F, false);
cube_r30.setTextureOffset(42, 0).addBox(0.0F, -7.0F, -28.0F, 2.0F, 14.0F, 7.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 0).addBox(-10.0F, -7.0F, -18.0F, 0.0F, 14.0F, 25.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 0).addBox(1.0F, 0.0F, -26.0F, 15.0F, 0.0F, 66.0F, 0.0F, false);
cube_r30.setTextureOffset(0, 0).addBox(-10.0F, -7.0F, -21.0F, 11.0F, 14.0F, 10.0F, 0.0F, false);
cube_r30.setTextureOffset(54, 144).addBox(-10.0F, -8.0F, -21.0F, 10.0F, 1.0F, 32.0F, 0.0F, false);
cube_r31 = new ModelRenderer(this);
cube_r31.setRotationPoint(0.0F, -6.0F, 9.0F);
Body.addChild(cube_r31);
setRotationAngle(cube_r31, 0.0F, 0.0F, 1.5708F);
cube_r31.setTextureOffset(144, 34).addBox(-2.0F, -9.0F, -28.0F, 18.0F, 2.0F, 7.0F, 0.0F, true);
cube_r31.setTextureOffset(54, 144).addBox(0.0F, -8.0F, -21.0F, 10.0F, 1.0F, 32.0F, 0.0F, true);
cube_r32 = new ModelRenderer(this);
cube_r32.setRotationPoint(0.0F, 36.0F, 9.0F);
Body.addChild(cube_r32);
setRotationAngle(cube_r32, 0.0F, 0.0F, 1.5708F);
cube_r32.setTextureOffset(42, 0).addBox(-28.0F, -7.0F, -28.0F, 2.0F, 14.0F, 7.0F, 0.0F, false);
cube_r33 = new ModelRenderer(this);
cube_r33.setRotationPoint(0.0F, -7.0F, -5.0F);
Body.addChild(cube_r33);
setRotationAngle(cube_r33, 0.0F, -0.4363F, -1.5708F);
cube_r33.setTextureOffset(0, 118).addBox(0.0F, -7.0F, 0.0F, 7.0F, 14.0F, 1.0F, 0.0F, false);
cube_r34 = new ModelRenderer(this);
cube_r34.setRotationPoint(51.0F, -18.5F, 20.0F);
Body.addChild(cube_r34);
setRotationAngle(cube_r34, 0.7342F, -0.1119F, -1.4365F);
cube_r34.setTextureOffset(53, 0).addBox(-24.5F, 0.0F, 0.0F, 24.0F, 0.0F, 43.0F, 0.0F, false);
cube_r35 = new ModelRenderer(this);
cube_r35.setRotationPoint(-51.0F, -18.5F, 20.0F);
Body.addChild(cube_r35);
setRotationAngle(cube_r35, 0.7342F, 0.1119F, 1.4365F);
cube_r35.setTextureOffset(53, 0).addBox(0.5F, 0.0F, 0.0F, 24.0F, 0.0F, 43.0F, 0.0F, true);
cube_r36 = new ModelRenderer(this);
cube_r36.setRotationPoint(8.0F, 4.0F, 5.5F);
Body.addChild(cube_r36);
setRotationAngle(cube_r36, 0.0F, 0.0F, 2.0944F);
cube_r36.setTextureOffset(162, 178).addBox(0.0F, 0.0F, -17.5F, 6.0F, 1.0F, 32.0F, 0.0F, true);
cube_r37 = new ModelRenderer(this);
cube_r37.setRotationPoint(-8.0F, 4.0F, 5.5F);
Body.addChild(cube_r37);
setRotationAngle(cube_r37, 0.0F, 0.0F, -2.0944F);
cube_r37.setTextureOffset(162, 178).addBox(-6.0F, 0.0F, -17.5F, 6.0F, 1.0F, 32.0F, 0.0F, false);
cube_r38 = new ModelRenderer(this);
cube_r38.setRotationPoint(5.0F, 9.0F, 20.0F);
Body.addChild(cube_r38);
setRotationAngle(cube_r38, 0.1515F, -0.0869F, -1.0538F);
cube_r38.setTextureOffset(0, 182).addBox(-0.1927F, -3.9414F, -0.5209F, 6.0F, 4.0F, 15.0F, 0.0F, false);
cube_r39 = new ModelRenderer(this);
cube_r39.setRotationPoint(-5.0F, 9.0F, 20.0F);
Body.addChild(cube_r39);
setRotationAngle(cube_r39, 0.1515F, 0.0869F, 1.0538F);
cube_r39.setTextureOffset(82, 118).addBox(-5.8073F, -4.9414F, -0.5209F, 6.0F, 5.0F, 15.0F, 0.0F, false);
cube_r40 = new ModelRenderer(this);
cube_r40.setRotationPoint(-8.0F, 0.5F, 20.0F);
Body.addChild(cube_r40);
setRotationAngle(cube_r40, 0.1745F, 0.0F, 1.5708F);
cube_r40.setTextureOffset(0, 144).addBox(-6.5F, -4.0F, 0.0F, 10.0F, 4.0F, 34.0F, 0.0F, true);
cube_r41 = new ModelRenderer(this);
cube_r41.setRotationPoint(8.0F, 0.5F, 20.0F);
Body.addChild(cube_r41);
setRotationAngle(cube_r41, 0.1745F, 0.0F, -1.5708F);
cube_r41.setTextureOffset(0, 144).addBox(-3.5F, -4.0F, 0.0F, 10.0F, 4.0F, 34.0F, 0.0F, false);
propeller = new ModelRenderer(this);
propeller.setRotationPoint(0.0F, 1.0F, -20.5F);
Body.addChild(propeller);
cube_r42 = new ModelRenderer(this);
cube_r42.setRotationPoint(0.0F, -7.0F, 29.5F);
propeller.addChild(cube_r42);
setRotationAngle(cube_r42, 0.0F, 0.0F, -1.5708F);
cube_r42.setTextureOffset(32, 0).addBox(-9.0F, -2.0F, -32.0F, 4.0F, 4.0F, 3.0F, 0.0F, false);
cube_r42.setTextureOffset(0, 260).addBox(-22.0F, -15.0F, -29.0F, 30.0F, 30.0F, 0.0F, 0.0F, false);
cube_r42.setTextureOffset(4, 0).addBox(-8.0F, -1.0F, -29.0F, 2.0F, 2.0F, 1.0F, 0.0F, false);
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
float alpha) {
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
@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()));
}
}
@@ -0,0 +1,167 @@
package net.halbear.hvf.Entity;
import net.halbear.hvf.Util.VehicleData.EngineCategories;
import net.halbear.hvf.Util.VehicleData.VehicleBuildInfo;
import net.halbear.hvf.Util.VehicleData.VehicleClassification;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import java.util.HashMap;
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<>();
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 VehicleClassification vehicleClassification;
private Vector3d[] VehicleSeatOffsets;
private EngineCategories EngineType;
public VehicleBaseEntity(EntityType<?> entityTypeIn, World worldIn, Vector3d[] VehicleSeatOffsets, VehicleBuildInfo vehicleBuildInfo) {
super(entityTypeIn, worldIn);
this.VehicleSeatOffsets = VehicleSeatOffsets;
vehicleClassification = vehicleBuildInfo.GetVehicleClassification();
EngineType = vehicleBuildInfo.GetEngineType();
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());
VEHICLE_SYNCHED_FLOAT_PARAMETERS.put("ORIENTATION_ROLL", EntityDataManager.createKey(VehicleBaseEntity.class, DataSerializers.FLOAT));
BASE_FLOAT_PARAMETERS.put("ORIENTATION_ROLL",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);
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());
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));
});
}
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));
}
@Override
protected void registerData() {
}
@Override
protected void readAdditional(CompoundNBT compound) {
}
@Override
protected void writeAdditional(CompoundNBT compound) {
}
@Override
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
public void tick() {
super.tick();
}
@Override
public boolean canBeCollidedWith(){return true;}
@Override
protected boolean canFitPassenger(Entity passenger) {
return this.getPassengers().size() < VehicleSeatOffsets.length;
}
@Override
public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) {
if (this.getPassengers().size() < VehicleSeatOffsets.length && !player.isPassenger()) {
if (!this.world.isRemote()) {
return player.startRiding(this) ? ActionResultType.CONSUME : ActionResultType.PASS;
}
return ActionResultType.func_233537_a_(this.world.isRemote());
}
return ActionResultType.SUCCESS;
}
@Override
public Entity getControllingPassenger() {
return this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
}
@Override
public void updatePassenger(Entity passenger) {
if (this.isPassenger(passenger)) {
int seatIndex = this.getPassengers().indexOf(passenger);
if (seatIndex >= 0 && seatIndex < VehicleSeatOffsets.length) {
Vector3d localOffset = VehicleSeatOffsets[seatIndex];
Vector3d rotatedOffset = localOffset.rotateYaw((float) Math.toRadians(-this.rotationYaw));
passenger.setPosition(
this.getPosX() + rotatedOffset.x,
this.getPosY() + rotatedOffset.y + passenger.getMountedYOffset(),
this.getPosZ() + rotatedOffset.z
);
} else {
super.updatePassenger(passenger);
}
}
}
}
@@ -0,0 +1,84 @@
package net.halbear.hvf;
import net.halbear.hvf.Registry.ModEntities;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.stream.Collectors;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("hals_vehicle_framework")
public class Halsvehicleframework {
public static final String MOD_ID = "hals_vehicle_framework";
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
public Halsvehicleframework() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
//register the mod elements on the mod event bus (loads them)
ModEntities.ENTITY_TYPES.register(bus);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event) {
// some preinit code
LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}
private void doClientStuff(final FMLClientSetupEvent event) {
// do something that can only be done on the client
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
}
private void enqueueIMC(final InterModEnqueueEvent event) {
// some example code to dispatch IMC to another mod
InterModComms.sendTo("hals_vehicle_framework", "helloworld", () -> {
LOGGER.info("Hello world from the MDK");
return "Hello world";
});
}
private void processIMC(final InterModProcessEvent event) {
// some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().map(m -> m.getMessageSupplier().get()).collect(Collectors.toList()));
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
// do something when the server starts
LOGGER.info("HELLO from server starting");
}
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
@SubscribeEvent
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
// register a new block here
LOGGER.info("HELLO from Register Block");
}
}
}
@@ -0,0 +1,28 @@
package net.halbear.hvf.Registry.EventHandlers;
import net.halbear.hvf.Entity.Example.Renderer.AeroplaneRenderer;
import net.halbear.hvf.Halsvehicleframework;
import net.halbear.hvf.Registry.ModEntities;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@Mod.EventBusSubscriber(modid = Halsvehicleframework.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventHandler {
@SafeVarargs
public static void SetCollectionRenderType(RenderType type, RegistryObject<Block>... blocks_list) { //hal
for (RegistryObject<Block> blockRegistryObject : blocks_list) {
RenderTypeLookup.setRenderLayer(blockRegistryObject.get(), type);
}
}
@SubscribeEvent
public static void init(final FMLClientSetupEvent event) {
RenderingRegistry.registerEntityRenderingHandler(ModEntities.AEROPLANE.get(), AeroplaneRenderer::new);
}
}
@@ -0,0 +1,23 @@
package net.halbear.hvf.Registry;
import net.halbear.hvf.Entity.Example.Aeroplane;
import net.halbear.hvf.Halsvehicleframework;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
//@Mod.EventBusSubscriber(modid = "hem", bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEntities {
public static DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, Halsvehicleframework.MOD_ID);
public static final RegistryObject<EntityType<Aeroplane>> AEROPLANE =
ENTITY_TYPES.register("aeroplane", ()-> EntityType.Builder.create(Aeroplane::new,
EntityClassification.MISC ).size(3f,8f).build(new ResourceLocation(Halsvehicleframework.MOD_ID, "aeroplane").toString()));
}
@@ -0,0 +1,14 @@
package net.halbear.hvf.Registry;
import net.minecraft.entity.EntityType;
import net.minecraft.tags.EntityTypeTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
public class ModEntityTags {
public static final ITag.INamedTag<EntityType<?>> CAMERA_AFFECTED_VEHICLE = EntityTypeTags.createOptional(new ResourceLocation("forge:hvf_camera_affected_vehicle"));
public static boolean doesEntityHaveCameraPreset(EntityType<?> EntityType){
return EntityType.isContained(CAMERA_AFFECTED_VEHICLE);
}
}
@@ -0,0 +1,44 @@
package net.halbear.hvf.Util.Client;
import net.minecraft.entity.EntityType;
import net.minecraft.util.math.vector.Vector3f;
public class VehicleCameraPreset {
private Vector3f CamOffset = new Vector3f(0.0f, 0.0f, 0.0f);
private Vector3f CamTransformations = new Vector3f(0.0f, 0.0f, 0.0f);
public Vector3f OriginalCamOffset = new Vector3f(0.0f, 0.0f, 0.0f);
public Vector3f OriginalCamTransformations = new Vector3f(0.0f, 0.0f, 0.0f);
private float CamFOV = 70.0f;
private float CamFOVExternal = 70.0f;
public VehicleCameraPreset(Vector3f CamOffset, Vector3f CamTransformations, float FOV, float FOV3rdPerson){
OriginalCamOffset = CamOffset;
OriginalCamTransformations = CamTransformations;
this.CamOffset = CamOffset;
this.CamTransformations = CamTransformations;
this.CamFOV = FOV;
this.CamFOVExternal = FOV3rdPerson;
}
public VehicleCameraPreset Clone(){
return new VehicleCameraPreset(this.CamOffset, this.CamTransformations, this.CamFOV, this.CamFOVExternal);
}
public Vector3f GetCameraOffsets(){
return CamOffset;
}
public Vector3f GetCameraTransformations(){
return CamTransformations;
}
public float GetCameraFOV(){
return CamFOV;
}
public float Get3rdPersonCameraFOV(){
return CamFOVExternal;
}
public void SetCameraOffsets(Vector3f newCamOffset){CamOffset = newCamOffset;}
public void SetCameraTransformations(Vector3f newCamTransformation){ CamTransformations = newCamTransformation; }
public void SetCameraFOV(float NewFOV){ CamFOV = NewFOV;}
public void Set3rdPersonCameraFOV(float NewExternalFOV){CamFOVExternal = NewExternalFOV;}
}
@@ -0,0 +1,87 @@
package net.halbear.hvf.Util.Client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.PointOfView;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.util.HashMap;
import java.util.Map;
@Mod.EventBusSubscriber
public class VehicleCameraSettings {
private static VehicleCameraPreset CurrentPreset = new VehicleCameraPreset(new Vector3f(0,0,0),new Vector3f(0,0,0),70,70);
private static EntityType<?> CurrentEntity;
private static boolean HvfVehicle = false;
public static Vector3f GetCameraOffsets(){
return CurrentPreset.GetCameraOffsets();
}
public static Map<EntityType<?>, VehicleCameraPreset> CameraPresets = new HashMap<>();
public static void AddEntityCameraPreset(EntityType<?> entityType, VehicleCameraPreset vehicleCameraPreset){
CameraPresets.put(entityType, vehicleCameraPreset);
}
@SubscribeEvent
public static void PlayerTickEvent(TickEvent.PlayerTickEvent event) {
if(!event.player.world.isRemote()) return;
if (event.phase != TickEvent.Phase.END) {
return;
}
if (event.player != null && event.player.isPassenger() && event.player.getRidingEntity() != null
&& CurrentEntity != event.player.getRidingEntity().getType()) {
Entity Current = event.player.getRidingEntity();
CurrentEntity = Current.getType();
HvfVehicle = CameraPresets.containsKey(CurrentEntity);
if (HvfVehicle) {
CurrentPreset = CameraPresets.get(CurrentEntity).Clone();
}
}
if(CurrentPreset == null) return;
if ((!event.player.isPassenger() || !HvfVehicle)
&& (CurrentPreset.Get3rdPersonCameraFOV() != (float) Minecraft.getInstance().gameSettings.fov
|| CurrentPreset.GetCameraFOV() != (float) Minecraft.getInstance().gameSettings.fov || CurrentPreset.GetCameraOffsets().getX() != 0 || CurrentPreset.GetCameraOffsets().getY() != 0
|| CurrentPreset.GetCameraOffsets().getZ() != 0 || CurrentPreset.GetCameraTransformations().getX() != 0 || CurrentPreset.GetCameraTransformations().getY() != 0
|| CurrentPreset.GetCameraTransformations().getZ() != 0)) {
CurrentPreset.SetCameraOffsets(new Vector3f(0.0f, 0.0f, 0.0f));// reset if the players not riding an entity and if any the values aren't 0
CurrentPreset.SetCameraTransformations(new Vector3f(0.0f, 0.0f, 0.0f));
CurrentPreset.SetCameraFOV((float) Minecraft.getInstance().gameSettings.fov);
CurrentPreset.Set3rdPersonCameraFOV((float) Minecraft.getInstance().gameSettings.fov);
if (!event.player.isPassenger())
CurrentEntity = null;
}
}
@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
if (HvfVehicle) {
event.setRoll(event.getRoll() + CurrentPreset.GetCameraTransformations().getX());
event.setYaw(event.getYaw() + CurrentPreset.GetCameraTransformations().getY());
event.setPitch(event.getPitch() + CurrentPreset.GetCameraTransformations().getZ());
}
}
@SubscribeEvent
public static void onCameraSetup(EntityViewRenderEvent.FOVModifier event) { // sets the FOV
if (HvfVehicle) {
Minecraft minecraftInstance = Minecraft.getInstance();
if (minecraftInstance.player != null && minecraftInstance.gameRenderer != null) {
PointOfView Cam = minecraftInstance.gameSettings.getPointOfView();
if (Cam == PointOfView.FIRST_PERSON) {
event.setFOV(CurrentPreset.GetCameraFOV());
} else {
event.setFOV(CurrentPreset.Get3rdPersonCameraFOV());
}
}
} else if (event.getFOV() != Minecraft.getInstance().gameSettings.fov) {
event.setFOV(Minecraft.getInstance().gameSettings.fov);
}
}
}
@@ -0,0 +1,31 @@
package net.halbear.hvf.Util.Mixin;
import net.halbear.hvf.Halsvehicleframework;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.settings.PointOfView;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.IBlockReader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static net.halbear.hvf.Util.Client.VehicleCameraSettings.GetCameraOffsets;
@Mixin(ActiveRenderInfo.class)
public abstract class CameraMixin {
@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){
if(entity.isPassenger() && Minecraft.getInstance().gameSettings.getPointOfView() != PointOfView.FIRST_PERSON && entity.getRidingEntity().getType().getRegistryName().getNamespace().equals(Halsvehicleframework.MOD_ID)){
Vector3f Position = GetCameraOffsets();
this.movePosition(-this.calcCameraDistance(Position.getZ()), Position.getY(), Position.getX());
}
}
@Shadow(aliases = {"move", "func_216782_a"})
protected abstract void movePosition(double p_216782_1_, double p_216782_3_, double p_216782_5_);
@Shadow(aliases = {"getMaxZoom", "func_216779_a"}) protected abstract double calcCameraDistance(double p_216779_1_);
}
@@ -0,0 +1,12 @@
package net.halbear.hvf.Util.VehicleData;
public enum EngineCategories {
Aircraft_Propeller,
Aircraft_Jet_Engine,
Ship_Propeller,
Car_Petrol_Engine,
Car_Diesel_Engine,
Steam_Ship_Engine,
Steam_Locomotive,
Rocket_Engine
}
@@ -0,0 +1,62 @@
package net.halbear.hvf.Util.VehicleData;
public class VehicleBuildInfo {
private VehicleClassification vehicleClassification;
private int EngineCount;
private EngineCategories EngineType;
private int GasCelCount;
private float MaxSpeedMS;
private float MaxEngineRPM;
private float WingSpanMeters;
private float GasCelCapacity;
public VehicleBuildInfo(VehicleClassification vehicleClassification){
this.vehicleClassification = vehicleClassification;
}
public VehicleBuildInfo SetEngineType(EngineCategories EngineType){
this.EngineType = EngineType;
return this;
}
public VehicleBuildInfo SetGasCelCount(int GasCelCount){
this.GasCelCount = GasCelCount;
return this;
}
public VehicleBuildInfo SetEngineCount(int EngineCount){
this.EngineCount = EngineCount;
return this;
}
public VehicleBuildInfo SetMaxSpeedMS(float MaxSpeedMS){
this.MaxSpeedMS = MaxSpeedMS;
return this;
}
public VehicleBuildInfo SetMaxEngineRPM(float MaxEngineRPM){
this.MaxEngineRPM = MaxEngineRPM;
return this;
}
public VehicleBuildInfo SetWingSpan(float WingSpanMeters){
this.WingSpanMeters = WingSpanMeters;
return this;
}
public VehicleBuildInfo SetGasCelCapacity(float GasCelCapacity){
this.GasCelCapacity = GasCelCapacity;
return this;
}
public VehicleClassification GetVehicleClassification(){
return vehicleClassification;
}
public int GetEngineCount(){
return EngineCount;
}
public EngineCategories GetEngineType(){
return EngineType;
}
public int GetGasCelCount(){
return GasCelCount;
}
public float GetMaxSpeedMS(){return MaxSpeedMS;}
public float GetMaxEngineRPM(){return MaxEngineRPM;}
public float GetWingSpan(){return WingSpanMeters;}
public float GetGasCelCapacity(){return GasCelCapacity;}
}
@@ -0,0 +1,13 @@
package net.halbear.hvf.Util.VehicleData;
public enum VehicleClassification {
Aeroplane,
Zepplin,
HotAirBalloon,
Ship,
WheeledLandVehicle,
TrackedLandVehicle,
RailVehicle,
RailCarriage,
Sail_Ship
}
+55
View File
@@ -0,0 +1,55 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader = "javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
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}"
# 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
[[mods]] #mandatory
# The modid of the mod
modId = "hals_vehicle_framework" #mandatory
# The version number of the mod
version = "${file.jarVersion}" #mandatory
# A display name for the mod
displayName = "Hals Vehicle Framework" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
#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
authors = "halbear1" #optional
# The description text for the mod (multi line!) (#mandatory)
description = '''${mod_description}'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies."hals_vehicle_framework"]] #optional
# the modid of the dependency
modId = "forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory = true #mandatory
# The version range of the dependency
versionRange = "[36,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering = "NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side = "BOTH"# Here's another dependency
[[dependencies."hals_vehicle_framework"]]
modId = "minecraft"
mandatory = true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange = "[1.16.5,1.17)"
ordering = "NONE"
side = "BOTH"
@@ -0,0 +1,3 @@
{
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@@ -0,0 +1,12 @@
{
"required": true,
"package": "net.halbear.hvf.Util.Mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"CameraMixin"
],
"injectors": {
"defaultRequire": 1
},
"refmap": "hem.mixin-refmap.json"
}
+6
View File
@@ -0,0 +1,6 @@
{
"pack": {
"description": "hals_vehicle_framework resources",
"pack_format": 6
}
}