Skip to content

Commit edfcf97

Browse files
committed
Fix #1 , again
1 parent b8e8cd3 commit edfcf97

8 files changed

Lines changed: 34 additions & 26 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ show_testing_output = false
1818

1919
# Mod Information
2020
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
21-
mod_version = 1.0.2
21+
mod_version = 1.0.3
2222
root_package = com.clear
2323
mod_id = clearmybackground
2424
mod_name = Clear My Background

src/main/java/com/clear/clearmybackground/ClearMyBackground.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
)
1717
public class ClearMyBackground {
1818
public static final Logger LOGGER = LogManager.getLogger();
19-
public static boolean FluxLoadingLoaded = false;
19+
public static boolean GAME_LOADING_DONE = false;
20+
public static boolean FLUX_LOADING_LOADED = false;
2021

2122
@Mod.EventHandler
2223
public void postInit(FMLPostInitializationEvent event) {
23-
FluxLoadingLoaded = Loader.isModLoaded("fluxloading");
24+
GAME_LOADING_DONE = true;
25+
FLUX_LOADING_LOADED = Loader.isModLoaded("fluxloading");
2426
}
2527
}

src/main/java/com/clear/clearmybackground/ClientHelper.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import com.clear.clearmybackground.mixin.early.GuiMainMenuAccessor;
44
import com.clear.clearmybackground.mixininterface.IGuiMainMenuMixin;
55
import net.minecraft.client.Minecraft;
6-
import net.minecraft.client.gui.Gui;
7-
import net.minecraft.client.gui.GuiMainMenu;
8-
import net.minecraft.client.gui.ScaledResolution;
6+
import net.minecraft.client.gui.*;
97
import net.minecraft.client.renderer.GlStateManager;
108
import net.minecraft.util.ResourceLocation;
9+
import net.minecraftforge.fml.client.GuiNotification;
1110
import org.lwjgl.opengl.GL11;
1211

1312
import javax.annotation.Nonnull;
13+
import javax.annotation.Nullable;
1414

