Update preprocessor and replace 1.13.2 subproject with 1.14.4-forge
The new preprocessor version brings first-party support for fabric, in particular for automatically fetching mappings loom and for automatically remapping between MC versions via intermediary mappings. This will come in handy when updating to 1.15. It also supports automatic remapping between fabric and forge on the same MC version (by going mcp<->srg<->mojang<->intermediary<->yarn). Therefore this commit replaces the previous 1.13.2 (forge) subproject with a 1.14.4-forge one. Instead of manually providing full mappings for 1.14.4-fabric to 1.13.2-forge and partial (classes) for 1.13.2-forge to 1.12.2-forge, we now only need partial (classes) for 1.12.2-forge to 1.14.4-forge and preprocessor will take care of the forge to fabric step (in fact, our mapping file for that is currently completely empty). In an attempt to write an IDE (IntelliJ) plugin for quicker and easier working with the preprocessor (e.g. immediately mapping single files from within the IDE, jumping between different versions for the same file), the preprocessor gradle plugin declaration now requires you to explicitly specify variables in the common.gradle and the overall relationship between projects in the build.gradle (latter is required anyway, so the plugin can know where it should map between forge and fabric and which subprojects are which versions). Since that necessitated some changes to the build.gradle file, I took the opportunity to convert it to Kotlin. As such we now also use Gradle's newer plugin-block with the pluginManagement-block instead of manually declaring buildScript (not for the common.gradle though), which imo is nicer anyway and comes with various advantages (see gradle docs). There were also some remapping bugs fixed and some new ones introduced (e.g. manually declared inner class mappings seem to no longer function properly under certain conditions). There's also support for remapping Kotlin now. Just saying.
This commit is contained in:
@@ -3,21 +3,24 @@ package com.replaymod.replay.handler;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
//#if MC>=11400
|
||||
//#if FABRIC>=1
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
//#endif
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -36,14 +39,14 @@ public class GuiHandler extends EventRegistrations {
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//#if FABRIC>=1
|
||||
{ on(InitScreenCallback.EVENT, this::injectIntoIngameMenu); }
|
||||
private void injectIntoIngameMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ List<GuiButton> buttonList = getButtonList(event);
|
||||
//$$ Screen guiScreen = getGui(event);
|
||||
//$$ List<Widget> buttonList = getButtonList(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof GameMenuScreen)) {
|
||||
return;
|
||||
@@ -163,13 +166,13 @@ public class GuiHandler extends EventRegistrations {
|
||||
.forEach(button -> button.y -= 24);
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//#if FABRIC>=1
|
||||
{ on(InitScreenCallback.EVENT, this::ensureReplayStopped); }
|
||||
private void ensureReplayStopped(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void ensureReplayStopped(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ Screen guiScreen = getGui(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof TitleScreen || guiScreen instanceof MultiplayerScreen)) {
|
||||
return;
|
||||
@@ -190,18 +193,18 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//#if FABRIC>=1
|
||||
{ on(InitScreenCallback.EVENT, this::injectIntoMainMenu); }
|
||||
private void injectIntoMainMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ Screen guiScreen = getGui(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof TitleScreen)) {
|
||||
return;
|
||||
}
|
||||
ButtonWidget button = new InjectedButton(
|
||||
InjectedButton button = new InjectedButton(
|
||||
guiScreen,
|
||||
BUTTON_REPLAY_VIEWER,
|
||||
guiScreen.width / 2 - 100,
|
||||
@@ -243,7 +246,13 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
}
|
||||
|
||||
public static class InjectedButton extends ButtonWidget {
|
||||
public static class InjectedButton extends
|
||||
//#if MC>=11400
|
||||
ButtonWidget
|
||||
//#else
|
||||
//$$ GuiButton
|
||||
//#endif
|
||||
{
|
||||
public final Screen guiScreen;
|
||||
public final int id;
|
||||
private Consumer<InjectedButton> onClick;
|
||||
|
||||
Reference in New Issue
Block a user