Skip to content

refactor: made jobs code more consistent, added ItemProcessingJobEvent for external usage#1490

Merged
klikli-dev merged 3 commits intoklikli-dev:version/1.21.1from
antessial:job_refactoring
Mar 9, 2026
Merged

refactor: made jobs code more consistent, added ItemProcessingJobEvent for external usage#1490
klikli-dev merged 3 commits intoklikli-dev:version/1.21.1from
antessial:job_refactoring

Conversation

@antessial
Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @antessial, 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!

This pull request focuses on enhancing code consistency and maintainability within the job system. It introduces a new event class to serve as a common base for item-processing jobs, thereby abstracting shared logic and reducing redundancy. Additionally, it refactors weather and time manipulation jobs to use more standardized and efficient methods, leading to a cleaner and more unified codebase for spirit job functionalities.

Highlights

  • Code Consistency for Job Events: Introduced a new base class, ItemProcessingJobEvent, to centralize common properties and methods for item-processing job events (Crusher, Crystallizer, Smelter, Trader), significantly reducing code duplication and improving maintainability.
  • Weather Job Refactoring: Refactored weather-changing jobs (ClearWeatherJob, RainWeatherJob, ThunderWeatherJob) to utilize the ServerLevel.setWeatherParameters method, streamlining weather manipulation logic and enhancing consistency across these jobs.
  • Time Job Refactoring: Improved time-changing jobs (DayTimeJob, NightTimeJob) by introducing a shared helper method getNearestDayTime in ChangeTimeJob, making time calculations more robust and consistent.
  • Version Update: The mod version in gradle.properties has been updated from 1.201.0 to 1.205.0.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • gradle.properties
    • Updated mod version to 1.205.0.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/ChangeTimeJob.java
    • Added DAY_LENGTH constant.
    • Introduced getNearestDayTime protected helper method for calculating nearest day time.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/ChangeWeatherJob.java
    • Deprecated the getDuration method.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/ClearWeatherJob.java
    • Updated import from ServerLevelData to ServerLevel.
    • Refactored changeWeather to use ServerLevel.setWeatherParameters for clearing weather.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/CrusherJob.java
    • Imported ItemProcessingJobEvent.
    • Removed EntityEvent import.
    • Refactored CrusherJobEvent to extend ItemProcessingJobEvent and simplified its constructor.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/CrystallizerJob.java
    • Imported ItemProcessingJobEvent.
    • Removed EntityEvent import.
    • Refactored CrystallizerJobEvent to extend ItemProcessingJobEvent and simplified its constructor.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/DayTimeJob.java
    • Added TIME_DAWN constant.
    • Updated getNewTime to use the new getNearestDayTime helper method from ChangeTimeJob.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/NightTimeJob.java
    • Added TIME_NIGHTFALL constant.
    • Updated getNewTime to use the new getNearestDayTime helper method from ChangeTimeJob.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/RainWeatherJob.java
    • Simplified changeWeather to directly use RAIN_DURATION with setWeatherParameters.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/SmelterJob.java
    • Imported ItemProcessingJobEvent.
    • Removed EntityEvent import.
    • Refactored SmelterJobEvent to extend ItemProcessingJobEvent and simplified its constructor.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/ThunderWeatherJob.java
    • Updated import from ServerLevelData to ServerLevel.
    • Added THUNDER_DURATION constant.
    • Refactored changeWeather to use ServerLevel.setWeatherParameters for setting thunder weather.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/TraderJob.java
    • Imported ItemProcessingJobEvent.
    • Removed EntityEvent import.
    • Refactored TraderJobEvent to extend ItemProcessingJobEvent and simplified its constructor.
  • src/main/java/com/klikli_dev/occultism/common/entity/job/event/ItemProcessingJobEvent.java
    • Added new class ItemProcessingJobEvent as a base for item processing job events, including input and result item stacks.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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
Copy Markdown
Contributor

@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

This pull request is a good refactoring effort to improve code consistency and reduce duplication. The introduction of ItemProcessingJobEvent to consolidate similar event classes is a great change. The weather and time job classes are also simplified.

However, I've found a critical bug in the new time calculation logic that would cause incorrect behavior for some rituals. I've also pointed out a minor issue regarding file formatting conventions. Please see the detailed comments for suggestions.

Comment thread src/main/java/com/klikli_dev/occultism/common/entity/job/ChangeTimeJob.java Outdated
antessial and others added 2 commits February 23, 2026 10:53
…eTimeJob.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…/ItemProcessingJobEvent.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
public static class CrusherJobEvent extends EntityEvent {
private ItemStack input;
private ItemStack result;
public static class CrusherJobEvent extends ItemProcessingJobEvent {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a benefit of each spirit having a different subclass?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Everything can just throw the same event and consumers(like ocultas) will only need to catch a single event which makes it quite easy. Maybe we can add job type field instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think there's much benefit, but I thought of backward compatibility in case other mods, such as Ars Ocultas, depend on these events

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It should be fine for me. I can create a fix and release it immediately. not sure if there are other consumers though

@klikli-dev
Copy link
Copy Markdown
Owner

@antessial is this ready to merge from your point of view?
@dphaldes are your points addressed too?

@antessial
Copy link
Copy Markdown
Contributor Author

antessial commented Mar 3, 2026

@antessial is this ready to merge from your point of view?

I'd merge this as-is, just in case there are other consumers

@dphaldes
Copy link
Copy Markdown
Contributor

dphaldes commented Mar 4, 2026

@dphaldes are your points addressed too?

For now yes.

@klikli-dev klikli-dev merged commit 8fe9f43 into klikli-dev:version/1.21.1 Mar 9, 2026
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.

3 participants