ThexXTURBOXx / BlockHelper

Basically WAILA for b1.2_02-1.5.2
https://modrinth.com/mod/block-helper
MIT License
8 stars 3 forks source link

How exactly do I register my BlockHelperBlockProvider #18

Closed CrossVas closed 5 months ago

CrossVas commented 5 months ago

Hi, I'm in the process of making an addon for BlockHelper, but I'm not sure how would I add my BlockHelperBlockProvider instance to display. Can you provide some more info on how I can achieve that? Thanks!

EDIT: What I've tried is adding:

BlockHelperModSupport.registerBlockProvider(infoProvider);

but it doesn't work.

The infoProvider is this:

public enum WrenchableInfoProvider implements BlockHelperBlockProvider {
    THIS;

    @Override
    public void addInformation(BlockHelperBlockState blockHelperBlockState, InfoHolder infoHolder) {
        infoHolder.add("Testing");
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
CrossVas commented 5 months ago

Nevermind, my voldeloom instance contains a modified version which isn't working properly inside my modding environment. Old mcp mod is displaying it just fine.

public enum WrenchableInfoProvider implements BlockHelperBlockProvider {
    THIS;

    @Override
    public void addInformation(BlockHelperBlockState blockHelperBlockState, InfoHolder infoHolder) {
        TileEntity tile = blockHelperBlockState.te;
        if (tile instanceof IWrenchable) {
            IWrenchable wrenchable = (IWrenchable) tile;
            float dropRate = wrenchable.getWrenchDropRate();
            if (dropRate > 0) {
                infoHolder.add("Wrenchable Block");
            }
        }
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}

image

EDIT: I had to modify the mod a bit for it to run inside modern forge gradle settings. Basically converted it to modern style mod.

CrossVas commented 5 months ago

Re-opening, because I still need to know how would I add additional info providers to the mod while in dev environment. Or at least some more info would be appreciated. What tools you use to build this mod? How can I use this mod inside a dev environment?

ThexXTURBOXx commented 5 months ago

Sorry for not responding until now: I am currently at a wedding, but still try to give as much help as possible. I have never tried to start the mod in dev environments as many parts rely on reflection and I did not want to have to add additional reflection calls just for that. Also, many other mods which Block Helper depends on do not work properly in dev by themselves.

Basically, if you want to build Block Helper yourself, you need to retrieve versions of these mods on your own, deobfuscate them, and somehow add them to the javac classpath (I am doing it using a modified version of the official MCP).

Regarding your issue about the Info provider not working: I think that it works properly now, right? Also, are you using an enum in order to make it basically a singleton?

CrossVas commented 5 months ago

No worries.

Basically, if you want to build Block Helper yourself, you need to retrieve versions of these mods on your own, deobfuscate them, and somehow add them to the javac classpath (I am doing it using a modified version of the official MCP).

I've actually built BlockHelper using modern gradle. Can be found here: BlockHelper-1.5.2. Still have some minor parts to fix, but that's out of scope.

Regarding your issue about the Info provider not working: I think that it works properly now, right?

It is not working inside of dev environment as is, because I don't have BaseMod, while the gradle version refuse to load any providers I have. All I can do is load it inside my MultiMC testing instance and check things. It's enough for now, but it's painful, so I have to find out why my version is not working.

Also, are you using an enum in order to make it basically a singleton?

That is a format from a modern mod, I'll change that once I got everything working under one environment.

CrossVas commented 5 months ago

I guess I'll have to use an external instance to check my addon. Still a bit confusing since it's an old version of MC, but it's working. image

The issue can be closed I think.

ThexXTURBOXx commented 5 months ago

It is very weird that your Forge dev env does not include BaseMod, as it is in fact contained in the latest Forge release for 1.5.2: grafik

But anyway, the @Mod annotation will practically do the same thing anyway, so you are fine using that instead in your version of Block Helper. If you find any issues in Block Helper, feel free to create an issue or PR here, though! However, I won't convert my "official" Block Helper repo to Gradle, because I like using the official way (MCP) instead - and I am unsure about the compatibility with many older versions of Minecraft and (most importantly) ModLoader or MLMP on that matter. Furthermore, for some versions, I needed to edit class files within Minecraft itself in order to compile Block Helper with support for some mods with base edits. All of this can be done also in a Gradle installation, but it takes probably 10x more time than just editing the corresponding class files yourself in your dev env. I wanted to convert to https://github.com/MCPHackers/RetroMCP-Java at some point, but it lacks many "more modern" (if you can call them that) versions of Minecraft, namely 1.3.2-1.5.1. So again, I would not have consistency across this repo. Actually, I wanted to create the mappings myself in order to be able to use it (as seen here), but I just don't have enough information to achieve this properly at this point.

Anyway, thanks for your input and sorry for this long response - I hope I could clear up some of the things I had to think through in order to make Block Helper function the way it does now :)