Skip to content

Reusable module templates#11205

Open
Thodor12 wants to merge 7 commits intoversion/1.21from
feature/module_templates
Open

Reusable module templates#11205
Thodor12 wants to merge 7 commits intoversion/1.21from
feature/module_templates

Conversation

@Thodor12
Copy link
Copy Markdown
Contributor

@Thodor12 Thodor12 commented Sep 23, 2025

Changes proposed in this pull request

  • Dependent on Some necessary de-fuckery of the window logic #11203
  • Introduces a template system that allows a player to configure templates or presets of configuration on certain modules per type of building, this works on the following modules:
    • Minimum stock
    • Item lists
    • Entity lists
    • Restaurant menu
    • Settings
  • Templates can be accessed by clicking a new tab on the right of the window, this tab will only appear for modules that implement the new ITemplateModule
  • A player can create new templates by filling the input and clicking the add icon, which will create a new template based on the current configuration of the module
  • Other buildings can then opt to "use" the template, which will overwrite it's configuration based on the template
  • Any building may overwrite a template by clicking on save, which will automatically synchronize the configuration across all tracking buildings
  • Templates can be removed by pressing the X
2025-09-23 18_51_55-Window 2025-09-23 18_50_57-Window

Implementation details

  • Two new interfaces must be implemented on both the SERVER and CLIENT: ITemplateModule and ITemplateModuleView
  • This only requires both sides to implement the getTemplateStorageId() method, the values that the server and client return must be identical!!
  • The module must already implement IPersistentModule, if not you must implement the (de)serialize methods
  • Nothing else is required for starters, however it can be further customized
    • The server can (and should) implement the resetTemplateAssignment() method on places where the configuration is modified, this is so that if the building is actively tracking a template, upon modification of data it'll automatically untrack the template, meaning that if another module syncs, the changes in this building won't be wiped again
    • The client should overwrite the getDescriptionText(CompoundTag data) method, this is to implement a more appropriate description text for the current module, otherwise it'll say "No description" on the second line in the window
  • General note: This implementation only works on modules where configuration must be non unique

Testing

  • Yes I tested this before submitting it.
  • I also did a multiplayer test.

Review please

# Conflicts:
#	src/main/java/com/minecolonies/core/client/gui/AbstractModuleWindow.java
#	src/main/java/com/minecolonies/core/client/gui/townhall/WindowTownHallCantCreateColony.java
#	src/main/java/com/minecolonies/core/client/gui/townhall/WindowTownHallColonyManage.java
#	src/main/java/com/minecolonies/core/client/gui/townhall/WindowTownHallDeleteAbandonColony.java
#	src/main/java/com/minecolonies/core/colony/buildings/moduleviews/MinimumStockModuleView.java
@Thodor12 Thodor12 changed the title Reusable module templates Draft: Reusable module templates Sep 23, 2025
@Thodor12 Thodor12 changed the title Draft: Reusable module templates Reusable module templates Sep 23, 2025
@Thodor12 Thodor12 marked this pull request as draft September 23, 2025 17:00
# Conflicts:
#	src/main/java/com/minecolonies/core/client/gui/AbstractBuildingMainWindow.java
#	src/main/java/com/minecolonies/core/client/gui/AbstractBuildingWindow.java
#	src/main/java/com/minecolonies/core/client/gui/AbstractModuleWindow.java
#	src/main/java/com/minecolonies/core/client/gui/WindowClipBoard.java
#	src/main/java/com/minecolonies/core/client/gui/WindowPostBoxMain.java
#	src/main/java/com/minecolonies/core/client/gui/modules/ConnectionModuleWindow.java
#	src/main/java/com/minecolonies/core/client/gui/modules/MinimumStockModuleWindow.java
#	src/main/java/com/minecolonies/core/client/gui/modules/WindowListRecipes.java
#	src/main/java/com/minecolonies/core/client/gui/townhall/WindowAlliancePage.java
#	src/main/java/com/minecolonies/core/client/gui/townhall/WindowPermissionsPage.java
#	src/main/java/com/minecolonies/core/colony/buildings/moduleviews/BuildingResourcesModuleView.java
#	src/main/java/com/minecolonies/core/colony/buildings/moduleviews/ColonyConnectionModuleView.java
#	src/main/java/com/minecolonies/core/colony/buildings/moduleviews/MinimumStockModuleView.java
@Thodor12 Thodor12 marked this pull request as ready for review November 20, 2025 09:58
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.

1 participant