-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data pack configuration while loaded in world
- Loading branch information
1 parent
6670a9d
commit 2801ad0
Showing
3 changed files
with
41 additions
and
91 deletions.
There are no files selected for viewing
90 changes: 0 additions & 90 deletions
90
src/main/java/ml/unbreakinggold/datapackinstaller/mixin/EditWorldScreenMixin.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/main/java/ml/unbreakinggold/datapackinstaller/mixin/GameMenuScreenMixin.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,40 @@ | ||
package ml.unbreakinggold.datapackinstaller.mixin; | ||
|
||
import ml.unbreakinggold.datapackinstaller.client.DatapackInstallerClient; | ||
import net.minecraft.client.gui.screen.GameMenuScreen; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.pack.PackScreen; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.client.gui.widget.GridWidget; | ||
import net.minecraft.resource.ResourcePackManager; | ||
import net.minecraft.text.Text; | ||
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; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import java.util.function.Supplier; | ||
|
||
@Mixin(GameMenuScreen.class) | ||
public abstract class GameMenuScreenMixin extends Screen { | ||
@Shadow private ButtonWidget createButton(Text text, Supplier<Screen> screenSupplier) { return null; }; | ||
@Unique private static final Text DATA_PACK_TEXT = Text.translatable("dataPack.title"); | ||
|
||
private GameMenuScreenMixin(Text title) { | ||
super(title); | ||
} | ||
|
||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isInSingleplayer()Z"), method = "initWidgets", locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void onInitWidgets(CallbackInfo ci, GridWidget gridWidget, GridWidget.Adder adder) { | ||
if (!this.client.isIntegratedServerRunning() || this.client.getServer().isRemote()) return; | ||
|
||
adder.add(this.createButton(DATA_PACK_TEXT, () -> { | ||
ResourcePackManager dataPackManager = this.client.getServer().getDataPackManager(); | ||
|
||
return new PackScreen(dataPackManager, (manager) -> {}, DatapackInstallerClient.MAIN_PATH, DATA_PACK_TEXT); | ||
})); | ||
} | ||
} |
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