Creating Your Own Bogey Style - Rabbitminers/Extended-Bogeys GitHub Wiki

Prerequisites

First make sure you have integrated Extended Bogeys if you haven't already you can find instructions Here aswell as Create and its requirements which you can find instructions for Here

You will also likely want to look into Registering Partial Models aswell as Using .obj (wavefront) Models

Demos / Examples

An example custom bogeys added in the base mod can be found Here giving a basic overview of how custom Styles are added as well as this Java Docs are provided within the interface explaining their functionality

Setup

Create a class implementing the IBogeyStyle interface provided by Extended Bogeys this provides common methods for rendering and other functionality. As a demonstration here is an example class implementing the IBogeyStyle interface and supplying a custom name for the style:

public class ExampleBogeyStyle implements IBogeyStyle {
    @Override
    public String getStyleName() {
        // It is recommended to use translation keys to allow for localisation of your bogey names, this is detailed in the tips page
        return "Example Style";
    }

    /* your code goes here */
}

From here you can implement different methods from IBogeyStyle to customise your new style. Different methods are provided for rendering in world (When the bogey is placed), in a Contraption (When the bogey is in a train) and in the selection GUI.

Custom Properties

Setting a maximum speed limit

This is a configurable setting which can be enabled within the in-game config. To set a maximum speed for your bogey style override the getMaximumSpeed method and replace the return value in blocks/second (Please be warned that very high values can create lag and cause rendering issues so use with caution), the default value is 28, the new value can both exceed and reduce the default value for example using our previous demo:

public class ExampleBogeyStyle implements IBogeyStyle {
    @Override
    public float getMaximumSpeed() {
        // This will reduce the maximum blocks per second to 12.5 blocks/second
        return 12.5f;
    }
    
    /* your code goes here */
}

Setting a minimum turn radius

This is a configurable setting which can be enabled within the in-game config designed for larger bogeys that may experience clipping when going round shorter turns, if the curve is to small the train will derail, the bogey with the shortest turn radius will take precedent for the rest of the train. To set a minimum turn radius for your bogey style override the getMinimumTurnRadius method and replace the return value, which by default is set to 0 with an radius between 1 and 128 angles above this are not currently possible, here is an example using our previous demo:

public class ExampleBogeyStyle implements IBogeyStyle {
    @Override
    public float getMinumumTurnRadius() {
        // This will reduce the minumimum curve length to 16 blocks
        return 16f;
    }
    
    /* your code goes here */
}

Rendering

In World

This is displayed when a Bogey is placed in-game but is not assembled within a contraption except for if the bogey is un-linked in which case in-world rendering will be used.

Rendering in world is handled by the methods renderLargeInWorld for the large version of your style, renderSmallInWorld, for the small version of your style or renderInWorld if you have any common rendering to be done (note - make sure to call the super method when doing this so that size specific rendering is also called)

Here is a demo using our previous example class:

public class ExampleBogeyStyle implements IBogeyStyle {

}

In A Contraption

This is called used when rendering as part of a contraption both for linked and and unlinked bogeys

Partial Models can be loaded as ModelData, this should be done in IBogeyStyle#registerSmallBogeyModelData and IBogeyStyle#registerLargeBogeyModelData respectively, which are called on initialisation of a new BogeyInstance. Make sure to supply all registered data to getAllCustomModelComponents() as this is used by Extended Bogeys to handle lighting, animation and transformations. Here is an example to load a frame and two sets of wheels.

public class ExampleBogeyStyle implements IBogeyStyle {
    private ModelData threeWheelBogeyRod;
    private ModelData frame;
    private ModelData[] wheels;

    @Override
    public List<ModelData> getAllCustomModelComponents() {
        List<ModelData> modelData = new ArrayList<>();
        modelData.add(frame);
        // Because our wheels are created as an array we can use addAll() to supply them both
        modelData.addAll(Arrays.asList(wheels));
        return modelData;
    }

