Everything posted by Jontom Xire
-
Button Widget not working
You're a hero, Warjort...again. I was having a similar problem with the Button class and could not find anything about the CreateNarration parameter that the compiled was complaining of as missing.
-
[19.3] Example code.
I did open an issue about the key mapping previously, and was very impressed by your response and response time. I am hugely impressed if you are the only one trying to update two lots of documentation at once. Maybe reduce work by obsoleting one after ensuring the other has all relevant information. I apologise for being lazy with raising issues since then, but the sheer amount of time it is taking me to get anything working means that the time I would need to spend actually thinking about where and how I am confused, and documenting it, would kill my project. I work full time as a software engineer and that means that normally I have no energy or inclination for hobby coding. This Christmas holidays is, as with previous years, the only time I can summon the energy to do any hobby coding. Regarding examples, a working and compilable example gives context that allows you to understand the whole picture. At least it does for me. I know some people just copy and paste without taking the time to understand how things fit together. As far as I am concerned I am happy to let them simmer in the juices of their own incompetence. People like me who copy and paste bit by bit into my own code, refactoring completely as we go, while reading the documentation in parallel, will find working examples really useful. Regarding the javadocs, I don't use IDEs. I can see how one would be useful here, but I used Eclipse previously and found it incredibly annoying. I hate wrestling with endless settings to get the indentation almost, but not completely, the way I like it. I hate the way IDEs try to write code for me, predicting what I am trying to type and just completely distracting my train of thought as I type. I have a vimrc file I have been using for almost 20 years, that I take from job to job and tweak as needed, and it gives me an editing environment that does exactly what I want. I guess I just need to spend some time to figure out how to generate the javadocs myself. Once again, despite all my frustrations, I am really grateful to Ash and all of you for your work on Forge and the documentation.
-
Documentation for sending message to client is incorrect or unclear.
The documentation at https://docs.minecraftforge.net/en/1.19.x/networking/simpleimpl/ for sending packets states that the code to send a message to a single player looks like this: INSTANCE.send(PacketDistributor.PLAYER.with(serverPlayer), new MyMessage()); I have wrapped this in a function in a class so that I can keep INSTANCE private and simplify all code that sends messages to the client. My function is: public static <MSG> void sendToClient(ServerPlayer player, MSG msg) { INSTANCE.send(PacketDistributor.PLAYER.with(player), msg); } This fails to compile with the error: incompatible types: ServerPlayer cannot be converted to Supplier<ServerPlayer> I have looked at the documentation for the Supplier class and there are no signs of any constructor or assignment function such as you get with Optional and similar classes. I did notice that it said that Supplier was a functional interface and changed my code to: public static <MSG> void sendToClient(ServerPlayer player, MSG msg) { INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), msg); } This compiles. I suggest you change the documentation to read: INSTANCE.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new MyMessage());
-
[19.3] Example code.
You're wonderful. Thanks!
-
[19.3] Example code.
This thread has been heavily derailed. Sorry.
-
[19.3] How do I do logical server side setup?
This contradicts both the documentation and my own experience. In the single player version there is a separate server thread. According to the documentation, and I agree based on over two decades as a professional software engineer, the code needs to distinguish between the server thread and the client (render) thread when doing anything server based so that when the mod is used on a dedicated server, everything works as expected. There are explicit warnings in the documentation to the effect that failing to do this correctly leads to crashes when a mod that works perfectly as a single player/LAN game is used with a dedicated server with multiplayer clients connecting to it. The documentation talks about Level#isClientSide(), yes, but the information I was missing was that I didn't know where to get an instance of Level from. I didn't realise that it was a member of the Entity class until I read your post and searched for "level" in the documentation of the "Player" class. Thank you very much for helping me figure this out.
-
[19.3] Example code.
In the community wiki example they implement a capability provider class that they then attach to the entity. In ElectroBlob's Wizardry mod which, even though it is based on 1.12.2, is what I am using as an example, they do much the same. So colour me confused. My code is at https://gitlab.com/xire-mods/stats-and-skills/-/tree/daddy_development, in the PlayerData.java file. I have no idea how or where to invalidate the LazyOptional instance. I am also currently wrestling with another problem, which is that when I handle the PlayerEvent.Clone event, there appear to be no capabilities attached to the Player instance returned by getOriginal(). I have added debug throughout to report hash codes, and when I call `player.getCapability(PLAYER_DATA_CAPABILITY)` on the Player returned by getOriginal(), it doesn't even call into my capability provider class. @SubscribeEvent public static void onPlayerCloneEvent(PlayerEvent.Clone event) { PlayerData new_data = PlayerData.get(event.getEntity()); PlayerData old_data = PlayerData.get(event.getOriginal()); ... } ... public static PlayerData get(Player player) { PlayerData result; LazyOptional<PlayerData> lo = player.getCapability(PLAYER_DATA_CAPABILITY); if (lo.isPresent()) { StatsNSkills.LOGGER.info("JX: " + player.getName().getString() + " (" + player.hashCode() + ") has capability."); result = lo.resolve().get(); } else { StatsNSkills.LOGGER.info("JX: " + player.getName().getString() + " (" + player.hashCode() + ") has no capability."); result = null; } return result; } ... public Provider(Player player) { data = new PlayerData(player); lazy_optional = LazyOptional.of(() -> data); StatsNSkills.LOGGER.info("JX: " + player.hashCode() + " = " + lazy_optional.hashCode()); } @Override public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction side) { if (capability == PLAYER_DATA_CAPABILITY) { StatsNSkills.LOGGER.info("JX: " + data.player.hashCode() + " -> " + lazy_optional.hashCode()); } return PLAYER_DATA_CAPABILITY.orEmpty(capability, lazy_optional); } The website has screwed up the indentation. On login I get: [30Dec2022 12:42:05.394] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: 240 = 642878468 [30Dec2022 12:42:05.655] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: 240 -> 642878468 [30Dec2022 12:42:05.655] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: JontomXire (240) has capability. [30Dec2022 12:42:05.656] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: JontomXire has logged in 1 times. The first line is when my Provider class is constructed. The second is from my Provider class' getCapabilities() function is called in the login event handler. The third line is from my get() function that gets the underlying data for the Player. When I respawn I get the following debug output: [30Dec2022 12:42:38.466] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: 513 = 372405745 [30Dec2022 12:42:38.467] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: 513 -> 372405745 [30Dec2022 12:42:38.467] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: JontomXire (513) has capability. [30Dec2022 12:42:38.468] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: JX: JontomXire (240) has no capability. The first line is from construction of an instance of my Provider class when attaching to the new Player instance. The next two lines are from calling get() on the new Player instance in the player clone event handler. The third line is from calling get() on the original player instance. Before it I would expect to see a line of debug like the second line in the login debug. The lack of such a line shows that my getCapabilities() function in my Provider class is not being called.
-
[19.3] Example code.
On the capabilities page: What is meant by an "owned" entity? What exactly makes an entity owned? Then it goes on to talk about a non-owned provider. A provider is not the same as an entity, surely? Where do we put "invalidateCaps()"? Is this an interface API that we need to implement? How does it get called?
-
[19.3] Example code.
Before I start, I want to make it clear that I appreciate how much hard work has gone into the official Forge documentation. That said... There are many examples where it is lacking in sufficient detail: Import packages. Many symbols are used in multiple packages and searching the javadocs is painful. A list of all the relevant import packages referenced by an article, and which symbols mentioned in the article that each provides, would be really helpful. At one point I was having an event listener ignored. The forge community wiki has an image at https://forge.gemwire.uk/images/c/cc/Guide_to_Event_Handlers.png that makes it very clear when the handler needs to be static and when not, as well as giving a comprehensive list of all the ways of registering event handlers. I spent hours figuring the same thing out based on the official Forge documentation and experimentation. The code fragments lack important context. Links to examples in each article would be really good. The page on capabilities is very piecemeal. There is no overview of the process. There is a section on exposing and another on registering, but no clear explanation of how all the pieces fit together. By contrast the community wiki has an entire page with a detailed explanation of how capabilities work at https://forge.gemwire.uk/wiki/Capabilities. No detail on parameters and return values for each function. I don't expect this for core Minecraft, or other 3rd party, classes and symbols, but adding doxygen to the Forge code would provide a very useful degree of documentation, with additional places to hold details of any gotchas or non-obvious details of functions, as well as links to the main documentation. Alternatively... At https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.19.2/ there is a github repository for the Javadocs for Forge. They can be automatically generated using scripting etc. Why is it left to someone else to generate these documents? Why not have a simple script that will generate the documentation for each release and publish it. Then you can put a link to it in the official Forge documentation. More than that, each time you put a function name in the documentation, it could be a link to the relevant part of the javadocs. A link to the community wiki, which as mentioned has many articles that are much better written, would be really helpful. It would also save you work. No point duplicating the effort. As stated in my original post, the documentation, somewhere (I cannot find it again) mentioned that there were examples elsewhere. There are no links to these examples. The community wiki has such examples, E.g. https://forge.gemwire.uk/wiki/Capabilities#Code_Examples It took me a whole day to figure out how to do a simple key mapping from the official forge documentation, and that was only possible after you responded (extremely promptly) to my bug report. Thank you for that. Even after the documentation was updated, it still took another half day. By comparison, at work I recently needed to work with Kvaser CAN devices, which I had never ever dealt with before. Instead of days, it took me about two hours to read and fully understand how to integrate their devices into our internal IO library. There are many many other examples of times when I have entered a programming task with no idea how to achieve it and had to rely on online documentation, and I have always found it much easier than I have found Minecraft modding. For someone new to modding, gaining the necessary information is extremely difficult.
-
[1.19] Example of using capabilities.
That wiki is SO SO SO much better than the official forge documentation. Thank you so much.
-
Missing important packages in Eclipse
Modding is a nightmare if you are just starting. The documentation is terrible. I am getting so confused on everything. For starters, what version of Minecraft and MDK are you modding for? Are you working on Linux/Mac or Windows? Did you run the commands from the README? If you prefer to use Eclipse: 1. Run the following command: `gradlew genEclipseRuns` (`./gradlew genEclipseRuns` if you are on Mac/Linux) 2. Open Eclipse, Import > Existing Gradle Project > Select Folder or run `gradlew eclipse` to generate the project. I am working with Minecraft 1.19.x and there is no "Start.java" file in the MDK. I am building entirely off the command line under Linux and it all works ok for me.
-
[1.19] Example of using capabilities.
Can anyone give me an example of adding a capability to players, please. I have some example code from a 1.12.2 mod, but things have clearly changed since then. I don't understand the documentation. It is fragmented and unclear. Obviously whoever wrote it understands what the hell they are talking about, but I don't. All the snippets and description is about an item handler for inventory related stuff on a block entity, which really does not help me. For example, when do you use an existing capability (apparently through a new key, so how are you using an existing capability?) and when do you need to expose a capability, or do you have do both? It appears I would have to subclass the Minecraft Player class to expose a capability. The initial text talks about exposing an event or "overriding the capability methods in your own implementations of the objects", but the section on exposing the capabilities has implementations of overriding the capability methods. I am so confused. I just want to be able to add, for example, a "dizziness" value to a player that I can increment or decrement depending on certain things happening, and reference from other parts of the code.
-
[19.3] How do I do logical server side setup?
My understanding is that FMLCommonSetupEvent() triggers for both client and local server and dedicated server, which is why it has "Common" in the name, so calling it FMLLogicalServerSetup() would be incorrect. I have found that my snippet above works for other events, such as PlayerEvent.PlayerLoggedInEvent.
-
[19.3] How do I do logical server side setup?
import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.util.thread.EffectiveSide; ... private void commonSetup(final FMLCommonSetupEvent event) { if (LogicalSide.SERVER == EffectiveSide.get()) { ... } } The above code compiles (when you fill in the missing bits). It does not work for a single player game. I am not sure if it works for a dedicated server.
-
[19.3] How do I do logical server side setup?
There are several setup events I can hande: FMLCommonSetupEvent - called for both client and server. FMLClientSetupEvent - client only. FMLDedicatedServerSetupEvent - dedicated server only, NOT single player/LAN game server. Where is the FMLServerSetupEvent that runs for both single player/LAN game servers and dedicated servers? I have read https://docs.minecraftforge.net/en/1.19.x/concepts/sides/ extensively. A DistExecutor seems overkill. In the common setup event handler I just want to check the side and do client/server specific stuff. How do I do setup for a logical server that may be running as a single player game or may be running as a dedicated server?
-
[19.3] Example code.
I am new to Minecraft modding. The Forge documentation mentions there being examples of code somewhere, but I cannot find them. I also find the Forge documentation lacking in sufficient detail. There is a lot of implicit knowledge. After half a day of tearing my hair out, I finally managed to implement a simple key mapping of a single key. To help new modders, I have provided a simple fully working code example of implementing a key mapping at https://gitlab.com/JontomXire/minecraft-forge-1.19.3-examples. I intend to extend this in due course with other examples. I would be grateful for all code examples that other people could provide. The criteria for acceptance are: Minimum code example. No need to include all the gradle stuff, just the build.gradle and anything under src. Try to base it on the example mod code included in the Forge MDK. Must build. All examples must be full and complete to compile without the user having to do anything other than copy in all the gradle stuff from the Forge MDK. Must run. All examples must work with nothing more than copying the JAR file into the mods folder of a clean installation, and then running that installation. It must be possible for the user to see the mod working, even if that requires checking the debug.log file.
-
Looking for proper documentation.
So Minecraft don't export their API to help the modding community...figures. What's the best way to view the Parchment data in a searchable format? Is there a tool for that? Anyway, thanks to your clues, I found this: https://nekoyue.github.io/ForgeJavaDocs-NG/ It only goes up to 1.19.1, but it's a great start!
-
Looking for proper documentation.
Hi, all. I am a professional programmer with 25 years experience. I am very good at it. Mainly C and C++ but I have spent some time with Java. I am used to proper documentation of libraries and APIs. I don't use an IDE as I prefer to read and understand the documentation. I have looked at the forge documentation and had a conversation with one of the maintainers and understand that Forge is layered over a Vanilla Minecraft API, a collection of Java objects that form the basis of mod development. Where is the documentation for this collection of Java objects? I have been pointed at "Parchment". I ended up downloading a JSON file that is not, frankly, human readable. Where is the documentation?!?!? How does anyone write a Minecraft mod without documentation? Are you all just using IDEs that prompt you with the function or object name you need and automatically add the required imports? How do you understand what the functions do, deep down? What I really need is something like https://linux.die.net/ or https://en.cppreference.com/w/ or https://doc.qt.io/qt-5/classes.html. Proper detailed documentation, properly organised and searchable. Does anything like that exist online for Minecraft?
-
Confused in Coding the Key binding.
It appears that KeyBinding has been replaced by KeyMapping for which there is zero documentation and no examples at all, even incomplete ones.
-
Confused in Coding the Key binding.
I have been searching the internet for hours trying to figure out how to do a key binding and all the articles are very incomplete and/or for VERY old versions of Forge. Please could you give more details or links to documentation on these functions. What is the full package path to import ClientRegistry? What are the parameters to ClientRegistry.registerKeyBinding? How do I register for events of type InputEvent.KeyInputEvent? Why does the documentation at https://docs.minecraftforge.net/en/latest/, when searched, not show any meaningful results for a search term of "KeyBinding" or "key input" or anything similar. I am completely happy with links to the relevant documentation...if there is any.
IPS spam blocked by CleanTalk.