Open crabmiau opened 1 week ago
The instance you used to create the ClickGUI or HUD. If you're using the PanelStudio-MC support library, that's typically an instance of GUIInterface
(a sublcass of MinecraftGUI
). In the example mod, you can obtain it via the ClickGUI.getInterface()
method.
I can't get it from another class since it has protected access
i figured it out but Point cfgvar5 = WatermarkModule.getComponent().getPosition(gui.getInterface()); returns java.awt.Point[x=1,y=1] even if its not at 1,1
If it's the WatermarkModule from the example mod, this shouldn't be the case. I can't tell what is causing it without looking at the code tho.
If you're looking to save the positions of the panels in a config file, there's an interface for that. Implement the interface IConfigList
, which models the config as a bunch of items representing panels (each represented with IPanelConfig
) that have a title (which identifies the panel) and position, and a boolean state, (usually whether the panel is open or closed).
The methods you implement for those interfaces basically save/load the values to/from the config file. To load/save the config you called gui.loadConfig
or gui.saveConfig
with your IConfigList
implementation.
Also worth noting is that the position you get via getPosition
is the top left corner of the component you're rendering to the HUD. This is not necessarily the one that is saved in the config file. For example, ListComponent
, which WatermarkModule
is based on, will store the x coordinate of the right edge, if it is configured to align to the right instead of the left.
If it's the WatermarkModule from the example mod, this shouldn't be the case. I can't tell what is causing it without looking at the code tho. If you're looking to save the positions of the panels in a config file, there's an interface for that. Implement the interface
IConfigList
, which models the config as a bunch of items representing panels (each represented withIPanelConfig
) that have a title (which identifies the panel) and position, and a boolean state, (usually whether the panel is open or closed). The methods you implement for those interfaces basically save/load the values to/from the config file. To load/save the config you calledgui.loadConfig
orgui.saveConfig
with yourIConfigList
implementation.
I tried to do it but it seems its not well documented and I don't exactly know how to use it
Are there any more simple examples?
I don't see how this could get much simpler. Most of the code is related to JSON loading/saving, which will have to be replaced by your own specific loading/saving code anyways.
and the example also seems old
Whoops, I linked the wrong branch: https://github.com/IUDevman/gamesense-client/blob/d2.3.1/src/main/java/com/gamesense/client/clickgui/GuiConfig.java At any rate, the interface haven't changed since then, so it shouldn't matter that much.
I'm trying to get the position of the watermark but it requires IInterface, I cant figure out where I can get it