    @Override
    public void registerLargeBogeyModelData(MaterialManager materialManager) {
        // Load the frame model
        frame = materialManager.defaultSolid().material(Materials.TRANSFORMED)
                .getModel(AllBlockPartials.BOGEY_FRAME)
                .createInstance();
        
        // Create an array of model data with the number of wheels we want
        wheels = new ModelData[2];
        
        // Fill the array with Large Wheels
        materialManager.defaultSolid()
                .material(Materials.TRANSFORMED)
                .getModel(AllBlockPartials.LARGE_BOGEY_WHEELS)
                .createInstances(wheels);
    }

    @Override
    public void registerSmallBogeyModelData(MaterialManager materialManager) {
        // Load the frame model
        frame = materialManager.defaultSolid().material(Materials.TRANSFORMED)
                .getModel(AllBlockPartials.BOGEY_FRAME)
                .createInstance();
        
        // Create an array of model data with the number of wheels we want
        wheels = new ModelData[2];

        // Fill the array with Small Wheels
        materialManager.defaultSolid()
                .material(Materials.TRANSFORMED)
                .getModel(AllBlockPartials.SMALL_BOGEY_WHEELS)
                .createInstances(wheels);
    }
}

TODO

In A GUI

This is displayed when the selection graphical user interface (GUI) is opened by the player in-game, and is rendered differently to the in world and in contraption rendering and thus requires its own method although is largely the same as rendering in world.

Rendering in a GUI is handled by the methods renderLargeInGuiOverlay for the large version of your style, renderSmallInGuiOverlay, for the small version of your style or renderInGuiOverlay if you have any common rendering to be done (note - make sure to call the super method when doing this so that size specific rendering is also called)

Here is a demo using our previous example class:

public class ExampleBogeyStyle implements IBogeyStyle {
    @Override
    public List<GuiGameElement.GuiRenderBuilder> renderInGuiOverlay(boolean isLarge) {
        // Capture size specific models and then append a new model to them
        List<GuiGameElement.GuiRenderBuilder> partialModels = IBogeyStyle.super.renderInGuiOverlay(isLarge); 
        partialModels.add(GuiGameElement.of(AllBlockPartials.BLAZE_BURNER_FLAME).atLocal(1, 1, 1))
        // Return the new list of models with our snazzy new flames attached
        return partialModels;
    }

    @Override
    public List<GuiGameElement.GuiRenderBuilder> renderLargeInGuiOverlay() {
        // Load partial models as GameElements and manipulate their location
        // Note - if you prefer this can also be inlined 
        GuiGameElement.GuiRenderBuilder
                frame = GuiGameElement.of(AllBlockPartials.BOGEY_FRAME),
                front_wheel = GuiGameElement.of(AllBlockPartials.LARGE_BOGEY_WHEELS).atLocal(-1, 0, 0),
                back_wheel = GuiGameElement.of(AllBlockPartials.LARGE_BOGEY_WHEELS).atLocal(1, 0, 0);
        // Return these values as an ArrayList
        return new ArrayList<>(Arrays.asList(frame, front_wheel, back_wheel));
    }

    @Override
    public List<GuiGameElement.GuiRenderBuilder> renderSmallInGuiOverlay() {
        // Load partial models as GameElements and manipulate their location
        // Note - if you prefer this can also be inlined 
        GuiGameElement.GuiRenderBuilder
                frame = GuiGameElement.of(AllBlockPartials.BOGEY_FRAME),
                front_wheel = GuiGameElement.of(AllBlockPartials.SMALL_BOGEY_WHEELS).atLocal(-1, 0, 0),
                back_wheel = GuiGameElement.of(AllBlockPartials.SMALL_BOGEY_WHEELS).atLocal(1, 0, 0);
        // Return these values as an ArrayList
        return new ArrayList<>(Arrays.asList(frame, front_wheel, back_wheel));
    }
    
    /* your code goes here */
}

This returns a list of GuiRenderBuilders of PartialModels that are then handled by Extended Bogeys, these can be positioned and rotated relative to the model using the GuiRenderBuilder#atLocal(x, y, z) method and GuiRenderBuilder#rotate(x, y, z), please note that GuiRenderBuilder#at positions the model on the screen not locally and such shouldn't be used as this is handled by Extended Bogeys

⚠️ **GitHub.com Fallback** ⚠️