Samlegamer / Macaw-s-Bridges-Compat

If you are a developer and you want to create a compatibility for the Macaw's Bridges mod you can use these examples.
1 stars 1 forks source link

How to create new Addon ??? [NOT FINISHED] #4

Closed Samlegamer closed 2 years ago

Samlegamer commented 2 years ago

Prerequisite:

Create a new forge project and have a main class.

1) Dependencies

First of all we need the Macaw's Bridges classes to be able to make an addon.

You just have to add this line to your build.gradle file:

repositories{
    maven {
        name = "CurseForge"
        url = "https://minecraft.curseforge.com/api/maven/"
    }
    maven {
        name = "CurseMaven"
        url = "https://www.cursemaven.com"
    }

}

dependencies
{
    minecraft 'net.minecraftforge:forge:1.16.5-36.2.0'
    implementation fg.deobf("curse.maven:macaws-bridges-351725:3516271")
}

In this tutorial we implement Macaw's Bridges 1.16.5, to implement a version 1.18.1 for example you have to change the last number.

1 16 5 implements red

Go to Curse Forge -> Macaw's Bridges,

mcw bridges title

Then go to files

mcw bridges files

You have to take the version you need, we will take the 1.16.5 in this example but know that you just have to change the file id to change the version.

mcw bridges 1 16 5

The number is here :

id mcw bridge

Then we need the 2nd addons mod, it's mainly him who will manage the textures. In this example we will take Biome O' Plenty in 1.16.5 :

Before

implementation fg.deobf("curse.maven:example-mod-IdProject:FileID")

After

example-mod and in the url :

bop 1

IdProject is just in "About Project":

bop 2

and finally the FileID is in the url by clicking on the corresponding version.

bop 3

bop 4

bop 5

implementation fg.deobf("curse.maven:biomes-o-plenty-220318:3544153")

It's very important to understand the dependency system for your own addons mods.

Once you have these two lines put "gradlew eclipse" for cmd or ".\gradlew eclipse" if you are on PowerShell.

This will refresh your IDE dependencies and add the chosen mods.

2) Setup Class

To start with we will create a basic block declaration class.

public class AddonBlocks
{
    public static final DeferredRegister<Block> BLOCKS_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, MainAddon.MODID);

    public static RegistryObject<Block> createBlock(String name, Supplier<? extends Block> supplier)
    {
        RegistryObject<Block> block = BLOCKS_REGISTRY.register(name, supplier);
        AddonItems.ITEMS_REGISTRY.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(MacawsBridges.BridgesItemGroup)));
        return block;
    }
}

AddonItems:

public class AddonItems
{
    public static final DeferredRegister<Item> ITEMS_REGISTRY = DeferredRegister.create(ForgeRegistries.ITEMS, MainAddon.MODID);
}

MainAddon:

@Mod(value = MainAddon.MODID)
@Mod.EventBusSubscriber(modid = MainAddon.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class MainAddon
{
    public static final String MODID = "exampleaddon";

    public MainAddon()
    {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::ClientSetup);
    }

    private void setup(FMLCommonSetupEvent event)
    {

    }

    private void ClientSetup(FMLClientSetupEvent event)
    {
             //For the RenderType
    }
}

3) Blocks