1515
public class ClientHelper {
1616

@@ -45,11 +45,13 @@ public static void scissor(int screenX, int screenY, int boxWidth, int boxHeight
4545
private static final ResourceLocation INWORLD_HEADER_SEPARATOR = new ResourceLocation(Tags.MOD_ID, "textures/gui/inworld_header_separator.png");
4646
private static final ResourceLocation INWORLD_FOOTER_SEPARATOR = new ResourceLocation(Tags.MOD_ID, "textures/gui/inworld_footer_separator.png");
4747

48-
public static void renderWorldBackground(@Nonnull Minecraft mc, int width, int height) {
48+
public static boolean renderWorldBackground(@Nullable GuiScreen screen, @Nonnull Minecraft mc, int width, int height) {
49+
if (!shouldModifyBG(screen)) return false;
4950
if (mc.world == null) {
5051
renderPanorama(mc);
5152
}
5253
renderMenuBackground(mc, width, height);
54+
return true;
5355
}
5456

5557
private static void renderMenuBackground(@Nonnull Minecraft mc, int width, int height) {
@@ -114,4 +116,14 @@ public static void renderListBackground(@Nonnull Minecraft mc, int left, int top
114116
if (blend) GlStateManager.enableBlend();
115117
else GlStateManager.disableBlend();
116118
}
119+
120+
private static boolean shouldModifyBG(@Nullable GuiScreen screen) {
121+
if (!ClearMyBackground.GAME_LOADING_DONE || screen == null) return false;
122+
if (ClearMyBackground.FLUX_LOADING_LOADED &&
123+
(screen instanceof GuiScreenWorking || screen instanceof GuiDownloadTerrain)
124+
) return false;
125+
//noinspection RedundantIfStatement
126+
if (screen instanceof GuiNotification) return false;
127+
return true;
128+
}
117129
}

src/main/java/com/clear/clearmybackground/mixin/early/GuiClickableScrolledSelectionListProxyMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
@Mixin(GuiClickableScrolledSelectionListProxy.class)
1212
public class GuiClickableScrolledSelectionListProxyMixin {
1313
@Inject(method = "drawSelectionBox", at = @At("HEAD"))
14-
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
14+
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
1515
GuiClickableScrolledSelectionListProxy self = (GuiClickableScrolledSelectionListProxy) (Object) this;
1616
ClientHelper.scissor(self.left, self.top, self.right - self.left, self.bottom - self.top);
1717
}
1818

1919
@Inject(method = "drawSelectionBox", at = @At("RETURN"))
20-
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
20+
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
2121
GL11.glDisable(GL11.GL_SCISSOR_TEST);
2222
}
2323
}

src/main/java/com/clear/clearmybackground/mixin/early/GuiScreenMixin.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package com.clear.clearmybackground.mixin.early;
22

3-
import com.clear.clearmybackground.ClearMyBackground;
43
import com.clear.clearmybackground.ClientHelper;
54
import net.minecraft.client.Minecraft;
6-
import net.minecraft.client.gui.GuiDownloadTerrain;
75
import net.minecraft.client.gui.GuiScreen;
8-
import net.minecraft.client.gui.GuiScreenWorking;
9-
import net.minecraftforge.fml.client.GuiOldSaveLoadConfirm;
106
import org.spongepowered.asm.mixin.Mixin;
117
import org.spongepowered.asm.mixin.Shadow;
128
import org.spongepowered.asm.mixin.injection.At;
@@ -29,18 +25,16 @@ public class GuiScreenMixin {
2925
@Inject(method = "drawWorldBackground", at = @At("HEAD"), cancellable = true)
3026
public void drawWorldBackground(int tint, @Nonnull CallbackInfo ci) {
3127
GuiScreen self = (GuiScreen) (Object) this;
32-
if (ClearMyBackground.FluxLoadingLoaded && (self instanceof GuiScreenWorking || self instanceof GuiDownloadTerrain)) return;
33-
if (self instanceof GuiOldSaveLoadConfirm) return;
34-
ClientHelper.renderWorldBackground(this.mc,this.width, this.height);
35-
ci.cancel();
28+
if (ClientHelper.renderWorldBackground(self, this.mc, this.width, this.height)) {
29+
ci.cancel();
30+
}
3631
}
3732

3833
@Inject(method = "drawBackground", at = @At("HEAD"), cancellable = true)
3934
public void drawBackground(int tint, @Nonnull CallbackInfo ci) {
4035
GuiScreen self = (GuiScreen) (Object) this;
41-
if (ClearMyBackground.FluxLoadingLoaded && (self instanceof GuiScreenWorking || self instanceof GuiDownloadTerrain)) return;
42-
if (self instanceof GuiOldSaveLoadConfirm) return;
43-
ClientHelper.renderWorldBackground(this.mc,this.width, this.height);
44-
ci.cancel();
36+
if (ClientHelper.renderWorldBackground(self, this.mc, this.width, this.height)) {
37+
ci.cancel();
38+
}
4539
}
4640
}

src/main/java/com/clear/clearmybackground/mixin/early/GuiSlotMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ private void modifyBackground(@Nonnull CallbackInfo ci) {
101101
}
102102

103103
@Inject(method = "drawSelectionBox", at = @At("HEAD"))
104-
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
104+
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
105105
ClientHelper.scissor(this.left, this.top, this.right - this.left, this.bottom - this.top);
106106
}
107107

108108
@Inject(method = "drawSelectionBox", at = @At("RETURN"))
109-
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
109+
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
110110
GL11.glDisable(GL11.GL_SCISSOR_TEST);
111111
}
112112
}

src/main/java/com/clear/clearmybackground/mixin/early/GuiWorldSelectionMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public class GuiWorldSelectionMixin {
1212
@Inject(method = "drawScreen", at = @At("HEAD"))
1313
private void drawBG(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
1414
GuiWorldSelection self = (GuiWorldSelection) (Object) this;
15-
ClientHelper.renderWorldBackground(self.mc, self.width, self.height);
15+
ClientHelper.renderWorldBackground(self, self.mc, self.width, self.height);
1616
}
1717
}

src/main/java/com/clear/clearmybackground/mixin/late/controlling/GuiNewKeyBindingListMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
@Mixin(value = GuiNewKeyBindingList.class, remap = false)
1212
public class GuiNewKeyBindingListMixin {
1313
@Inject(method = "drawSelectionBox", at = @At("HEAD"))
14-
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
14+
private void enableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
1515
GuiNewKeyBindingList self = (GuiNewKeyBindingList) (Object) this;
1616
ClientHelper.scissor(self.left, self.top, self.right - self.left, self.bottom - self.top);
1717
}
1818

1919
@Inject(method = "drawSelectionBox", at = @At("RETURN"))
20-
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci){
20+
private void disableScissor(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks, CallbackInfo ci) {
2121
GL11.glDisable(GL11.GL_SCISSOR_TEST);
2222
}
2323
}

0 commit comments

Comments
 (0)