mirror of
https://github.com/PuzzleMC/Puzzle.git
synced 2025-12-15 19:35:10 +01:00
stonecutter: support Fabric 1.20.1
This commit is contained in:
@@ -262,4 +262,8 @@ stonecutter {
|
||||
direction = eval(current.version, ">=1.21.5")
|
||||
replace("SimpleTexture", "ReloadableTexture")
|
||||
}
|
||||
replacements.string {
|
||||
direction = eval(current.version, ">=1.21")
|
||||
replace("new ResourceLocation", "ResourceLocation.fromNamespaceAndPath")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ package net.puzzlemc.gui.mixin;
|
||||
|
||||
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.minecraft.client.gui.components.SpriteIconButton;
|
||||
import net.minecraft.client.gui.layouts.HeaderAndFooterLayout;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.puzzlemc.core.config.PuzzleConfig;
|
||||
import net.puzzlemc.gui.PuzzleGui;
|
||||
import net.puzzlemc.gui.screen.PuzzleOptionsScreen;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -20,16 +17,32 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
//? if >= 1.21 {
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
||||
import net.minecraft.client.gui.components.SpriteIconButton;
|
||||
import net.minecraft.client.gui.layouts.HeaderAndFooterLayout;
|
||||
import net.puzzlemc.gui.PuzzleGui;
|
||||
//?} else {
|
||||
/*import net.minecraft.client.gui.screens.OptionsScreen;
|
||||
import net.minecraft.client.gui.components.TextAndImageButton;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import static net.puzzlemc.core.PuzzleCore.MOD_ID;
|
||||
*///?}
|
||||
|
||||
@Mixin(OptionsScreen.class)
|
||||
public abstract class MixinOptionsScreen extends Screen {
|
||||
private MixinOptionsScreen(Component title) {super(title);}
|
||||
|
||||
//? if >= 1.21 {
|
||||
@Shadow @Final private HeaderAndFooterLayout layout;
|
||||
@Unique
|
||||
SpriteIconButton puzzle$button = SpriteIconButton.builder(Component.translatable("puzzle.screen.title"), (buttonWidget) ->
|
||||
(Objects.requireNonNull(this.minecraft)).setScreen(new PuzzleOptionsScreen(this)), true)
|
||||
.size(20, 20).sprite(PuzzleGui.PUZZLE_BUTTON, 20, 20).build();
|
||||
|
||||
private MixinOptionsScreen(Component title) {super(title);}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
public void puzzle$onInit(CallbackInfo ci) {
|
||||
if (PuzzleConfig.enablePuzzleButton) {
|
||||
@@ -52,4 +65,22 @@ public abstract class MixinOptionsScreen extends Screen {
|
||||
}
|
||||
puzzle$button.setPosition(this.width / 2 - 178 + i, layout.getY() + layout.getFooterHeight() - 4);
|
||||
}
|
||||
//?} else {
|
||||
/*@Unique TextAndImageButton puzzle$button = TextAndImageButton.builder(Component.translatable("midnightlib.overview.title"), ResourceLocation.fromNamespaceAndPath(MOD_ID, "icon/button.png"),
|
||||
button -> Objects.requireNonNull(minecraft).setScreen(new PuzzleOptionsScreen(this))).textureSize(19, 19).usedTextureSize(16, 16).offset(-2, 0).build();
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
private void midnightlib$init(CallbackInfo ci) {
|
||||
if (PuzzleConfig.enablePuzzleButton) {
|
||||
puzzle$button.setWidth(20);
|
||||
int i = 0;
|
||||
if (PlatformFunctions.isModLoaded("lod")) {
|
||||
i = i + 358;
|
||||
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.FALSE)) i = i - 25;
|
||||
}
|
||||
puzzle$button.setPosition(this.width / 2 - 178 + i, this.height / 6 - 12);
|
||||
this.addRenderableWidget(puzzle$button);
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class PuzzleOptionListWidget extends MidnightConfigListWidget {
|
||||
var entry = new ButtonEntry(buttons, text, info);
|
||||
this.addEntry(entry);
|
||||
}
|
||||
public void renderWidget(GuiGraphics context, int mouseX, int mouseY, float delta) {
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
public void /*? if >= 1.21 {*/ renderWidget /*?} else {*/ /*renderList*/ /*?}*/(GuiGraphics context, int mouseX, int mouseY, float delta) {
|
||||
super./*? if >= 1.21 {*/ renderWidget /*?} else {*/ /*renderList*/ /*?}*/(context, mouseX, mouseY, delta);
|
||||
ButtonEntry e = this.getHovered();
|
||||
if (minecraft.screen instanceof PuzzleOptionsScreen page && e != null && !e.buttons.isEmpty() &&
|
||||
e.text.getContents() instanceof TranslatableContents content) {
|
||||
|
||||
@@ -48,8 +48,8 @@ import static net.puzzlemc.core.PuzzleCore.LOGGER;
|
||||
import static net.puzzlemc.core.PuzzleCore.MOD_ID;
|
||||
|
||||
public class PuzzleSplashScreen {
|
||||
public static final ResourceLocation LOGO = ResourceLocation.withDefaultNamespace("textures/gui/title/mojangstudios.png");
|
||||
public static final ResourceLocation BACKGROUND = ResourceLocation.withDefaultNamespace("puzzle/splash_background.png");
|
||||
public static final ResourceLocation LOGO = ResourceLocation.fromNamespaceAndPath("minecraft", "textures/gui/title/mojangstudios.png");
|
||||
public static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("minecraft", "puzzle/splash_background.png");
|
||||
public static File CONFIG_PATH = new File(String.valueOf(PlatformFunctions.getConfigDirectory().resolve(".puzzle_cache")));
|
||||
public static Path LOGO_TEXTURE = Paths.get(CONFIG_PATH + "/mojangstudios.png");
|
||||
public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png");
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
|
||||
"depends": {
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.21"
|
||||
"minecraft": ">=1.20"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 152 B |
Reference in New Issue
Block a user