vanilla-fixes

Minecraft: Better than Adventure! mod that fixes some issues
git clone git://memoryshards.xyz/vanilla-fixes.git
Log | Files | Refs | README | LICENSE

commit 95afccc8d7726e7080cd73feb3fffe08b658f25a
parent 48c8cf14f3f87dec5aab5cd04ec8ca4b5fc1b2b2
Author: Amb0s <ambos@disroot.org>
Date:   Sun, 21 Jan 2024 10:51:35 +0100

Updated mod group and links

Diffstat:
Mgradle.properties | 2+-
Asrc/main/java/ambos/vanillafixes/VanillaFixes.java | 15+++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/ChunkProviderStaticMixin.java | 14++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/DisplayListMixin.java | 42++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/FogManagerMixin.java | 37+++++++++++++++++++++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/GuiIngameMixin.java | 18++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/GuiMainMenuMixin.java | 30++++++++++++++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/GuiTooltipMixin.java | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/MinecraftMixin.java | 19+++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/RenderGlobalMixin.java | 43+++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/ambos/vanillafixes/mixin/SoundManagerMixin.java | 39+++++++++++++++++++++++++++++++++++++++
Dsrc/main/java/turniplabs/vanillafixes/VanillaFixes.java | 15---------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java | 14--------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/DisplayListMixin.java | 42------------------------------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/FogManagerMixin.java | 37-------------------------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java | 18------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/GuiMainMenuMixin.java | 30------------------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/GuiTooltipMixin.java | 68--------------------------------------------------------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java | 19-------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java | 43-------------------------------------------
Dsrc/main/java/turniplabs/vanillafixes/mixin/SoundManagerMixin.java | 39---------------------------------------
Msrc/main/resources/fabric.mod.json | 8++++----
Msrc/main/resources/vanillafixes.mixins.json | 2+-
23 files changed, 331 insertions(+), 331 deletions(-)

