Skip to content

Conversation

@Fourmisain
Copy link
Contributor

GameRules aren't part of World and ClientWorld anymore, as they are not synced with the client automatically anymore (I think).
Not a big problem since we already manually synced the weather one anyways, so I just added the daylight one to it as well (see GameruleSyncPayload).

The Item.Settings now need to be passed a RegistryKey and there's no TypedActionResult anymore.

1.21.4 needs an item definition (assets/testutils/items/rulebook.json) for the item model to show up.
There's no harm to leave that in 1.21.2/3.

Leaving as a draft to look over again tomorrow, though it should be fully functional.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Fourmisain, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request updates the Minecraft version from 1.21.1 to 1.21.4. It addresses changes in the game's API, specifically the removal of GameRules from World and ClientWorld, and changes to Item.Settings and TypedActionResult. The PR also includes an item definition file required for 1.21.4.

Highlights

  • Minecraft Version Update: The Minecraft version has been updated from 1.21.1 to 1.21.4, requiring adjustments to dependencies and code.
  • GameRules Handling: The GameRules are no longer automatically synced, so the daylight cycle is now manually synced using GameruleSyncPayload.
  • Item Settings Update: Item.Settings now requires a RegistryKey to be passed.
  • TypedActionResult Removal: The TypedActionResult class has been removed and replaced with ActionResult.
  • Item Definition: An item definition file (assets/testutils/items/rulebook.json) has been added for the rulebook item to ensure the model shows up in 1.21.4.

Changelog

Click here to see the changelog
  • .minepkg-lock.toml
    • Updated Minecraft version to 1.21.4.
    • Updated fabric version to 0.119.0+1.21.4.mpkg.1.
    • Updated mapping to 1.21.4+build.8.
  • gradle.properties
    • Updated minecraft_version to 1.21.2.
    • Updated yarn_mappings to 1.21.2+build.1.
    • Updated fabric_version to 0.106.1+1.21.2.
    • Updated libgui_version to 12.0.1+1.21.2.
    • Updated minecraft_version_range to >=1.21.2 <=1.21.4.
  • minepkg.toml
    • Updated minecraft requirement to >=1.21.2 <=1.21.4.
  • src/main/java/io/minepkg/testutils/RuleBookGUI.java
    • Removed import of net.minecraft.world.GameRules (line 24).
    • Replaced w.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE) with TestUtilsClient.doDaylightCycle (line 187).
    • Replaced world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE) with TestUtilsClient.doDaylightCycle (line 222).
  • src/main/java/io/minepkg/testutils/RuleBookItem.java
    • Removed import of net.minecraft.item.ItemStack (line 5).
    • Removed import of net.minecraft.util.TypedActionResult (line 10).
    • Replaced TypedActionResult<ItemStack> use(...) with ActionResult use(...) (line 19).
    • Replaced new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand)) with ActionResult.SUCCESS (line 28).
  • src/main/java/io/minepkg/testutils/TestUtils.java
    • Replaced io.minepkg.testutils.network.s2c.WeatherGameruleSyncPayload with io.minepkg.testutils.network.s2c.GameruleSyncPayload (line 7).
    • Added imports for net.minecraft.registry.RegistryKey and net.minecraft.registry.RegistryKeys (lines 17-18).
    • Modified item registration to use RegistryKey (lines 48-52).
    • Replaced broadcastWeatherRuleChange with broadcastRules (lines 101, 106).
    • Replaced WeatherGameruleSyncPayload with GameruleSyncPayload (lines 125, 136).
    • Removed sendWeatherRule and replaced it with sendWeatherRule which uses GameruleSyncPayload (lines 133-137).
  • src/main/java/io/minepkg/testutils/TestUtilsClient.java
    • Added doDaylightCycle boolean (line 13).
    • Replaced WeatherGameruleSyncPayload with GameruleSyncPayload (lines 26-31).
    • Added TestUtilsClient.doDaylightCycle = payload.doDaylightCycle(); (line 30).
  • src/main/java/io/minepkg/testutils/network/s2c/GameruleSyncPayload.java
    • Added new file for GameruleSyncPayload to sync both daylight and weather rules.
  • src/main/java/io/minepkg/testutils/network/s2c/WeatherGameruleSyncPayload.java
    • Removed file.
  • src/main/resources/assets/testutils/items/rulebook.json
    • Added new file for item definition.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Trivia time!

What is the name of the Swedish game developer that created Minecraft?

Click here for the answer
Markus Alexej Persson, also known as Notch, created Minecraft.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the mod to Minecraft version 1.21.4, adapting to API changes and ensuring compatibility. The changes include updating dependencies, adjusting to changes in how GameRules are handled, and providing necessary item definitions. Overall, the changes seem well-structured and address the necessary updates for the new Minecraft version.

Summary of Findings

  • GameRule Synchronization: The pull request correctly addresses the change in GameRules synchronization by manually syncing the daylight cycle along with the weather. This ensures that the client receives the correct game rule states.
  • Item Settings Update: The update to Item.Settings by passing a RegistryKey is correctly implemented, adapting to the API changes in the new Minecraft version.
  • Redundant sendWeatherRule call: The sendWeatherRule method is called before sendOpenBookPacket in RuleBookItem.use. Since sendWeatherRule is now sending all gamerules, it is redundant to call it before opening the book.

Merge Readiness

The pull request appears to be well-structured and addresses the necessary updates for Minecraft version 1.21.4. However, the redundant sendWeatherRule call should be removed for efficiency. Once this is addressed, the pull request should be ready for merging. I am unable to approve this pull request, and other reviewers should review and approve this code before merging.

@Fourmisain
Copy link
Contributor Author

(Renamed sendWeatherCycle -> sendGameRules, broadcastRules -> broadcastGameRules)

@Fourmisain Fourmisain marked this pull request as ready for review March 19, 2025 15:04
@Fourmisain Fourmisain merged commit 3d88ee4 into main Mar 19, 2025
1 check passed
@Fourmisain Fourmisain deleted the 1_21_2 branch March 19, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants