[1.14] Fix ModMenu buttons clashing with RM buttons on main menu

This commit is contained in:
Jonas Herzig
2019-06-20 18:40:49 +02:00
parent b7136e6d70
commit 481b7b4c9d
2 changed files with 9 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ public class MainMenuHandler extends EventRegistrations {
// Buttons that aren't in a rectangle directly above our space don't need moving
if (button.x + width(button) < gui.width / 2 - 100
|| button.x > gui.width / 2 + 100
|| button.y > gui.height / 4 + 10 + 4 * 24) continue;
|| button.y > gui.height / 4 + 10 + 4 * 24 + 20) continue;
// Move button up to make space for one rows of buttons
// and then move back down by 10 to compensate for the space to the exit button that was already there
int offset = -1 * 24 + 10;

View File

@@ -22,6 +22,7 @@ import net.minecraft.world.chunk.WorldChunk;
//#if MC>=11400
import com.replaymod.core.mixin.AbstractButtonWidgetAccessor;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import java.util.concurrent.CompletableFuture;
//#else
@@ -470,6 +471,13 @@ public class MCVer {
public static void addButton(Screen screen, ButtonWidget button) {
GuiScreenAccessor acc = (GuiScreenAccessor) screen;
//#if MC>=11400
if (screen instanceof TitleScreen && isModLoaded("modmenu")) {
// Since we bypass the usual addButton, we need to manually move our buttons down
// https://github.com/Prospector/ModMenu/blob/eea70ec37581a7229142cf21df795fdacc6a7b4c/src/main/java/io/github/prospector/modmenu/mixin/TitleScreenMixin.java#L42
button.y += 12;
}
//#endif
acc.getButtons().add(button);
//#if MC>=11300
acc.getChildren().add(button);