Skip to content

Commit

Permalink
Merge tag '1.2.1+1.19.4' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Estecka committed Mar 2, 2024
2 parents 45e8133 + da2ef99 commit 407b15b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
## 1.1
- Clicking "proceed" on the feature flag warning screen will automatically exit the world, back to the title screen. A reload is no longer triggered.
- "Proceed" on the warning screens can no longer be clicked without ticking the checkbox.

## 1.2
### 1.2.0
- Integration for Cloth Gamerules screen.
### 1.2.1
- Fix Mixin searching for ClotGamerules classes when not installed.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ loader_version=0.15.7
fabric_version=0.91.0+1.20.1

# Mod Properties
mod_version=1.2.0
mod_version=1.2.1
maven_group=tk.estecka.packrulemenus
archives_base_name=packrule-menus

Expand Down
17 changes: 16 additions & 1 deletion src/main/java/tk/estecka/packrulemenus/PackRuleMenus.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package tk.estecka.packrulemenus;

import java.util.Optional;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.world.GameRules;
import tk.estecka.clothgamerules.api.ClothGamerulesScreenFactory;

public class PackRuleMenus
{
static public final Logger LOGGER = LoggerFactory.getLogger("Pack-Rule Menus");
}

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) ));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tk.estecka.packrulemenus.mixin;

import java.util.Collection;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -13,13 +11,11 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.llamalad7.mixinextras.sugar.Local;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.MessageScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.gui.screen.world.EditGameRulesScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.resource.DataConfiguration;
Expand All @@ -32,7 +28,6 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.WorldSavePath;
import net.minecraft.world.GameRules;
import tk.estecka.clothgamerules.api.ClothGamerulesScreenFactory;
import tk.estecka.packrulemenus.GenericWarningScreen;
import tk.estecka.packrulemenus.PackRuleMenus;

Expand All @@ -58,7 +53,8 @@ abstract public class OptionScreenMixin
final GameRules worldRules = server.getOverworld().getGameRules();
adder.add(createButton(
Text.translatable("selectWorld.gameRules"),
() -> CreateGameruleScreen(
() -> PackRuleMenus.CreateGameruleScreen(
this,
worldRules.copy(),
optRules -> optRules.ifPresent(r -> worldRules.setAllValues(r, server))
)
Expand All @@ -76,13 +72,6 @@ abstract public class OptionScreenMixin
));
}
}

private Screen CreateGameruleScreen(GameRules rules, Consumer<Optional<GameRules>> saveConsumer){
if (FabricLoader.getInstance().isModLoaded("cloth-gamerules"))
return ClothGamerulesScreenFactory.CreateScreen(this, rules, saveConsumer);
else
return new EditGameRulesScreen(rules, saveConsumer.andThen( __->RevertScreen() ));
}

private void RevertScreen(){
client.setScreen((OptionsScreen)(Object)this);
Expand Down

0 comments on commit 407b15b

Please sign in to comment.