From a52b91a6605063b622d913fa712ec53db1378bf2 Mon Sep 17 00:00:00 2001 From: Wide-Cat <74723656+Wide-Cat@users.noreply.github.com> Date: Sat, 22 Jul 2023 23:10:06 +0100 Subject: [PATCH] Add texture rotations to no render (#3869) --- .../mixin/AbstractBlockMixin.java | 11 +++++++ .../mixin/AbstractBlockStateMixin.java | 29 +++++++++++++++++++ .../systems/modules/render/NoRender.java | 12 ++++++++ src/main/resources/meteor-client.mixins.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockStateMixin.java diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java index acea24a485..45fed77b49 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java @@ -7,6 +7,8 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.AmbientOcclusionEvent; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.NoRender; import net.minecraft.block.AbstractBlock; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; @@ -16,12 +18,21 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Random; + @Mixin(AbstractBlock.class) public class AbstractBlockMixin { + private static final Random RANDOM = new Random(); + @Inject(method = "getAmbientOcclusionLightLevel", at = @At("HEAD"), cancellable = true) private void onGetAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable info) { AmbientOcclusionEvent event = MeteorClient.EVENT_BUS.post(AmbientOcclusionEvent.get()); if (event.lightLevel != -1) info.setReturnValue(event.lightLevel); } + + @Inject(method = "getRenderingSeed", at = @At("HEAD"), cancellable = true) + private void onRenderingSeed(BlockState state, BlockPos pos, CallbackInfoReturnable cir) { + if (Modules.get().get(NoRender.class).noTextureRotations()) cir.setReturnValue(RANDOM.nextLong()); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockStateMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockStateMixin.java new file mode 100644 index 0000000000..ff19c95594 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockStateMixin.java @@ -0,0 +1,29 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import net.minecraft.block.AbstractBlock; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +import java.util.Random; + +@Mixin(AbstractBlock.AbstractBlockState.class) +public class AbstractBlockStateMixin { + private static final Random RANDOM = new Random(); + + @ModifyVariable(method = "getModelOffset", at = @At("HEAD"), argsOnly = true) + private BlockPos modifyPos(BlockPos pos) { + if (Modules.get() == null) return pos; + + if (Modules.get().get(NoRender.class).noTextureRotations()) return pos.multiply(RANDOM.nextInt()); + return pos; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java index 4cfb6379f7..8692934f8a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java @@ -290,6 +290,14 @@ public class NoRender extends Module { .build() ); + private final Setting noTextureRotations = sgWorld.add(new BoolSetting.Builder() + .name("texture-rotations") + .description("Changes texture rotations and model offsets to use a random value instead of the block position.") + .defaultValue(false) + .onChanged(b -> mc.worldRenderer.reload()) + .build() + ); + // Entity private final Setting>> entities = sgEntity.add(new EntityTypeListSetting.Builder() @@ -520,6 +528,10 @@ public boolean noBarrierInvis() { return isActive() && noBarrierInvis.get(); } + public boolean noTextureRotations() { + return isActive() && noTextureRotations.get(); + } + // Entity public boolean noEntity(Entity entity) { diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index d30557565b..7818d92b8d 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -6,6 +6,7 @@ "client": [ "AbstractBlockAccessor", "AbstractBlockMixin", + "AbstractBlockStateMixin", "AbstractClientPlayerEntityMixin", "AbstractFurnaceScreenHandlerMixin", "AbstractFurnaceScreenMixin",