-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The menu buttons are back to their original position by default. - Added an option to move or remove the menu buttons from the Options screen via ModMenu. - The menu buttons are now accessible via Mod Menu.
- Loading branch information
Showing
22 changed files
with
669 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ classes/ | |
.settings/ | ||
.vscode/ | ||
bin/ | ||
.factorypath | ||
.classpath | ||
.project | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
# Data-Pack / Game-Rule Menus | ||
|
||
Makes the titular menus accessible from the pause menu in singleplayer worlds. | ||
Takes the titular menus from the World-Creation menu, and makes them available from already created singleplayer worlds. | ||
This provides a more user-friendly alternative to the vanilla `/gamerule` and `/datapack` commands. | ||
|
||
Like those commands, the menus will only be accessible in worlds with cheats/commands enabled. | ||
|
||
Unlike the vanilla `/datapack` command, the Datapack menu from this mod can be used to toggle experimental features! | ||
|
||
|
||
## Word of caution: Datapacks | ||
|
||
Minecraft's own built-in datapacks are not "just" datapacks, and require special handling. A warning screen will be shown whenever you attempt to toggle any of these, and give you the option to back out. | ||
Some types of datapacks require a world restart to fully take effect. | ||
Whenever possible, the mod will show a warning after toggling one of them, and offer you the option to either back-out, or exit the world gracefully. | ||
However, some type of packs cannot be detected, and no warning will be displayed for those. | ||
|
||
### Registry Packs | ||
The new type of packs introduced in MC 1.21. Packs that add data to registries (painting variants, etc), **are not detected by the mod**, but still require a world restart to fully take effects. | ||
|
||
### Experimental Feature | ||
When packs that include experimental features (such as bundles) are toggled, the approriate feature flag will be toggled on the world. | ||
Toggling these packs may cause some errors in the log, but those are benign so long as you restart the world immediately afterward. This behaviour is no different from using the `/datapack` command. | ||
|
||
However, **unlike regular datapacks, those won't fully take effect until the world is restarted.** After you confirm the changes, the world will immediately exit. | ||
### Experimental Features | ||
Packs that include experimental features (such as bundles) are properly detected by the mod. Toggling them will also toggle the corresponding feature-flag on the world, and exit the world gracefully. | ||
|
||
### Vanilla Datapack | ||
The Vanilla datapack can technically be disabled, but the uses cases for this are very marginal. Doing so will break worlds most of the times, so you probably don't want to do it. | ||
The Vanilla datapack can technically be disabled, but you probably don't want to do it. | ||
Doing so will usually break worlds unless you know exactly what you are doing. | ||
An additional warning screen will appear when trying to disable this pack. | ||
|
||
If you can't load a world after having disabled the Vanilla datapack, loading it in Safe Mode should be able to restore it. | ||
If you can't load a world after having disabled the Vanilla datapack, loading it in Safe Mode should be able to restore it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/fr/estecka/packrulemenus/GameruleHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package fr.estecka.packrulemenus; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Consumer; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.world.EditGameRulesScreen; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.server.integrated.IntegratedServer; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.world.GameRules; | ||
import tk.estecka.clothgamerules.api.ClothGamerulesScreenFactory; | ||
|
||
public class GameruleHandler | ||
{ | ||
private final Screen parent; | ||
private final IntegratedServer server; | ||
private final MinecraftClient client = MinecraftClient.getInstance(); | ||
|
||
public GameruleHandler(Screen parent, IntegratedServer server){ | ||
this.parent = parent; | ||
this.server = server; | ||
} | ||
|
||
public ButtonWidget CreateButton() { | ||
final GameRules worldRules = server.getOverworld().getGameRules(); | ||
|
||
return ButtonWidget.builder( | ||
Text.translatable("selectWorld.gameRules"), | ||
__ -> client.setScreen( CreateGameruleScreen(parent, worldRules.copy(), optRules -> optRules.ifPresent(r -> worldRules.setAllValues(r, server))) ) | ||
) | ||
.build() | ||
; | ||
} | ||
|
||
|
||
static public Screen CreateGameruleScreen(Screen parent, GameRules rules, Consumer<Optional<GameRules>> saveConsumer){ | ||
if (FabricLoader.getInstance().isModLoaded("cloth-gamerules")) | ||
return ClothGamerulesScreenFactory.CreateScreen(parent, rules, saveConsumer); | ||
else | ||
return new EditGameRulesScreen(rules, saveConsumer.andThen( __->MinecraftClient.getInstance().setScreen(parent) )); | ||
} | ||
} |
Oops, something went wrong.