Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][compat] iris shaders #173

Merged
merged 2 commits into from
Aug 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}
}