Skip to content

Commit

Permalink
Merge pull request #173 from lonefelidae16/fix/compat-iris
Browse files Browse the repository at this point in the history
[fix][compat] iris shaders
  • Loading branch information
juancarloscp52 committed Aug 27, 2022
2 parents ab29224 + aa35d99 commit 8611a5d
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.util.math.MatrixStack;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntryListWidget.class)
public abstract class EntryListWidgetMixin {
@Shadow @Final protected MinecraftClient client;
@Shadow protected int bottom;
@Shadow protected int top;
@Shadow protected abstract void renderBackground(MatrixStack matrices);
@Shadow public abstract void setRenderBackground(boolean renderBackground);
@Shadow public abstract void setRenderHorizontalShadows(boolean renderHorizontalShadows);

@Redirect(method = "render", at=@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/EntryListWidget;renderBackground(Lnet/minecraft/client/util/math/MatrixStack;)V"))
private void renderPanorama(EntryListWidget entryListWidget, MatrixStack matrices){
Expand All @@ -34,21 +37,17 @@ private void renderPanorama(EntryListWidget entryListWidget, MatrixStack matrice
}
}

// Prevent the screen background from drawing
@Redirect(method = "render", at=@At(value = "FIELD",target = "Lnet/minecraft/client/gui/widget/EntryListWidget;renderBackground:Z", opcode = Opcodes.GETFIELD))
private boolean doNotDrawBackground(EntryListWidget entryListWidget){
return !Bedrockify.getInstance().settings.isCubemapBackgroundEnabled() || shouldIgnoreScreen();
@Inject(method = "<init>(Lnet/minecraft/client/MinecraftClient;IIIII)V", at=@At("RETURN"))
private void bedrockify$ctor(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight, CallbackInfo ci){
// Prevent the screen background from drawing
this.setRenderBackground(!Bedrockify.getInstance().settings.isCubemapBackgroundEnabled() || shouldIgnoreScreen());
// Prevent top and bottom bars from drawing (Only on pack Screens)
this.setRenderHorizontalShadows(!(this.client.currentScreen instanceof PackScreen) || !Bedrockify.getInstance().settings.isCubemapBackgroundEnabled());
}

private boolean shouldIgnoreScreen() {
return this.client.currentScreen.getClass().getName().contains(".modmenu.gui.ModsScreen")/* Mod Menu*/ ||
this.client.currentScreen.getClass().getName().contains(".iris.gui.") /* Iris Shaders Compat*/ ||
this.client.currentScreen.getClass().getName().contains(".modmanager.gui."); /* Mod Manager */
}

//Prevent top and bottom bars from drawing (Only on pack Screens)
@Redirect(method = "render", at=@At(value = "FIELD",target = "Lnet/minecraft/client/gui/widget/EntryListWidget;renderHorizontalShadows:Z", opcode = Opcodes.GETFIELD))
private boolean doNotDrawBars(EntryListWidget entryListWidget){
return !(this.client.currentScreen instanceof PackScreen) || !Bedrockify.getInstance().settings.isCubemapBackgroundEnabled();
}
}

0 comments on commit 8611a5d

Please sign in to comment.