Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
working project i think
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed May 13, 2024
1 parent 0413bea commit 762746c
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 425 deletions.
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ repositories {
}

java {
withSourcesJar()
withJavadocJar()
toolchain {
when(platform.mcVersion) {
in 12001..12004 -> {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/dev/microcontrollers/overlaytweaks/Shifter.java

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.microcontrollers.overlaytweaks.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.microcontrollers.overlaytweaks.config.OverlayTweaksConfig;
import net.minecraft.client.MinecraftClient;
Expand All @@ -13,15 +12,10 @@
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

// BetterF3 has a priority of 1100. This is to prevent a crash with cancelDebugCrosshair.
@Mixin(value = InGameHud.class, priority = 1200)
@Mixin(InGameHud.class)
public class InGameHudMixin {
@Shadow
public float vignetteDarkness;
@Shadow
private Text title;
@Shadow
private Text subtitle;
@Mutable
@Final
@Shadow
Expand Down Expand Up @@ -87,63 +81,4 @@ private void removeScoreboardInDebug(CallbackInfo ci) {
}
}

/*
The following methods were taken from Easeify under LGPLV3
https://github.com/Polyfrost/Easeify/blob/main/LICENSE
The code has been updated to 1.20 and with several fixes
*/

//#if MC >= 1.20.6
@ModifyExpressionValue(method = "renderTitleAndSubtitle", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(III)I"))
//#else
//$$ @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(III)I"))
//#endif
private int disableTitles(int value) {
if (OverlayTweaksConfig.CONFIG.instance().disableTitles) return 0;
else return value;
}

//#if MC >= 1.20.6
@Inject(method = "renderTitleAndSubtitle", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V", ordinal = 0, shift = At.Shift.AFTER))
//#else
//$$ @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V", ordinal = 0, shift = At.Shift.AFTER))
//#endif
private void modifyTitleScale(DrawContext context, float tickDelta, CallbackInfo ci) {
float titleScale = OverlayTweaksConfig.CONFIG.instance().titleScale / 100;
// TODO: MCCIsland uses a giant title to black out your screen when switching worlds, so let's keep that. Find a better way to only keep black out
if (OverlayTweaksConfig.CONFIG.instance().autoTitleScale && (MinecraftClient.getInstance().getCurrentServerEntry() != null && !MinecraftClient.getInstance().getCurrentServerEntry().address.contains("mccisland.net"))) {
final float width = MinecraftClient.getInstance().textRenderer.getWidth(title) * 4.0F;
if (width > context.getScaledWindowWidth()) {
titleScale = (context.getScaledWindowWidth() / width) * OverlayTweaksConfig.CONFIG.instance().titleScale / 100;
}
}
context.getMatrices().scale(titleScale, titleScale, titleScale);
}

//#if MC >= 1.20.6
@Inject(method = "renderTitleAndSubtitle", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V", ordinal = 1, shift = At.Shift.AFTER))
//#else
//$$ @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V", ordinal = 1, shift = At.Shift.AFTER))
//#endif
private void modifySubtitleScale(DrawContext context, float tickDelta, CallbackInfo ci) {
float titleScale = OverlayTweaksConfig.CONFIG.instance().titleScale / 100;
// TODO: MCCIsland uses a giant title to black out your screen when switching worlds, so let's keep that. Find a better way to only keep black out
if (OverlayTweaksConfig.CONFIG.instance().autoTitleScale && (MinecraftClient.getInstance().getCurrentServerEntry() != null && !MinecraftClient.getInstance().getCurrentServerEntry().address.contains("mccisland.net"))) {
final float width = MinecraftClient.getInstance().textRenderer.getWidth(subtitle) * 2.0F;
if (width > context.getScaledWindowWidth()) {
titleScale = (context.getScaledWindowWidth() / width) * OverlayTweaksConfig.CONFIG.instance().titleScale / 100;
}
}
context.getMatrices().scale(titleScale, titleScale, titleScale);
}

//#if MC >= 1.20.6
@ModifyConstant(method = "renderTitleAndSubtitle", constant = @Constant(intValue = 255, ordinal = 0))
//#else
//$$ @ModifyConstant(method = "render", constant = @Constant(intValue = 255, ordinal = 3))
//#endif
private int modifyOpacity(int constant) {
return (int) (OverlayTweaksConfig.CONFIG.instance().titleOpacity / 100 * 255);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ public boolean hasGlint(ItemStack stack) {
//$$ return OverlayTweaksConfig.CONFIG.instance().potionGlint && !PotionUtil.getPotionEffects(stack).isEmpty();
//#endif
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public class SubtitlesHudMixin {
private int modifySubtitleColor(int original) {
return OverlayTweaksConfig.CONFIG.instance().subtitleColor.getRGB();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,41 @@

@Mixin(AnvilScreen.class)
public class AnvilScreenMixin {
//#if MC >= 1.20.4
@Inject(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
//#else
//$$ @Inject(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"))
//#endif
private void buttonOpacityStart(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

//#if MC >= 1.20.4
@Inject(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", shift = At.Shift.AFTER))
//#else
//$$ @Inject(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", shift = At.Shift.AFTER))
//#endif
private void buttonOpacityEnd(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

//#if MC >= 1.20.4
@Inject(method = "drawInvalidRecipeArrow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
//#else
//$$ @Inject(method = "drawInvalidRecipeArrow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"))
//#endif
private void invalidArrowOpacityStart(DrawContext context, int x, int y, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

//#if MC >= 1.20.4
@Inject(method = "drawInvalidRecipeArrow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", shift = At.Shift.AFTER))
//#else
//$$ @Inject(method = "drawInvalidRecipeArrow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", shift = At.Shift.AFTER))
//#endif
private void invalidArrowOpacityEnd(DrawContext context, int x, int y, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.microcontrollers.overlaytweaks.mixin.screenopacity;

//#if MC >= 1.20.6
//#if MC >= 1.20.4
import com.mojang.blaze3d.systems.RenderSystem;
import dev.microcontrollers.overlaytweaks.config.OverlayTweaksConfig;
import net.minecraft.client.gui.DrawContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ private void containerOpacityEnd(DrawContext context, float delta, int mouseX, i
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

//#if MC >= 1.20.4
@Inject(method = "renderTabIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
//#else
//$$ @Inject(method = "renderTabIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"))
//#endif
private void containerOpacityStartTab(DrawContext context, ItemGroup group, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

//#if MC >= 1.20.4
@Inject(method = "renderTabIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", shift = At.Shift.AFTER))
//#else
//$$ @Inject(method = "renderTabIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", shift = At.Shift.AFTER))
//#endif
private void containerOpacityEndTab(DrawContext context, ItemGroup group, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private void containerOpacityEnd(DrawContext context, float delta, int mouseX, i
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

//#if MC >= 1.20.4
@Inject(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
private void invalidArrowOpacityStart(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
RenderSystem.enableBlend();
Expand All @@ -34,4 +35,5 @@ private void invalidArrowOpacityEnd(DrawContext context, float delta, int mouseX
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.LoomScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
//#if MC <= 1.20.4
//$$ import net.minecraft.item.ItemStack;
//$$ import net.minecraft.nbt.NbtCompound;
//$$ import net.minecraft.nbt.NbtList;
import net.minecraft.registry.entry.RegistryEntry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -37,7 +38,11 @@ private void containerOpacityEnd(DrawContext context, float delta, int mouseX, i
No changes of note have been made other than adapting to this project
*/
@Inject(method = "drawBanner", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
public void onCreateMatrix(DrawContext context, RegistryEntry<BannerPattern> pattern, int x, int y, CallbackInfo ci, NbtCompound nbtCompound, NbtList nbtList, ItemStack itemStack, MatrixStack matrixStack) {
//#if MC >= 1.20.6
public void onCreateMatrix(DrawContext context, RegistryEntry<BannerPattern> pattern, int x, int y, CallbackInfo ci, MatrixStack matrixStack) {
//#else
//$$ public void onCreateMatrix(DrawContext context, RegistryEntry<BannerPattern> pattern, int x, int y, CallbackInfo ci, NbtCompound nbtCompound, NbtList nbtList, ItemStack itemStack, MatrixStack matrixStack) {
//#endif
matrixStack.scale(InvScale.getScale(), InvScale.getScale(), 1F);
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/overlaytweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"package": "dev.microcontrollers.overlaytweaks.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"BossBarHudMixin",
"BuiltinItemModelRendererMixin",
"ClientWorldMixin",
"DebugHudMixin",
Expand All @@ -16,7 +15,6 @@
"LightningEntityRendererMixin",
"LivingEntityRendererMixin",
"MouseMixin",
"PlayerListHudMixin",
"PotionItemMixin",
"ScreenMixin",
"SubtitlesHudMixin",
Expand Down

0 comments on commit 762746c

Please sign in to comment.