Skip to content

Commit

Permalink
Implement remove snooper tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jan 30, 2023
1 parent d5d3662 commit f73d96e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ All changes are toggleable via the config file.
* Player Speed: Configurable player fly and walk speed
* Remove Realms Button: Removes the redundant Minecraft Realms button from the main menu
* Remove Recipe Book: Removes the recipe book button from GUIs
* Remove Snooper: Forcefully turns off the snooper and hides the snooper settings button from the options menu
* Skip Credits: Skips the credits screen after the player goes through the end podium portal
* Smooth Scrolling: Adds smooth scrolling to every in-game list
* Super Hot Torch: Enables one-time ignition of entities by hitting them with a torch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ public static class TweaksMiscCategory
@Config.Comment("Removes the recipe book button from GUIs")
public boolean utRecipeBookToggle = false;

@Config.Name("Remove Snooper")
@Config.Comment("Forcefully turns off the snooper and hides the snooper settings button from the options menu")
public boolean utSnooperToggle = true;

@Config.Name("Skip Credits")
@Config.Comment("Skips the credits screen after the player goes through the end podium portal")
public boolean utSkipCreditsToggle = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public List<String> getMixinConfigs()
"mixins.tweaks.saddledwandering.json",
"mixins.tweaks.skipcredits.json",
"mixins.tweaks.smoothscrolling.json",
"mixins.tweaks.snooper.client.json",
"mixins.tweaks.spawning.json",
"mixins.tweaks.uncapfps.json",
"mixins.tweaks.xpbottle.json") :
Expand Down Expand Up @@ -168,6 +169,7 @@ public List<String> getMixinConfigs()
"mixins.tweaks.prefixcheck.json",
"mixins.tweaks.redstonelighting.json",
"mixins.tweaks.saddledwandering.json",
"mixins.tweaks.snooper.server.json",
"mixins.tweaks.spawning.json",
"mixins.tweaks.xpbottle.json"
);
Expand Down Expand Up @@ -223,6 +225,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return !firstLaunch && UTConfigParser.isEnabled("B:\"Skip Credits\"=true");
case "mixins.tweaks.smoothscrolling.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Smooth Scrolling\"=true");
case "mixins.tweaks.snooper.client.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Remove Snooper\"=true");
case "mixins.tweaks.uncapfps.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Uncap FPS\"=true");
}
Expand Down Expand Up @@ -307,6 +311,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return !firstLaunch && UTConfigParser.isEnabled("B:\"No Redstone Lighting\"=true");
case "mixins.tweaks.saddledwandering.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"No Saddled Wandering\"=true");
case "mixins.tweaks.snooper.server.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Remove Snooper\"=true");
case "mixins.tweaks.spawning.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Husk & Stray Spawning\"=true");
case "mixins.tweaks.xpbottle.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mod.acgaming.universaltweaks.tweaks.snooper.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Minecraft.class)
public class UTSnooperClient
{
@Shadow
public GameSettings gameSettings;

@Inject(method = "isSnooperEnabled", at = @At("HEAD"), cancellable = true)
public void utSnooperClient(CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfig.TWEAKS_MISC.utSnooperToggle) return;
if (UTConfig.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSnooperClient ::: Disable client snooper");
this.gameSettings.snooperEnabled = false;
cir.setReturnValue(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mod.acgaming.universaltweaks.tweaks.snooper.mixin;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptions;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GuiOptions.class)
public class UTSnooperClientButton extends GuiScreen
{
@Inject(method = "initGui", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 12), cancellable = true)
public void utRemoveSnooperButton(CallbackInfo ci)
{
if (!UTConfig.TWEAKS_MISC.utSnooperToggle) return;
if (UTConfig.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSnooperClientButton ::: Init GUI");
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done")));
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package mod.acgaming.universaltweaks.tweaks.snooper.mixin;

import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.dedicated.PropertyManager;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(DedicatedServer.class)
public class UTSnooperServer
{
@Shadow
private PropertyManager settings;

@Inject(method = "isSnooperEnabled", at = @At("HEAD"), cancellable = true)
public void utSnooperServer(CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfig.TWEAKS_MISC.utSnooperToggle) return;
if (UTConfig.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSnooperServer ::: Disable server snooper");
this.settings.getBooleanProperty("snooper-enabled", false);
this.settings.setProperty("snooper-enabled", false);
cir.setReturnValue(false);
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.snooper.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.snooper.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTSnooperClient", "UTSnooperClientButton"]
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.snooper.server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.snooper.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTSnooperServer"]
}

0 comments on commit f73d96e

Please sign in to comment.