diff --git a/gradle.properties b/gradle.properties @@ -8,5 +8,5 @@ loader_version=0.14.19-babric.3-bta # Mod mod_version=4.3.0 -mod_group=turniplabs +mod_group=ambos mod_name=vanilla-fixes diff --git a/src/main/java/ambos/vanillafixes/VanillaFixes.java b/src/main/java/ambos/vanillafixes/VanillaFixes.java @@ -0,0 +1,15 @@ +package ambos.vanillafixes; + +import net.fabricmc.api.ModInitializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VanillaFixes implements ModInitializer { + public static final String MOD_ID = "vanillafixes"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + @Override + public void onInitialize() { + LOGGER.info("Vanilla Fixes initialized"); + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/ChunkProviderStaticMixin.java b/src/main/java/ambos/vanillafixes/mixin/ChunkProviderStaticMixin.java @@ -0,0 +1,14 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.world.chunk.provider.ChunkProviderStatic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = ChunkProviderStatic.class, remap = false) +final class ChunkProviderStaticMixin { + @ModifyConstant(method = "getInfoString", constant = @Constant(stringValue = "ChunkCache: ")) + private String reformatChunkCache(String value) { + return "Chunk Cache: "; + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/DisplayListMixin.java b/src/main/java/ambos/vanillafixes/mixin/DisplayListMixin.java @@ -0,0 +1,42 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.render.DisplayList; +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.ModifyArgs; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(value = DisplayList.class, remap = false) +final class DisplayListMixin { + private double offsetX; + private double offsetY; + private double offsetZ; + + @Shadow + private int posX; + + @Shadow + private int posY; + + @Shadow + private int posZ; + + @Inject(method = "setToPos", at = @At("RETURN"), require = 0) + private void onSetToPos(int blockX, int blockY, int blockZ, double offsetX, double offsetY, double offsetZ, + CallbackInfo ci) { + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + } + + @ModifyArgs(method = "call", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glTranslatef(FFF)V"), + require = 0) + private void changeType(Args args) { + args.set(0, (float) ((double) this.posX - this.offsetX)); + args.set(1, (float) ((double) this.posY - this.offsetY)); + args.set(2, (float) ((double) this.posZ - this.offsetZ)); + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/FogManagerMixin.java b/src/main/java/ambos/vanillafixes/mixin/FogManagerMixin.java @@ -0,0 +1,37 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.option.enums.RenderDistance; +import net.minecraft.client.render.FogManager; + +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.ModifyArgs; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(value = FogManager.class, remap = false) +public class FogManagerMixin { + @Shadow + private Minecraft mc; + + @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0) + private void changeFogStart(Args args) { + if (!(Boolean)this.mc.gameSettings.fog.value + && args.get(0).equals(2915) // https://legacy.lwjgl.org/javadoc/constant-values.html + && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) { + args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 12)); + } + } + + @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0) + private void changeFogEnd(Args args) { + if (!(Boolean)this.mc.gameSettings.fog.value + && args.get(0).equals(2916) // https://legacy.lwjgl.org/javadoc/constant-values.html + && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) { + args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 16)); + } + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiIngameMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiIngameMixin.java @@ -0,0 +1,18 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.gui.GuiIngame; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; + +@Mixin(value = GuiIngame.class, remap = false) +final class GuiIngameMixin { + @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "s I: ")) + private String deobfuscateWeatherIntensity(String value) { + return "s, Intensity: "; + } + + @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "% P: ")) + private String deobfuscateWeatherPower(String value) { + return "%, Power: "; + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiMainMenuMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiMainMenuMixin.java @@ -0,0 +1,30 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(value = GuiMainMenu.class, remap = false) +final class GuiMainMenuMixin extends GuiScreen { + @Inject(method = "init", at = @At("RETURN"), require = 0) + private void removeLinks(CallbackInfo ci) { + controlList.removeIf(button -> + button.id == 5 /* Discord */ || button.id == 6 /* Minecraft Forums */ || + button.id == 7 /* Youtube */); + } + + @Inject(method = "init", at = @At("RETURN"), require = 0) + private void removeButtons(CallbackInfo ci) { + controlList.removeIf(button -> button.id == 8 /* Languages */); + } + + @ModifyArgs(method = "drawScreen", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/render/FontRenderer;drawCenteredString(Ljava/lang/String;III)V", + ordinal = 0), require = 0) + private void removeDownloadingResourcesString(Args args) { + args.set(0, ""); + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiTooltipMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiTooltipMixin.java @@ -0,0 +1,68 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiTooltip; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.tool.ItemTool; +import net.minecraft.core.item.tool.ItemToolSword; +import net.minecraft.core.net.command.TextFormatting; +import net.minecraft.core.player.inventory.InventoryPlayer; +import net.minecraft.core.player.inventory.slot.Slot; +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.CallbackInfoReturnable; + +@Mixin(value = GuiTooltip.class, remap = false) +final class GuiTooltipMixin extends Gui { + @Shadow + Minecraft mc; + + private Slot hoveredSlot; + + @Inject(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At("HEAD")) + private void getSlot(ItemStack itemStack, boolean showDescription, Slot slot, CallbackInfoReturnable<Object> cir) { + // Stores hovered inventory slot. + hoveredSlot = slot; + } + + @Redirect(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At(value = "INVOKE", + target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 0)) + private StringBuilder addStats(StringBuilder stringBuilder, String str) { + stringBuilder.append(str); + + if (mc.gameSettings.heldItemCountOverlay.value) { + // Gets player inventory. + InventoryPlayer inventory = mc.thePlayer.inventory; + + if (inventory.getHeldItemStack() == null && hoveredSlot != null && hoveredSlot.hasStack() && + hoveredSlot.getStack().getItemName() != null) { // If the slot isn't empty... + if (hoveredSlot.getStack().getItem() instanceof ItemToolSword || + hoveredSlot.getStack().getItem() instanceof ItemTool) { // If it's a sword or a tool... + + // Gets durability. + int toolDurability = hoveredSlot.getStack().getMaxDamage() - hoveredSlot.getStack() + .getItemDamageForDisplay(); + + // Gets damage. + int toolDamage = hoveredSlot.getStack().getItem().getDamageVsEntity(null); + + /* Formats durability display */ + String durabilityTooltip = "Durability: " + toolDurability + "/" + hoveredSlot + .getStack() + .getMaxDamage(); + stringBuilder.append('\n').append(TextFormatting.LIGHT_GRAY).append(durabilityTooltip); + + /* Formats damage display */ + String damageTooltip = "+" + toolDamage + " Attack Damage"; + stringBuilder.append('\n').append(TextFormatting.LIGHT_GRAY).append(damageTooltip); + } + } + } + + return stringBuilder; + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/MinecraftMixin.java b/src/main/java/ambos/vanillafixes/mixin/MinecraftMixin.java @@ -0,0 +1,19 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.render.EffectRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = Minecraft.class, remap = false) +final class MinecraftMixin { + @Shadow + public EffectRenderer effectRenderer; + + @Inject(method = "getEntityCountsInfoString", at = @At("HEAD"), require = 0, cancellable = true) + private void changeFormatting(CallbackInfoReturnable<String> cir) { + cir.setReturnValue("Particles: " + this.effectRenderer.getNumParticlesString()); + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/RenderGlobalMixin.java b/src/main/java/ambos/vanillafixes/mixin/RenderGlobalMixin.java @@ -0,0 +1,43 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.render.RenderGlobal; +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.CallbackInfoReturnable; + +@Mixin(value = RenderGlobal.class, remap = false) +final class RenderGlobalMixin { + @Shadow + private int countEntitiesTotal; + @Shadow + private int countEntitiesRendered; + @Shadow + private int renderersLoaded; + @Shadow + private int renderersBeingRendered; + + @Inject(method = "getRendererDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) + private void changeFormatting(CallbackInfoReturnable<String> cir) { + cir.setReturnValue("Renderers: " + this.renderersBeingRendered + "/" + this.renderersLoaded); + } + + @Inject(method = "getEntityDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) + private void changeFormatting2(CallbackInfoReturnable<String> cir) { + cir.setReturnValue("Entities: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal); + } + + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0)) + private void cancelCallglEnable(int cap) { + // Fix fog rendering underwater. + } + + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0)) + private void cancelCallglDisable(int cap) { + // Fix fog rendering underwater. + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/SoundManagerMixin.java b/src/main/java/ambos/vanillafixes/mixin/SoundManagerMixin.java @@ -0,0 +1,39 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.sound.SoundManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +import java.io.File; + +@Mixin(value = SoundManager.class, remap = false) +final class SoundManagerMixin { + @Redirect(method = "loadModAudio", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/Minecraft;getAppDir(Ljava/lang/String;)Ljava/io/File;", ordinal = 0)) + private static File doNotGetAppDir(String s) { + return new File(s); + } + + @ModifyArgs(method = "loadSoundSettings", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/sound/SoundManager;loadModAudio(Ljava/lang/String;Lnet/minecraft/client/sound/SoundPool;)V"), + require = 0) + private void changeModResourcesPath(Args args) { + // Note: "mod" directory is now inside .minecraft/resources instead of $HOME/.minecraft-bta/resources + // (MultiMC users should be happy) + Minecraft mc = Minecraft.getMinecraft(Minecraft.class); + + if (args.get(0).equals("minecraft-bta/resources/mod/sound")) { + args.set(0, mc.getMinecraftDir() + "/resources/mod/sound"); + } else if (args.get(0).equals("minecraft-bta/resources/mod/streaming")) { + args.set(0, mc.getMinecraftDir() + "/resources/mod/streaming"); + } else if (args.get(0).equals("minecraft-bta/resources/mod/music")) { + args.set(0, mc.getMinecraftDir() + "/resources/mod/music"); + } else { + args.set(0, mc.getMinecraftDir() + "/resources/mod/cavemusic"); + } + } +} diff --git a/src/main/java/turniplabs/vanillafixes/VanillaFixes.java b/src/main/java/turniplabs/vanillafixes/VanillaFixes.java @@ -1,15 +0,0 @@ -package turniplabs.vanillafixes; - -import net.fabricmc.api.ModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class VanillaFixes implements ModInitializer { - public static final String MOD_ID = "vanillafixes"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - - @Override - public void onInitialize() { - LOGGER.info("VanillaFixes initialized"); - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java @@ -1,14 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.world.chunk.provider.ChunkProviderStatic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -@Mixin(value = ChunkProviderStatic.class, remap = false) -final class ChunkProviderStaticMixin { - @ModifyConstant(method = "getInfoString", constant = @Constant(stringValue = "ChunkCache: ")) - private String reformatChunkCache(String value) { - return "Chunk Cache: "; - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/DisplayListMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/DisplayListMixin.java @@ -1,42 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.render.DisplayList; -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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -@Mixin(value = DisplayList.class, remap = false) -final class DisplayListMixin { - private double offsetX; - private double offsetY; - private double offsetZ; - - @Shadow - private int posX; - - @Shadow - private int posY; - - @Shadow - private int posZ; - - @Inject(method = "setToPos", at = @At("RETURN"), require = 0) - private void onSetToPos(int blockX, int blockY, int blockZ, double offsetX, double offsetY, double offsetZ, - CallbackInfo ci) { - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - } - - @ModifyArgs(method = "call", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glTranslatef(FFF)V"), - require = 0) - private void changeType(Args args) { - args.set(0, (float) ((double) this.posX - this.offsetX)); - args.set(1, (float) ((double) this.posY - this.offsetY)); - args.set(2, (float) ((double) this.posZ - this.offsetZ)); - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/FogManagerMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/FogManagerMixin.java @@ -1,37 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.option.enums.RenderDistance; -import net.minecraft.client.render.FogManager; - -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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -@Mixin(value = FogManager.class, remap = false) -public class FogManagerMixin { - @Shadow - private Minecraft mc; - - @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", - target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0) - private void changeFogStart(Args args) { - if (!(Boolean)this.mc.gameSettings.fog.value - && args.get(0).equals(2915) // https://legacy.lwjgl.org/javadoc/constant-values.html - && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) { - args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 12)); - } - } - - @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", - target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0) - private void changeFogEnd(Args args) { - if (!(Boolean)this.mc.gameSettings.fog.value - && args.get(0).equals(2916) // https://legacy.lwjgl.org/javadoc/constant-values.html - && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) { - args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 16)); - } - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java @@ -1,18 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.gui.GuiIngame; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.*; - -@Mixin(value = GuiIngame.class, remap = false) -final class GuiIngameMixin { - @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "s I: ")) - private String deobfuscateWeatherIntensity(String value) { - return "s, Intensity: "; - } - - @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "% P: ")) - private String deobfuscateWeatherPower(String value) { - return "%, Power: "; - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiMainMenuMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiMainMenuMixin.java @@ -1,30 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.gui.GuiScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -@Mixin(value = GuiMainMenu.class, remap = false) -final class GuiMainMenuMixin extends GuiScreen { - @Inject(method = "init", at = @At("RETURN"), require = 0) - private void removeLinks(CallbackInfo ci) { - controlList.removeIf(button -> - button.id == 5 /* Discord */ || button.id == 6 /* Minecraft Forums */ || - button.id == 7 /* Youtube */); - } - - @Inject(method = "init", at = @At("RETURN"), require = 0) - private void removeButtons(CallbackInfo ci) { - controlList.removeIf(button -> button.id == 8 /* Languages */); - } - - @ModifyArgs(method = "drawScreen", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/render/FontRenderer;drawCenteredString(Ljava/lang/String;III)V", - ordinal = 0), require = 0) - private void removeDownloadingResourcesString(Args args) { - args.set(0, ""); - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiTooltipMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiTooltipMixin.java @@ -1,68 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiTooltip; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.item.tool.ItemTool; -import net.minecraft.core.item.tool.ItemToolSword; -import net.minecraft.core.net.command.TextFormatting; -import net.minecraft.core.player.inventory.InventoryPlayer; -import net.minecraft.core.player.inventory.slot.Slot; -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.CallbackInfoReturnable; - -@Mixin(value = GuiTooltip.class, remap = false) -final class GuiTooltipMixin extends Gui { - @Shadow - Minecraft mc; - - private Slot hoveredSlot; - - @Inject(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At("HEAD")) - private void getSlot(ItemStack itemStack, boolean showDescription, Slot slot, CallbackInfoReturnable<Object> cir) { - // Stores hovered inventory slot. - hoveredSlot = slot; - } - - @Redirect(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At(value = "INVOKE", - target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 0)) - private StringBuilder addStats(StringBuilder stringBuilder, String str) { - stringBuilder.append(str); - - if (mc.gameSettings.heldItemCountOverlay.value) { - // Gets player inventory. - InventoryPlayer inventory = mc.thePlayer.inventory; - - if (inventory.getHeldItemStack() == null && hoveredSlot != null && hoveredSlot.hasStack() && - hoveredSlot.getStack().getItemName() != null) { // If the slot isn't empty... - if (hoveredSlot.getStack().getItem() instanceof ItemToolSword || - hoveredSlot.getStack().getItem() instanceof ItemTool) { // If it's a sword or a tool... - - // Gets durability. - int toolDurability = hoveredSlot.getStack().getMaxDamage() - hoveredSlot.getStack() - .getItemDamageForDisplay(); - - // Gets damage. - int toolDamage = hoveredSlot.getStack().getItem().getDamageVsEntity(null); - - /* Formats durability display */ - String durabilityTooltip = "Durability: " + toolDurability + "/" + hoveredSlot - .getStack() - .getMaxDamage(); - stringBuilder.append('\n').append(TextFormatting.LIGHT_GRAY).append(durabilityTooltip); - - /* Formats damage display */ - String damageTooltip = "+" + toolDamage + " Attack Damage"; - stringBuilder.append('\n').append(TextFormatting.LIGHT_GRAY).append(damageTooltip); - } - } - } - - return stringBuilder; - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java @@ -1,19 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.render.EffectRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = Minecraft.class, remap = false) -final class MinecraftMixin { - @Shadow - public EffectRenderer effectRenderer; - - @Inject(method = "getEntityCountsInfoString", at = @At("HEAD"), require = 0, cancellable = true) - private void changeFormatting(CallbackInfoReturnable<String> cir) { - cir.setReturnValue("Particles: " + this.effectRenderer.getNumParticlesString()); - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java @@ -1,43 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.render.RenderGlobal; -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.CallbackInfoReturnable; - -@Mixin(value = RenderGlobal.class, remap = false) -final class RenderGlobalMixin { - @Shadow - private int countEntitiesTotal; - @Shadow - private int countEntitiesRendered; - @Shadow - private int renderersLoaded; - @Shadow - private int renderersBeingRendered; - - @Inject(method = "getRendererDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) - private void changeFormatting(CallbackInfoReturnable<String> cir) { - cir.setReturnValue("Renderers: " + this.renderersBeingRendered + "/" + this.renderersLoaded); - } - - @Inject(method = "getEntityDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) - private void changeFormatting2(CallbackInfoReturnable<String> cir) { - cir.setReturnValue("Entities: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal); - } - - @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", - target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0)) - private void cancelCallglEnable(int cap) { - // Fix fog rendering underwater. - } - - @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", - target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0)) - private void cancelCallglDisable(int cap) { - // Fix fog rendering underwater. - } -} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/SoundManagerMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/SoundManagerMixin.java @@ -1,39 +0,0 @@ -package turniplabs.vanillafixes.mixin; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.sound.SoundManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -import java.io.File; - -@Mixin(value = SoundManager.class, remap = false) -final class SoundManagerMixin { - @Redirect(method = "loadModAudio", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/Minecraft;getAppDir(Ljava/lang/String;)Ljava/io/File;", ordinal = 0)) - private static File doNotGetAppDir(String s) { - return new File(s); - } - - @ModifyArgs(method = "loadSoundSettings", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/sound/SoundManager;loadModAudio(Ljava/lang/String;Lnet/minecraft/client/sound/SoundPool;)V"), - require = 0) - private void changeModResourcesPath(Args args) { - // Note: "mod" directory is now inside .minecraft/resources instead of $HOME/.minecraft-bta/resources - // (MultiMC users should be happy) - Minecraft mc = Minecraft.getMinecraft(Minecraft.class); - - if (args.get(0).equals("minecraft-bta/resources/mod/sound")) { - args.set(0, mc.getMinecraftDir() + "/resources/mod/sound"); - } else if (args.get(0).equals("minecraft-bta/resources/mod/streaming")) { - args.set(0, mc.getMinecraftDir() + "/resources/mod/streaming"); - } else if (args.get(0).equals("minecraft-bta/resources/mod/music")) { - args.set(0, mc.getMinecraftDir() + "/resources/mod/music"); - } else { - args.set(0, mc.getMinecraftDir() + "/resources/mod/cavemusic"); - } - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json @@ -8,16 +8,16 @@ "Ambos" ], "contact": { - "homepage": "https://github.com/Turnip-Labs", - "sources": "https://github.com/Turnip-Labs/vanilla-fixes", - "issues": "https://github.com/Turnip-Labs/vanilla-fixes/issues" + "homepage": "https://memoryshards.xyz", + "sources": "https://github.com/amb0s/vanilla-fixes", + "issues": "https://github.com/amb0s/vanilla-fixes/issues" }, "license": "MIT", "icon": "icon.png", "environment": "*", "entrypoints": { "main": [ - "turniplabs.vanillafixes.VanillaFixes" + "ambos.vanillafixes.VanillaFixes" ] }, "mixins": [ diff --git a/src/main/resources/vanillafixes.mixins.json b/src/main/resources/vanillafixes.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "turniplabs.vanillafixes.mixin", + "package": "ambos.vanillafixes.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ "ChunkProviderStaticMixin",