2026-05-20 08:39:35 +01:00
2026-05-20 08:39:35 +01:00
2026-05-19 23:22:02 +01:00
2026-05-20 08:39:35 +01:00

Hal's Vehicle Framework

a simple to use but powerful vehicle library for Minecraft Forge 1.16.5, 1.20.1, and 1.21.1

Getting Started

after importing the library, to create an entity with the framework you structure it as so

The entity itself:

public class MyVehicleClass extends VehicleBaseEntity {

    private static final VehicleBuildInfo buildInfo = new VehicleBuildInfo(VehicleClassification.Zepplin)
            .SetEngineCount(2)                                      //example properties
            .SetEngineType(EngineCategories.Aircraft_Propeller)     //this example uses the Zepplin vehicle properties
            .SetMaxEngineRPM(3000)
            .SetMaxSpeedMS(70)
            .SetGasCelCount(8)
            .SetGasCelCapacity(1000);

    public MyVehicleClass(EntityType<?> Type, World WorldIn) {
        //The parameters in this super are the Type, the World, an array of seat positions and the vehicle build info
        //specify as many seat positions as you want in this array as it loads all of them as player seats on the entity
        
        super(Type, WorldIn, new Vector3d[]{new Vector3d(0.0D, -1D, 0.0D)}, buildInfo); // The super class handles everything entity related
        
        //this allows you to completely customise how the camera is structure for the vehicle,
        //the first Vector is position offset, the 2nd vector is rotation, 
        //and then the first float value is 1st person FOV with the 2nd float value being 3rd person FOV
        
        VehicleCameraSettings.AddEntityCameraPreset(this.getType(),
                new VehicleCameraPreset(new Vector3f(0,4.0f, 16.0f),
                new Vector3f(0,0,0),70,65f));
    }
    
    @Override
    public void TickUpdateEvent(){
        //this is called by the super class every tick update 
        //and is a safer way to add code without overriding what happens in the parent class
        //you can still @Override the normal tick update though
    }
}

The entity renderer:

this you put an array of models in but for this example its an array of 1 size, this is so you can put multiple models for a single vehicle in, or make it dynamically swappable in game

@OnlyIn(Dist.CLIENT)
public class MyVehicleRenderer extends VehicleBaseRenderer {
    public AirboatRenderer(EntityRendererManager renderManagerIn) {
        super(renderManagerIn, new EntityModel<?>[]{new MyVehicleModel()},"textures/entities/MyVehicleTexture.png");
    }
}

Registering the entity

you register the entity as if it were any other entity

    public static DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, MOD_ID);

    public static final RegistryObject<EntityType<MyVehicleClass>> MY_VEHICLE =
            ENTITY_TYPES.register("my_vehicle", ()-> EntityType.Builder.create(MyVehicleClass::new,
                    EntityClassification.MISC ).size(3f,2f).build(new ResourceLocation(MOD_ID, "my_vehicle").toString()));

Registering the renderer

this is also the same as if it were any other entity, it is put in the client event handler

@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventHandler {
    @SubscribeEvent
    public static void init(final FMLClientSetupEvent event) {
        RenderingRegistry.registerEntityRenderingHandler(ModEntities.MY_VEHICLE.get(),  MyVehicleRenderer::new);
    }
}
S
Description
a forge/neoforge minecraft vehicle framework
Readme 518 KiB
Languages
Java 100%