Only preserve window position if a non-default width/height was given
Fixes #103 (in next release)
This commit is contained in:
parent
962b843199
commit
0d901c6281
|
|
@ -1,8 +1,7 @@
|
||||||
package org.embeddedt.modernfix.forge.mixin.bugfix.preserve_early_window_pos;
|
package org.embeddedt.modernfix.forge.mixin.bugfix.preserve_early_window_pos;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Monitor;
|
import com.mojang.blaze3d.platform.*;
|
||||||
import com.mojang.blaze3d.platform.ScreenManager;
|
import net.minecraft.client.Minecraft;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
import net.minecraftforge.fml.loading.progress.EarlyProgressVisualization;
|
import net.minecraftforge.fml.loading.progress.EarlyProgressVisualization;
|
||||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
|
@ -35,19 +34,26 @@ public class WindowMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getEarlyProgressVisualizer() {
|
private Object getEarlyProgressVisualizer() {
|
||||||
|
Minecraft client = Minecraft.getInstance();
|
||||||
if(VISUALIZER == null || this.fullscreen)
|
if(VISUALIZER == null || this.fullscreen)
|
||||||
return null;
|
return null;
|
||||||
Object o = ObfuscationReflectionHelper.getPrivateValue(EarlyProgressVisualization.class, EarlyProgressVisualization.INSTANCE, "visualization");
|
Object o = ObfuscationReflectionHelper.getPrivateValue(EarlyProgressVisualization.class, EarlyProgressVisualization.INSTANCE, "visualization");
|
||||||
return VISUALIZER.isAssignableFrom(o.getClass()) ? o : null;
|
return VISUALIZER.isAssignableFrom(o.getClass()) ? o : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean defaultDisplayData(DisplayData arg3) {
|
||||||
|
return arg3.width == 854 && arg3.height == 480 && !arg3.isFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a null monitor if not in fullscreen and the visualizer is present, so that the code grabs the
|
* Return a null monitor if not in fullscreen and the visualizer is present, so that the code grabs the
|
||||||
* original X/Y position of the window.
|
* original X/Y position of the window.
|
||||||
*/
|
*/
|
||||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/ScreenManager;getMonitor(J)Lcom/mojang/blaze3d/platform/Monitor;"))
|
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/ScreenManager;getMonitor(J)Lcom/mojang/blaze3d/platform/Monitor;"))
|
||||||
private Monitor getMonitor(ScreenManager manager, long id) {
|
private Monitor getMonitor(ScreenManager manager, long id, WindowEventHandler arg, ScreenManager arg2, DisplayData arg3) {
|
||||||
return getEarlyProgressVisualizer() != null ? null : manager.getMonitor(id);
|
if(defaultDisplayData(arg3) && getEarlyProgressVisualizer() != null)
|
||||||
|
return null;
|
||||||
|
return manager.getMonitor(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,9 +61,9 @@ public class WindowMixin {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/loading/progress/EarlyProgressVisualization;handOffWindow(Ljava/util/function/IntSupplier;Ljava/util/function/IntSupplier;Ljava/util/function/Supplier;Ljava/util/function/LongSupplier;)J"), require = 0)
|
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/loading/progress/EarlyProgressVisualization;handOffWindow(Ljava/util/function/IntSupplier;Ljava/util/function/IntSupplier;Ljava/util/function/Supplier;Ljava/util/function/LongSupplier;)J"), require = 0)
|
||||||
private long performHandoff(EarlyProgressVisualization instance, IntSupplier width, IntSupplier height, Supplier<String> title, LongSupplier monitor) {
|
private long performHandoff(EarlyProgressVisualization instance, IntSupplier width, IntSupplier height, Supplier<String> title, LongSupplier monitor, WindowEventHandler arg, ScreenManager arg2, DisplayData arg3) {
|
||||||
Object visualizer = getEarlyProgressVisualizer();
|
Object visualizer = getEarlyProgressVisualizer();
|
||||||
if(visualizer != null) {
|
if(visualizer != null && defaultDisplayData(arg3)) {
|
||||||
long windowId = ObfuscationReflectionHelper.<Long, Object>getPrivateValue((Class<? super Object>)visualizer.getClass(), visualizer, "window");
|
long windowId = ObfuscationReflectionHelper.<Long, Object>getPrivateValue((Class<? super Object>)visualizer.getClass(), visualizer, "window");
|
||||||
int[] w = new int[1];
|
int[] w = new int[1];
|
||||||
int[] h = new int[1];
|
int[] h = new int[1];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user