-
Notifications
You must be signed in to change notification settings - Fork 0
Boats
VoidLeech edited this page Dec 20, 2024
·
2 revisions
To create Boats using Oblivion, follow these steps.
Your dependency on Oblivion should be BEFORE.
- Create an Enum containing your wood types. This enum should implement OblivionBoatType AND call
initOBT()
:
public enum ExampleBoatType implements OblivionBoatType {
EXAMPLE_1(YourBlocks.EXAMPLE_1_PLANKS.get(), "example_1", YourItems.EXAMPLE_1_RAFT, YourItems.EXAMPLE_1_CHEST_RAFT, true),
EXAMPLE_2(YourBlocks.EXAMPLE_2_PLANKS.get(), "example_2", YourItems.EXAMPLE_2_BOAT, YourItems.EXAMPLE_2_CHEST_BOAT, false);
private final String name;
private final Supplier<? extends OblivionBoatItem> boat;
private final Supplier<? extends OblivionBoatItem> chestBoat;
private final boolean usesRaftModel;
private final Block planks;
ExampleBoatType(Block planks, String name, Supplier<? extends OblivionBoatItem> boat, Supplier<? extends OblivionBoatItem> chestBoat, boolean usesRaftModel) {
this.name = name;
this.boat = boat;
this.chestBoat = chestBoat;
this.planks = planks;
this.usesRaftModel = usesRaftModel;
initOBT();
}
@Override
public String getName() {
return name;
}
@Override
public String getNamespace() {
return MOD_ID;
}
@Override
public Item getBoat() {
return boat.get();
}
@Override
public Item getChestBoat() {
return chestBoat.get();
}
@Override
public boolean usesRaftModel() {
return usesRaftModel;
}
@Override
public Block getPlanks() {
return planks;
}
}
-
Register your boat items as normal (DeferredRegister+RegistryObject), using the provided OblivionBoatItem, passing one of your enum's values.
-
In your ClientModEvents (or similar), register your enum:
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
OblivionBoatRenderer.registerBoatResources(ExampleBoatType.class, MOD_ID);
}
- Create ModelLayers for your wood types (Dist.Client only):
public class ExampleModelLayers {
public static final ModelLayerLocation EXAMPLE_1_RAFT_LAYER = new ModelLayerLocation(
new ResourceLocation(MOD_ID, "boat/example_1"), "main");
public static final ModelLayerLocation EXAMPLE_1_CHEST_RAFT_LAYER = new ModelLayerLocation(
new ResourceLocation(MOD_ID, "chest_boat/example_1"), "main");
public static final ModelLayerLocation EXAMPLE_2_BOAT_LAYER = new ModelLayerLocation(
new ResourceLocation(MOD_ID, "boat/example_2"), "main");
public static final ModelLayerLocation EXAMPLE_2_CHEST_BOAT_LAYER = new ModelLayerLocation(
new ResourceLocation(MOD_ID, "chest_boat/example_2"), "main");
}
- In your ClientModEvents (or similar), register the models, using Raft(Chest)Model for any wood types you've declared to use the Raft model, and Boat(Chest)Model otherwise:
@SubscribeEvent
public static void registerModelLayers(EntityRenderersEvent.RegisterLayerDefinitions event){
event.registerLayerDefinition(ExampleModelLayers.EXAMPLE_1_RAFT_LAYER, RaftModel::createBodyModel);
event.registerLayerDefinition(ExampleModelLayers.EXAMPLE_1_CHEST_RAFT_LAYER, ChestRaftModel::createBodyModel);
event.registerLayerDefinition(ExampleModelLayers.EXAMPLE_2_BOAT_LAYER, BoatModel::createBodyModel);
event.registerLayerDefinition(ExampleModelLayers.EXAMPLE_2_CHEST_BOAT_LAYER, ChestBoatModel::createBodyModel);
}
- Add your textures to
assets/mod_id/textures/entity/boat/
andassets/mod_id/textures/entity/chest_boat/
, each just the name of your wood as defined in your enum, i.e. example_1.png.