Skip to content

Commit

Permalink
Added codysmile11 NoRender settings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Dec 29, 2024
1 parent a2e1627 commit 402799e
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.stardust.mixin;

import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.injection.Inject;
import net.minecraft.block.entity.BannerBlockEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import meteordevelopment.meteorclient.systems.modules.Modules;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import net.minecraft.client.render.block.entity.BannerBlockEntityRenderer;

/**
* @author Tas [0xTas] <root@0xTas.dev>
**/
@Mixin(BannerBlockEntityRenderer.class)
public class BannerBlockEntityRendererMixin {

// See NoRenderMixin.java
@Inject(method = "render(Lnet/minecraft/block/entity/BannerBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true)
private void onRender(BannerBlockEntity bannerBlockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) {
if (bannerBlockEntity.getWorld() != null) {
Modules mods = Modules.get();
if (mods == null) return;
NoRender noRender = mods.get(NoRender.class);
if (!noRender.isActive()) return;

Text bannerName = bannerBlockEntity.getCustomName();
var bannerSetting = noRender.settings.get("cody-banners");

if (bannerSetting == null || bannerName == null) return;
if ((boolean) bannerSetting.get() && bannerName.getString().contains("codysmile11")) {
ci.cancel();
}
}
}
}
23 changes: 23 additions & 0 deletions src/main/java/dev/stardust/mixin/EntityRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package dev.stardust.mixin;

import net.minecraft.text.Text;
import net.minecraft.entity.Entity;
import dev.stardust.modules.AntiToS;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.client.render.Frustum;
import org.spongepowered.asm.mixin.injection.At;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.injection.Inject;
import net.minecraft.client.render.entity.EntityRenderer;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* @author Tas [0xTas] <root@0xTas.dev>
Expand All @@ -25,4 +31,21 @@ private Text censorEntityName(Text name) {
if (!antiToS.containsBlacklistedText(name.getString())) return name;
return Text.literal(antiToS.censorText(name.getString())).setStyle(name.getStyle());
}

// See NoRenderMixin.java
@Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true)
private void shouldRender(Entity entity, Frustum frustum, double x, double y, double z, CallbackInfoReturnable<Boolean> cir) {
if (!(entity instanceof PlayerEntity player)) return;

Modules mods = Modules.get();
if (mods == null) return;
NoRender noRender = mods.get(NoRender.class);
if (!noRender.isActive()) return;

var codySetting = noRender.settings.get("cody");
if (codySetting != null && (boolean) codySetting.get() && player.getGameProfile().getName().equals("codysmile11")) {
cir.setReturnValue(false);
cir.cancel();
}
}
}
27 changes: 27 additions & 0 deletions src/main/java/dev/stardust/mixin/SignBlockEntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
import dev.stardust.modules.AntiToS;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.block.entity.SignText;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.block.entity.SignBlockEntity;
import org.spongepowered.asm.mixin.injection.Inject;
import net.minecraft.client.render.VertexConsumerProvider;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import meteordevelopment.meteorclient.systems.modules.Modules;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;

/**
Expand All @@ -33,4 +39,25 @@ private SignText modifyRenderedText(SignText signText) {
.trim();
return antiToS.containsBlacklistedText(testText) ? antiToS.familyFriendlySignText(signText) : signText;
}

// See NoRenderMixin.java
@Inject(method = "render(Lnet/minecraft/block/entity/SignBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true)
private void onRender(SignBlockEntity signBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
Modules mods = Modules.get();
if (mods == null) return;
NoRender noRender = mods.get(NoRender.class);
if (!noRender.isActive()) return;

var signSetting = noRender.settings.get("cody-signs");
if (signSetting == null) return;
if ((boolean) signSetting.get() && isCodySign(signBlockEntity)) {
ci.cancel();
}
}

@Unique
private boolean isCodySign(SignBlockEntity sbe) {
SignText frontText = sbe.getFrontText();
return Arrays.stream(frontText.getMessages(false)).anyMatch(msg -> msg.getString().contains("codysmile11"));
}
}
60 changes: 60 additions & 0 deletions src/main/java/dev/stardust/mixin/meteor/NoRenderMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package dev.stardust.mixin.meteor;

import org.spongepowered.asm.mixin.Mixin;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Category;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;

/**
* @author Tas [0xTas] <root@0xTas.dev>
**/
// TODO: Paul wants this to stop the signs from showing up on another client's search somehow...
@Mixin(value = NoRender.class, remap = false)
public abstract class NoRenderMixin extends Module {
public NoRenderMixin(Category category, String name, String description) {
super(category, name, description);
}

@Unique
private final SettingGroup sgCody = settings.createGroup("codysmile11");
@Unique
private @Nullable Setting<Boolean> codySigns = null;
@Unique
private @Nullable Setting<Boolean> codyPlayer = null;
@Unique
private @Nullable Setting<Boolean> codyBanners = null;

@Inject(method = "<init>", at = @At(value = "FIELD", target = "Lmeteordevelopment/meteorclient/systems/modules/render/NoRender;noSignText:Lmeteordevelopment/meteorclient/settings/Setting;"))
private void addNoRenderSettings(CallbackInfo ci) {
// See EntityRendererMixin.java
codyPlayer = sgCody.add(
new BoolSetting.Builder()
.name("cody")
.description("Ignore his very existence.")
.defaultValue(false)
.build()
);
codySigns = sgCody.add(
new BoolSetting.Builder()
.name("cody-signs")
.description("Don't render signs which contain the text \"codysmile11\".")
.defaultValue(false)
.build()
);
codyBanners = sgCody.add(
new BoolSetting.Builder()
.name("cody-banners")
.description("Don't render banners which contain \"codysmile11\" in the name.")
.defaultValue(false)
.build()
);
}
}
4 changes: 3 additions & 1 deletion src/main/resources/stardust.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "dev.stardust.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"client": [
"ScreenMixin",
"ChatHudMixin",
Expand All @@ -28,6 +28,7 @@
"accessor.AnvilScreenAccessor",
"accessor.GameOptionsAccessor",
"accessor.MusicTrackerAccessor",
"BannerBlockEntityRendererMixin",
"accessor.SourceManagerAccessor",
"accessor.BookEditScreenAccessor",
"accessor.BookScreenContentsAccessor",
Expand All @@ -48,6 +49,7 @@
"meteor.FreecamMixin",
"meteor.AutoMendMixin",
"meteor.NotifierMixin",
"meteor.NoRenderMixin",
"FireworkRocketEntityMixin",
"meteor.accessor.CategoryAccessor",
"accessor.ClientConnectionAccessor",
Expand Down

0 comments on commit 402799e

Please sign in to comment.