From c8d7caecefce40565e8691f1fdb16ad046d19f4c Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Thu, 4 Jul 2024 22:42:11 -0400 Subject: [PATCH 1/5] fix: GammaOverride in between loading worlds fix: Sign Copy Text for Hanging Signs fix: Reduced Explosion particles --- .gitignore | 1 + .../java/fi/dy/masa/tweakeroo/InitHandler.java | 6 +++++- .../masa/tweakeroo/event/WorldLoadListener.java | 15 ++++++++++++++- .../dy/masa/tweakeroo/mixin/MixinExplosion.java | 17 ++++++----------- .../tweakeroo/mixin/MixinSignBlockEntity.java | 8 ++++++-- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index e4ac6288a..ea1a3f120 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ logs/ build.number run .vscode +/.idea/ diff --git a/src/main/java/fi/dy/masa/tweakeroo/InitHandler.java b/src/main/java/fi/dy/masa/tweakeroo/InitHandler.java index 4be534802..0d902bfdc 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/InitHandler.java +++ b/src/main/java/fi/dy/masa/tweakeroo/InitHandler.java @@ -8,6 +8,7 @@ import fi.dy.masa.malilib.event.WorldLoadHandler; import fi.dy.masa.malilib.interfaces.IInitializationHandler; import fi.dy.masa.malilib.interfaces.IRenderer; +import fi.dy.masa.malilib.interfaces.IWorldLoadListener; import fi.dy.masa.tweakeroo.config.Callbacks; import fi.dy.masa.tweakeroo.config.Configs; import fi.dy.masa.tweakeroo.event.ClientTickHandler; @@ -32,7 +33,10 @@ public void registerModHandlers() RenderEventHandler.getInstance().registerWorldLastRenderer(renderer); TickHandler.getInstance().registerClientTickHandler(new ClientTickHandler()); - WorldLoadHandler.getInstance().registerWorldLoadPreHandler(new WorldLoadListener()); + + IWorldLoadListener worldListener = new WorldLoadListener(); + WorldLoadHandler.getInstance().registerWorldLoadPreHandler(worldListener); + WorldLoadHandler.getInstance().registerWorldLoadPostHandler(worldListener); Callbacks.init(MinecraftClient.getInstance()); } diff --git a/src/main/java/fi/dy/masa/tweakeroo/event/WorldLoadListener.java b/src/main/java/fi/dy/masa/tweakeroo/event/WorldLoadListener.java index 2a4a0be89..e84c24f70 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/event/WorldLoadListener.java +++ b/src/main/java/fi/dy/masa/tweakeroo/event/WorldLoadListener.java @@ -14,4 +14,17 @@ public void onWorldLoadPre(@Nullable ClientWorld worldBefore, @Nullable ClientWo // Always disable the Free Camera mode when leaving the world or switching dimensions FeatureToggle.TWEAK_FREE_CAMERA.setBooleanValue(false); } -} + + @Override + public void onWorldLoadPost(@Nullable ClientWorld worldBefore, @Nullable ClientWorld worldAfter, MinecraftClient mc) + { + if (worldBefore == null) + { + if (FeatureToggle.TWEAK_GAMMA_OVERRIDE.getBooleanValue()) + { + FeatureToggle.TWEAK_GAMMA_OVERRIDE.setBooleanValue(false); + FeatureToggle.TWEAK_GAMMA_OVERRIDE.setBooleanValue(true); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinExplosion.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinExplosion.java index 09549c1ae..dd59a282f 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinExplosion.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinExplosion.java @@ -2,9 +2,8 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; -import net.minecraft.particle.DefaultParticleType; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.world.explosion.Explosion; import fi.dy.masa.tweakeroo.config.FeatureToggle; @@ -12,14 +11,10 @@ @Mixin(Explosion.class) public abstract class MixinExplosion { - @Redirect(method = "affectWorld", - slice = @Slice( - from = @At("HEAD"), - to = @At(value = "FIELD", - target = "Lnet/minecraft/world/explosion/Explosion;affectedBlocks:Lit/unimi/dsi/fastutil/objects/ObjectArrayList;")), - at = @At(value = "FIELD", - target = "Lnet/minecraft/particle/ParticleTypes;EXPLOSION_EMITTER:Lnet/minecraft/particle/DefaultParticleType;")) - private DefaultParticleType redirectSpawnParticles() + @ModifyArg(method = "affectWorld", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/World;addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V")) + private ParticleEffect addParticleModify(ParticleEffect parameters) { if (FeatureToggle.TWEAK_EXPLOSION_REDUCED_PARTICLES.getBooleanValue()) { diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinSignBlockEntity.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinSignBlockEntity.java index 82c7ff620..0a3c7adc1 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinSignBlockEntity.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinSignBlockEntity.java @@ -12,6 +12,7 @@ import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.block.entity.SignText; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ingame.HangingSignEditScreen; import net.minecraft.client.gui.screen.ingame.SignEditScreen; import net.minecraft.nbt.NbtCompound; import net.minecraft.util.math.BlockPos; @@ -40,9 +41,12 @@ private void restoreCopiedText(NbtCompound nbt, CallbackInfo ci) { MinecraftClient mc = MinecraftClient.getInstance(); - if ((mc.currentScreen instanceof SignEditScreen) && ((IGuiEditSign) mc.currentScreen).getTile() == (Object) this) + if (mc.currentScreen instanceof SignEditScreen || mc.currentScreen instanceof HangingSignEditScreen) { - MiscUtils.applyPreviousTextToSign((SignBlockEntity) (Object) this, null, ((SignBlockEntity) (Object) this).isPlayerFacingFront(mc.player)); + if (((IGuiEditSign) mc.currentScreen).getTile() == (Object) this) + { + MiscUtils.applyPreviousTextToSign((SignBlockEntity) (Object) this, null, ((SignBlockEntity) (Object) this).isPlayerFacingFront(mc.player)); + } } } } From 7a2d304cf7d9e02efe57ac5872a2f1bd933ea62f Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Fri, 29 Nov 2024 13:23:57 -0300 Subject: [PATCH 2/5] Fix Tweakeroo's free camera tweak breaking zoom mods (#75) --- .../tweakeroo/mixin/MixinGameRenderer.java | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java index 43c3f0df0..5aed94eff 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -1,14 +1,15 @@ package fi.dy.masa.tweakeroo.mixin; import java.util.function.Predicate; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import net.minecraft.block.enums.CameraSubmersionType; 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.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -63,10 +64,36 @@ private void applyZoom(Camera camera, float partialTicks, boolean useFOVSetting, { cir.setReturnValue(Configs.Generic.ZOOM_FOV.getDoubleValue()); } - else if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) + } + + @ModifyExpressionValue(method = "getFov", at = @At(value = "CONSTANT", args = "floatValue=70.0")) + private float applyFreeCameraFov(float original) + { + if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) + { + return ((float) this.client.options.getFov().getValue()); + } + + return original; + } + + @ModifyVariable(method = "getFov", at = @At(value = "LOAD", ordinal = 0), argsOnly = true) + private boolean freezeFovOnFreeCamera(boolean value) + { + return !FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue() && value; + } + + @ModifyExpressionValue( + method = "getFov", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/render/Camera;getSubmersionType()Lnet/minecraft/block/enums/CameraSubmersionType;")) + private CameraSubmersionType ignoreSubmersionTypeOnFreeCamera(CameraSubmersionType original) + { + if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) { - cir.setReturnValue((double) this.client.options.getFov().getValue()); + return CameraSubmersionType.NONE; } + + return original; } @Redirect(method = "updateTargetedEntity", at = @At(value = "INVOKE", From 0af01f8edb5baa11147b387eb39a29e2ec5244b3 Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Fri, 29 Nov 2024 12:00:02 -0500 Subject: [PATCH 3/5] apply freecam "fix" from 1.21.3. --- .../tweakeroo/mixin/MixinGameRenderer.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java index 5aed94eff..4eb7b874b 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -1,9 +1,15 @@ package fi.dy.masa.tweakeroo.mixin; import java.util.function.Predicate; - import com.llamalad7.mixinextras.injector.ModifyExpressionValue; + import net.minecraft.block.enums.CameraSubmersionType; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.Camera; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.decoration.AbstractDecorationEntity; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -31,12 +37,11 @@ @Mixin(value = GameRenderer.class, priority = 1001) public abstract class MixinGameRenderer { - @Shadow @Final MinecraftClient client; - @Shadow protected abstract void bobView(MatrixStack matrices, float tickDelta); + @Shadow @Final MinecraftClient client; - private float realYaw; - private float realPitch; + @Unique private float realYaw; + @Unique private float realPitch; @Inject(method = "renderWorld", at = @At("HEAD"), cancellable = true) private void onRenderWorld(CallbackInfo ci) @@ -66,12 +71,12 @@ private void applyZoom(Camera camera, float partialTicks, boolean useFOVSetting, } } - @ModifyExpressionValue(method = "getFov", at = @At(value = "CONSTANT", args = "floatValue=70.0")) - private float applyFreeCameraFov(float original) + @ModifyExpressionValue(method = "getFov", at = @At(value = "CONSTANT", args = "doubleValue=70.0")) + private double applyFreeCameraFov(double original) { if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) { - return ((float) this.client.options.getFov().getValue()); + return ((double) this.client.options.getFov().getValue()); } return original; From 6e07cfc1bd9771ebedf1bb2e661385c3a3e26ee3 Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Fri, 29 Nov 2024 12:05:39 -0500 Subject: [PATCH 4/5] apply freecam "fix" from 1.21.3. --- .../dy/masa/tweakeroo/mixin/MixinGameRenderer.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java index 4eb7b874b..b89311765 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -3,9 +3,9 @@ import java.util.function.Predicate; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import net.minecraft.block.enums.CameraSubmersionType; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Camera; +import net.minecraft.client.render.CameraSubmersionType; import net.minecraft.client.render.GameRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -19,14 +19,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.decoration.AbstractDecorationEntity; - import fi.dy.masa.tweakeroo.config.Callbacks; import fi.dy.masa.tweakeroo.config.Configs; import fi.dy.masa.tweakeroo.config.FeatureToggle; @@ -90,7 +82,7 @@ private boolean freezeFovOnFreeCamera(boolean value) @ModifyExpressionValue( method = "getFov", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/render/Camera;getSubmersionType()Lnet/minecraft/block/enums/CameraSubmersionType;")) + target = "Lnet/minecraft/client/render/Camera;getSubmersionType()Lnet/minecraft/client/render/CameraSubmersionType;")) private CameraSubmersionType ignoreSubmersionTypeOnFreeCamera(CameraSubmersionType original) { if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) From aceacb7031f8fea75527b2ecf01eb9530d7b54f6 Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Fri, 29 Nov 2024 12:12:19 -0500 Subject: [PATCH 5/5] apply freecam "fix" from 1.21.3. --- .gitignore | 1 + .../java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ea1a3f120..c530dabd6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build.number run .vscode /.idea/ +/libs/ diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java index b89311765..55975fa30 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -7,6 +7,7 @@ import net.minecraft.client.render.Camera; import net.minecraft.client.render.CameraSubmersionType; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.decoration.AbstractDecorationEntity; @@ -46,7 +47,7 @@ private void onRenderWorld(CallbackInfo ci) @Redirect(method = "renderWorld", require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V")) - private void disableWorldViewBob(GameRenderer renderer, MatrixStack matrices, float tickDelta) + private void disableWorldViewBob(GameRenderer instance, MatrixStack matrices, float tickDelta) { if (Configs.Disable.DISABLE_WORLD_VIEW_BOB.getBooleanValue() == false) {