-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AntiToS - Now censors item, entity, & inventory screen names.
- Loading branch information
Showing
9 changed files
with
195 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
|
||
/** | ||
* @author Tas [@0xTas] <[email protected]> | ||
**/ | ||
|
@@ -96,7 +95,7 @@ private void mixinInit(CallbackInfo ci) { | |
List<String> pages = ((WrittenBookContentsAccessor) this.contents).getPages(); | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
BookTools bookTools = modules.get(BookTools.class); | ||
if (antiToS.isActive() && antiToS.booksSetting.get()) { | ||
if (antiToS.isActive()) { | ||
List<String> filtered = new ArrayList<>(); | ||
for (String page : pages) { | ||
if (antiToS.containsBlacklistedText(page)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.stardust.mixin; | ||
|
||
import net.minecraft.text.Text; | ||
import dev.stardust.modules.AntiToS; | ||
import net.minecraft.entity.boss.BossBar; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.hud.BossBarHud; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(BossBarHud.class) | ||
public class BossBarHudMixin { | ||
|
||
// See AntiToS.java | ||
@Inject(method = "renderBossBar(Lnet/minecraft/client/gui/DrawContext;IILnet/minecraft/entity/boss/BossBar;)V", at = @At("HEAD")) | ||
private void censorBossBar(DrawContext context, int x, int y, BossBar bossBar, CallbackInfo ci) { | ||
Modules modules = Modules.get(); | ||
if (modules == null) return; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return; | ||
|
||
if (antiToS.containsBlacklistedText(bossBar.getName().getString())) { | ||
bossBar.setName(Text.literal(antiToS.censorText(bossBar.getName().getString()).formatted(bossBar.getName().getStyle()))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,14 @@ | |
|
||
import net.minecraft.text.Text; | ||
import dev.stardust.modules.AntiToS; | ||
import net.minecraft.text.MutableText; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import net.minecraft.client.gui.hud.ChatHud; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
|
||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
|
@@ -25,7 +27,17 @@ private Text censorChatMessage(Text message) { | |
Modules modules = Modules.get(); | ||
if (modules == null) return message; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive() || !antiToS.chatSetting.get()) return message; | ||
return (antiToS.containsBlacklistedText(message.getString()) ? Text.of(antiToS.censorText(message.getString())) : message); | ||
if (!antiToS.isActive()) return message; | ||
MutableText mText = Text.literal(antiToS.censorText(message.getString())); | ||
return (antiToS.containsBlacklistedText(message.getString()) ? mText.setStyle(message.getStyle()) : message); | ||
} | ||
|
||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) | ||
private void maybeCancelAddMessage(Text message, CallbackInfo ci) { | ||
Modules modules = Modules.get(); | ||
if (modules == null) return; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return; | ||
if (antiToS.chatMode.get() == AntiToS.ChatMode.Remove && antiToS.containsBlacklistedText(message.getString())) ci.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.stardust.mixin; | ||
|
||
import net.minecraft.text.Text; | ||
import dev.stardust.modules.AntiToS; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(EntityRenderer.class) | ||
public abstract class EntityRendererMixin { | ||
|
||
// See AntiToS.java | ||
@ModifyVariable(method = "renderLabelIfPresent", at = @At("HEAD"), argsOnly = true) | ||
private Text censorEntityName(Text name) { | ||
Modules modules = Modules.get(); | ||
if (modules == null) return name; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return name; | ||
|
||
if (!antiToS.containsBlacklistedText(name.getString())) return name; | ||
return Text.literal(antiToS.censorText(name.getString())).setStyle(name.getStyle()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dev.stardust.mixin; | ||
|
||
import net.minecraft.text.Text; | ||
import dev.stardust.modules.AntiToS; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.text.MutableText; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import net.minecraft.client.gui.DrawContext; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(InGameHud.class) | ||
public class InGameHudMixin { | ||
@Shadow | ||
private ItemStack currentStack; | ||
|
||
// See AntiToS.java | ||
@Inject( | ||
method = "renderHeldItemTooltip", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;hasCustomName()Z", shift = At.Shift.BEFORE) | ||
) | ||
private void censorItemTooltip(DrawContext context, CallbackInfo ci, @Local LocalRef<MutableText> itemName) { | ||
if (this.currentStack.isEmpty()) return; | ||
|
||
Modules modules = Modules.get(); | ||
if (modules == null) return; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return; | ||
|
||
if (antiToS.containsBlacklistedText(itemName.get().getString())) { | ||
itemName.set(Text.empty().append(antiToS.censorText(itemName.get().getString())).formatted(this.currentStack.getRarity().formatting)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package dev.stardust.mixin; | ||
|
||
import java.util.List; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Rarity; | ||
import dev.stardust.modules.AntiToS; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.text.MutableText; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.jetbrains.annotations.Nullable; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import meteordevelopment.meteorclient.systems.modules.Modules; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(ItemStack.class) | ||
public abstract class ItemStackMixin { | ||
@Shadow | ||
public abstract Rarity getRarity(); | ||
|
||
// See AntiToS.java | ||
@Inject(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;hasCustomName()Z", shift = At.Shift.BEFORE)) | ||
private void censorItemTooltip(@Nullable PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir, @Local(ordinal = 0)LocalRef<MutableText> name) { | ||
Modules modules = Modules.get(); | ||
if (modules == null) return; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return; | ||
|
||
if (antiToS.containsBlacklistedText(name.get().getString())) { | ||
name.set(Text.empty().append(antiToS.censorText(name.get().getString()).formatted(this.getRarity().formatting))); | ||
} | ||
} | ||
|
||
@Inject(method = "toHoverableText", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;hasCustomName()Z", shift = At.Shift.BEFORE)) | ||
private void censorHoveredText(CallbackInfoReturnable<Text> cir, @Local(ordinal = 0)LocalRef<MutableText> name) { | ||
Modules modules = Modules.get(); | ||
if (modules == null) return; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive()) return; | ||
|
||
if (antiToS.containsBlacklistedText(name.get().getString())) { | ||
name.set(Text.empty().append(antiToS.censorText(name.get().getString()))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import net.minecraft.client.render.block.entity.BlockEntityRenderer; | ||
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer; | ||
|
||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
|
@@ -26,7 +25,7 @@ private SignText modifyRenderedText(SignText signText) { | |
Modules modules = Modules.get(); | ||
if (modules == null ) return signText; | ||
AntiToS antiToS = modules.get(AntiToS.class); | ||
if (!antiToS.isActive() || !antiToS.signsSetting.get()) return signText; | ||
if (!antiToS.isActive()) return signText; | ||
|
||
String testText = Arrays.stream(signText.getMessages(false)) | ||
.map(Text::getString) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
import meteordevelopment.meteorclient.settings.*; | ||
import meteordevelopment.meteorclient.systems.modules.Module; | ||
|
||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
|
@@ -30,79 +29,66 @@ public enum SignMode { | |
Censor, Replace | ||
} | ||
|
||
public final Setting<Boolean> chatSetting = sgSources.add( | ||
new BoolSetting.Builder() | ||
.name("Chat Messages") | ||
.description("Censor text in chat if it matches the content blacklist.") | ||
.defaultValue(true) | ||
.build() | ||
); | ||
|
||
public final Setting<Boolean> booksSetting = sgSources.add( | ||
new BoolSetting.Builder() | ||
.name("Book Text") | ||
.description("Censor text in books if it matches the content blacklist.") | ||
.defaultValue(true) | ||
.build() | ||
); | ||
public enum ChatMode { | ||
Censor, Remove | ||
} | ||
|
||
public final Setting<Boolean> signsSetting = sgSources.add( | ||
new BoolSetting.Builder() | ||
.name("Sign Text") | ||
.description("Filter sign text according to the content blacklist.") | ||
.defaultValue(true) | ||
public final Setting<ChatMode> chatMode = sgSources.add( | ||
new EnumSetting.Builder<ChatMode>() | ||
.name("Sign Mode") | ||
.description("Censor or completely replace SignText that matches the filter.") | ||
.defaultValue(ChatMode.Censor) | ||
.build() | ||
); | ||
private final Setting<SignMode> signMode = sgSources.add( | ||
new EnumSetting.Builder<SignMode>() | ||
.name("Sign Mode") | ||
.description("Censor or completely replace SignText that matches the filter.") | ||
.defaultValue(SignMode.Censor) | ||
.visible(signsSetting::get) | ||
.build() | ||
); | ||
private final Setting<String> familyFriendlyLine1 = sgSources.add( | ||
new StringSetting.Builder() | ||
.name("Replacement Line 1") | ||
.defaultValue("Original text") | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
private final Setting<String> familyFriendlyLine2 = sgSources.add( | ||
new StringSetting.Builder() | ||
.name("Replacement Line 2") | ||
.defaultValue("was replaced by") | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
private final Setting<String> familyFriendlyLine3 = sgSources.add( | ||
new StringSetting.Builder() | ||
.name("Replacement Line 3") | ||
.defaultValue("Stardust AntiToS") | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
private final Setting<String> familyFriendlyLine4 = sgSources.add( | ||
new StringSetting.Builder() | ||
.name("Replacement Line 4") | ||
.defaultValue("plz no ban ☺") | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
private final Setting<DyeColor> familyFriendlyColor = sgSources.add( | ||
new EnumSetting.Builder<DyeColor>() | ||
.name("Replacement Color") | ||
.description("Render replacement SignText with the selected dye color.") | ||
.defaultValue(DyeColor.RED) | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
private final Setting<Boolean> familyFriendlyGlowing = sgSources.add( | ||
new BoolSetting.Builder() | ||
.name("Replacement Glowing") | ||
.description("Render replacement SignText with glowing text.") | ||
.defaultValue(true) | ||
.visible(() -> signsSetting.get() && signMode.get() == SignMode.Replace) | ||
.visible(() -> signMode.get() == SignMode.Replace) | ||
.build() | ||
); | ||
|
||
|
@@ -141,7 +127,11 @@ private void initBlacklistText() { | |
} | ||
|
||
// See ChatHudMixin.java | ||
// && ItemStackMixin.java | ||
// && InGameHudMixin.java | ||
// && BookScreenMixin.java | ||
// && TextRendererMixin.java | ||
// && EntityRendererMixin.java | ||
// && SignBlockEntityRendererMixin.java | ||
public boolean containsBlacklistedText(String text) { | ||
return blacklisted.stream().anyMatch(line -> text.trim().toLowerCase().contains(line.trim().toLowerCase())); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters