Skip to content

Commit

Permalink
Add texture rotations to no render (MeteorDevelopment#3869)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat authored Jul 22, 2023
1 parent 5c3d7a0 commit a52b91a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Float> 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<Long> cir) {
if (Modules.get().get(NoRender.class).noTextureRotations()) cir.setReturnValue(RANDOM.nextLong());
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ public class NoRender extends Module {
.build()
);

private final Setting<Boolean> 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<Set<EntityType<?>>> entities = sgEntity.add(new EntityTypeListSetting.Builder()
Expand Down Expand Up @@ -520,6 +528,10 @@ public boolean noBarrierInvis() {
return isActive() && noBarrierInvis.get();
}

public boolean noTextureRotations() {
return isActive() && noTextureRotations.get();
}

// Entity

public boolean noEntity(Entity entity) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/meteor-client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"client": [
"AbstractBlockAccessor",
"AbstractBlockMixin",
"AbstractBlockStateMixin",
"AbstractClientPlayerEntityMixin",
"AbstractFurnaceScreenHandlerMixin",
"AbstractFurnaceScreenMixin",
Expand Down

0 comments on commit a52b91a

Please sign in to comment.