Skip to content

Commit

Permalink
Fix WindowsDisplay not resetting resizable (#73)
Browse files Browse the repository at this point in the history
* Fix WindowsDisplay not resetting resizable

* Set remap to false for toggleResizable mixin

* Revert remap option

* Update workflow
  • Loading branch information
xchgeax authored Jul 29, 2022
1 parent 6496a2c commit c6b5897
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ on:
jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
with:
workspace: setupDecompWorkspace
secrets: inherit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Requires SpongeMixins mod (https://github.com/GTNewHorizons/SpongeMixins) to wor
* FixHungerOverhaul - Patches unintended mod interaction with Spice Of Life - Carrot Edition
* FixPotionLimit - Support all 256 potion slots by fixing the incorrect signed byte conversions.
* RemoveUpdateChecks - Removes outdated update checks
* FixFullscreenResizable - Fix game window is not resizeable after exiting fullscreen
## Speedups
* SpeedupChunkCoordinatesHashCode - Swaps out the HashCode function for ChunkCoordinates with one that provides better performance with HashSet

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class LoadingConfig {
public boolean fixComponentsPoppingOff;
public boolean thirstyTankContainer;
public boolean fixWorldServerLeakingUnloadedEntities;
public boolean fixFullscreenResizable;

// ASM
public boolean pollutionAsm;
Expand Down Expand Up @@ -109,6 +110,7 @@ public LoadingConfig(File file) {
fixHugeChatKick = config.get("fixes", "fixHugeChatKick", true, "Fix oversized chat message kicking player.").getBoolean();
logHugeChat = config.get("fixes", "logHugeChat", true, "Log oversized chat message to console. WARNING: might create huge log files if this happens very often.").getBoolean();
fixWorldServerLeakingUnloadedEntities = config.get("fixes", "fixWorldServerLeakingUnloadedEntities", true, "Fix WorldServer leaking entities when no players are present in a dimension").getBoolean();
fixFullscreenResizable = config.get("fixes", "fixFullscreenResizable", true, "Fix game window becoming not resizable after toggling fullscrean in any way").getBoolean();

increaseParticleLimit = config.get("tweaks", "increaseParticleLimit", true, "Increase particle limit").getBoolean();
particleLimit = Math.max(Math.min(config.get("tweaks", "particleLimit", 8000, "Particle limit [4000-16000]").getInt(), 16000), 4000);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum Mixins {
FIX_HUGE_CHAT_KICK("minecraft.MixinS02PacketChat", () -> Hodgepodge.config.fixHugeChatKick, TargetedMod.VANILLA),
FIX_WORLD_SERVER_LEAKING_UNLOADED_ENTITIES("minecraft.MixinWorldServerUpdateEntities", () -> Hodgepodge.config.fixWorldServerLeakingUnloadedEntities, TargetedMod.VANILLA),
FIX_ARROW_WRONG_LIGHTING("minecraft.MixinRendererLivingEntity", Side.CLIENT, () -> Hodgepodge.config.fixGlStateBugs, TargetedMod.VANILLA),
FIX_FULLSCREEN_RESIZABLE("minecraft.MixinMinecraft", Side.CLIENT, () -> Hodgepodge.config.fixFullscreenResizable, TargetedMod.VANILLA),

// Potentially obsolete vanilla fixes
GRASS_GET_BLOCK_FIX("minecraft.MixinBlockGrass", () -> Hodgepodge.config.fixVanillaUnprotectedGetBlock, TargetedMod.VANILLA),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.mitchej123.hodgepodge.mixins.minecraft;

import net.minecraft.client.Minecraft;
import net.minecraft.util.Util;
import org.lwjgl.opengl.Display;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Minecraft.class)
public class MixinMinecraft {

@Shadow
private boolean fullscreen;

/*
* LWJGL bug https://bugs.mojang.com/browse/MC-68754?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&showAll=true
*/
@Inject(method = "toggleFullscreen", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setVSyncEnabled(Z)V"))
private void toggleResizable(CallbackInfo ci) {
if (!this.fullscreen && (Util.getOSType() == Util.EnumOS.WINDOWS)) {
Display.setResizable(false);
Display.setResizable(true);
}
}
}

0 comments on commit c6b5897

Please sign in to comment.