Compare commits

...

9 Commits
1.18 ... 1.20.1

18 changed files with 477 additions and 145 deletions

View File

@ -1,12 +1,16 @@
<center>
<h1 style="vertical-align:center"><img src="./docs/logo.png" width="32"> Super Secret Revival</h1>
</center>
<h1><img src="https://git.oat.zone/oat/super-secret-revival/raw/branch/1.18/docs/logo.png" width="32" height="32">&nbsp;Super Secret Revival</h1>
Faithfully reimplements the Super Secret Settings button that was added in `13w38a` (1.7.2) and removed in `15w31a`
(1.9) to modern versions of Minecraft.
![](./docs/screenshot1.png)
<center>
<a href="https://legacy.curseforge.com/minecraft/mc-mods/fabric-super-secret-settings"><img alt="curseforge" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/curseforge_vector.svg"></a>
<a href="https://modrinth.com/mod/super-secret-revival"><img alt="modrinth" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/modrinth_vector.svg"></a>
<img alt="forge" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/unsupported/forge_vector.svg">
</center>
---
I think a lot about the fact that this feature was randomly left in the release builds, then when we just started

View File

@ -33,10 +33,6 @@ processResources {
}
}
loom {
accessWidenerPath = file("src/main/resources/supersecretrevival.accesswidener")
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is

View File

@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
loader_version=0.14.10
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22
# Mod Properties
mod_version=1.0+1.18
mod_version=1.3+1.20.1
maven_group=zone.oat.supersecretrevival
archives_base_name=super-secret-revival
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.59.1+1.18.2
fabric_version=0.87.0+1.20.1

View File

@ -0,0 +1,39 @@
package zone.oat.supersecretrevival;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Mod implements ClientModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("super-secret-revival");
// also used for identifying the button (Don't Worry about it)
public static final Text BUTTON_TEXT = Text.translatable("options.supersecretrevival.super_secret_settings");
private static KeyBinding disableShaderKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.supersecretrevival.disable", // The translation key of the keybinding's name
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
GLFW.GLFW_KEY_F4, // The keycode of the key
"key.categories.misc" // The translation key of the keybinding's category.
));
public static void triggerSuperSecretSettings() {
ShaderControls.setRandomShader();
RandomSoundPlayer.playRandomSound();
}
@Override
public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (disableShaderKeybind.wasPressed()) {
ShaderControls.disableShader();
}
});
}
}

View File

@ -0,0 +1,129 @@
package zone.oat.supersecretrevival;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import java.util.Arrays;
public class RandomSoundPlayer {
private static final Random RANDOM = Random.create();
// prevent these sounds from playing
//
// in 1.8 this used to be a list of categories;
// however sounds no longer have an association
// to categories so we have to improvise
private static SoundEvent[] soundBlocklist = {
SoundEvents.MUSIC_CREATIVE,
SoundEvents.MUSIC_CREDITS,
SoundEvents.MUSIC_DISC_5,
SoundEvents.MUSIC_DISC_11,
SoundEvents.MUSIC_DISC_13,
SoundEvents.MUSIC_DISC_BLOCKS,
SoundEvents.MUSIC_DISC_CAT,
SoundEvents.MUSIC_DISC_CHIRP,
SoundEvents.MUSIC_DISC_FAR,
SoundEvents.MUSIC_DISC_MALL,
SoundEvents.MUSIC_DISC_MELLOHI,
SoundEvents.MUSIC_DISC_PIGSTEP,
SoundEvents.MUSIC_DISC_STAL,
SoundEvents.MUSIC_DISC_STRAD,
SoundEvents.MUSIC_DISC_WAIT,
SoundEvents.MUSIC_DISC_WARD,
SoundEvents.MUSIC_DISC_OTHERSIDE,
SoundEvents.MUSIC_DRAGON,
SoundEvents.MUSIC_END,
SoundEvents.MUSIC_GAME,
SoundEvents.MUSIC_MENU,
SoundEvents.MUSIC_NETHER_BASALT_DELTAS,
SoundEvents.MUSIC_NETHER_CRIMSON_FOREST,
SoundEvents.MUSIC_OVERWORLD_DEEP_DARK,
SoundEvents.MUSIC_OVERWORLD_DRIPSTONE_CAVES,
SoundEvents.MUSIC_OVERWORLD_GROVE,
SoundEvents.MUSIC_OVERWORLD_JAGGED_PEAKS,
SoundEvents.MUSIC_OVERWORLD_LUSH_CAVES,
SoundEvents.MUSIC_OVERWORLD_SWAMP,
SoundEvents.MUSIC_OVERWORLD_JUNGLE_AND_FOREST,
SoundEvents.MUSIC_OVERWORLD_OLD_GROWTH_TAIGA,
SoundEvents.MUSIC_OVERWORLD_MEADOW,
SoundEvents.MUSIC_NETHER_NETHER_WASTES,
SoundEvents.MUSIC_OVERWORLD_FROZEN_PEAKS,
SoundEvents.MUSIC_OVERWORLD_SNOWY_SLOPES,
SoundEvents.MUSIC_NETHER_SOUL_SAND_VALLEY,
SoundEvents.MUSIC_OVERWORLD_STONY_PEAKS,
SoundEvents.MUSIC_NETHER_WARPED_FOREST,
SoundEvents.MUSIC_UNDER_WATER,
SoundEvents.AMBIENT_CAVE,
SoundEvents.AMBIENT_BASALT_DELTAS_ADDITIONS,
SoundEvents.AMBIENT_BASALT_DELTAS_LOOP,
SoundEvents.AMBIENT_BASALT_DELTAS_MOOD,
SoundEvents.AMBIENT_CRIMSON_FOREST_ADDITIONS,
SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP,
SoundEvents.AMBIENT_CRIMSON_FOREST_MOOD,
SoundEvents.AMBIENT_NETHER_WASTES_ADDITIONS,
SoundEvents.AMBIENT_NETHER_WASTES_LOOP,
SoundEvents.AMBIENT_NETHER_WASTES_MOOD,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_LOOP,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD,
SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS,
SoundEvents.AMBIENT_WARPED_FOREST_LOOP,
SoundEvents.AMBIENT_WARPED_FOREST_MOOD,
SoundEvents.AMBIENT_UNDERWATER_ENTER,
SoundEvents.AMBIENT_UNDERWATER_EXIT,
SoundEvents.AMBIENT_UNDERWATER_LOOP,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE,
};
private static SoundEvent getRandomSound(Random random) {
SoundEvent event;
do {
Registry<SoundEvent> registry = Registry.SOUND_EVENT;
int size = registry.size();
int rand = random.nextInt(size);
event = registry.get(rand);
} while (Arrays.asList(soundBlocklist).contains(event));
return event;
}
// money back guarantee. Bill mays. Phil swif
// In this phrase "money-back" is an adjective and needs to be spelled with a hyphen.
// Incorrect: We offer a 14-day money back guarantee.
// Correct: We offer a 14-day money-back guarantee.
public static void guaranteedPlaySound(SoundEvent sound, float volume, float pitch) {
MinecraftClient client = MinecraftClient.getInstance();
World world = client.world;
if (world instanceof ClientWorld) {
world.playSound(
client.player,
client.player.getBlockPos(),
sound,
SoundCategory.MASTER,
volume,
pitch
);
} else {
client.getSoundManager().play(PositionedSoundInstance.master(sound, pitch));
}
}
public static void playRandomSound() {
SoundEvent sound = getRandomSound(RANDOM);
guaranteedPlaySound(sound, 1f, 0.5f);
}
}

View File

@ -0,0 +1,21 @@
package zone.oat.supersecretrevival;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.util.Identifier;
import zone.oat.supersecretrevival.mixin.GameRendererAccessorMixin;
public class ShaderControls {
private static final GameRenderer renderer = MinecraftClient.getInstance().gameRenderer;
public static void setRandomShader() {
Identifier shader = GameRendererAccessorMixin.getShaderLocations()[((GameRendererAccessorMixin) renderer).getRandom().nextInt(GameRenderer.SHADER_COUNT)];
Mod.LOGGER.info("Loading shader " + shader.getPath());
((GameRendererAccessorMixin) renderer).invokeLoadShader(shader);
}
public static void disableShader() {
Mod.LOGGER.info("Disabling all shaders");
renderer.disableShader();
}
}

View File

@ -0,0 +1,21 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.text.Text;
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.CallbackInfo;
import zone.oat.supersecretrevival.Mod;
@Mixin(ClickableWidget.class)
public class CancelClickSoundMixin {
@Shadow private Text message;
@Inject(method = "playDownSound", at = @At(value = "HEAD"), cancellable = true)
private void injected(SoundManager soundManager, CallbackInfo ci) {
if (this.message != null && this.message.equals(Mod.BUTTON_TEXT)) ci.cancel();
}
}

View File

@ -0,0 +1,22 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.util.math.random.Random;
@Mixin(GameRenderer.class)
public interface GameRendererAccessorMixin {
@Accessor
Random getRandom();
@Accessor("SHADERS_LOCATIONS")
public static Identifier[] getShaderLocations() {
throw new AssertionError();
}
@Invoker("loadShader")
public void invokeLoadShader(Identifier id);
}

View File

@ -0,0 +1,33 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
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;
import zone.oat.supersecretrevival.Mod;
@Mixin(OptionsScreen.class)
public class SecretSettingsButtonMixin extends Screen {
protected SecretSettingsButtonMixin(Text title) {
super(title);
}
@Inject(at = @At("HEAD"),method = "init")
private void injected(CallbackInfo ci) {
ButtonWidget b = new ButtonWidget(
this.width / 2 + 5,
this.height / 6 + 18,
150,
20,
Mod.BUTTON_TEXT,
(button) -> {
Mod.triggerSuperSecretSettings();
}
);
this.addDrawableChild(b);
}
}

View File

@ -3,28 +3,19 @@ package zone.oat.supersecretrevival;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderEffect;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Mod implements ClientModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("super-secret-revival");
// also used for identifying the button (Don't Worry about it)
public static final Text BUTTON_TEXT = Text.translatable("options.supersecretrevival.super_secret_settings");
private static KeyBinding disableShaderKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.supersecretrevival.disable", // The translation key of the keybinding's name
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
@ -32,103 +23,9 @@ public class Mod implements ClientModInitializer {
"key.categories.misc" // The translation key of the keybinding's category.
));
// prevent these sounds from playing
//
// in 1.8 this used to be a list of categories;
// however sounds no longer have an association
// to categories so we have to improvise
private static SoundEvent[] soundBlocklist = {
SoundEvents.MUSIC_CREATIVE,
SoundEvents.MUSIC_CREDITS,
SoundEvents.MUSIC_DISC_11,
SoundEvents.MUSIC_DISC_13,
SoundEvents.MUSIC_DISC_BLOCKS,
SoundEvents.MUSIC_DISC_CAT,
SoundEvents.MUSIC_DISC_CHIRP,
SoundEvents.MUSIC_DISC_FAR,
SoundEvents.MUSIC_DISC_MALL,
SoundEvents.MUSIC_DISC_MELLOHI,
SoundEvents.MUSIC_DISC_PIGSTEP,
SoundEvents.MUSIC_DISC_STAL,
SoundEvents.MUSIC_DISC_STRAD,
SoundEvents.MUSIC_DISC_WAIT,
SoundEvents.MUSIC_DISC_WARD,
SoundEvents.MUSIC_DISC_OTHERSIDE,
SoundEvents.MUSIC_DRAGON,
SoundEvents.MUSIC_END,
SoundEvents.MUSIC_GAME,
SoundEvents.MUSIC_MENU,
SoundEvents.MUSIC_NETHER_BASALT_DELTAS,
SoundEvents.MUSIC_NETHER_CRIMSON_FOREST,
SoundEvents.MUSIC_OVERWORLD_DRIPSTONE_CAVES,
SoundEvents.MUSIC_OVERWORLD_GROVE,
SoundEvents.MUSIC_OVERWORLD_JAGGED_PEAKS,
SoundEvents.MUSIC_OVERWORLD_LUSH_CAVES,
SoundEvents.MUSIC_OVERWORLD_MEADOW,
SoundEvents.MUSIC_NETHER_NETHER_WASTES,
SoundEvents.MUSIC_OVERWORLD_FROZEN_PEAKS,
SoundEvents.MUSIC_OVERWORLD_SNOWY_SLOPES,
SoundEvents.MUSIC_NETHER_SOUL_SAND_VALLEY,
SoundEvents.MUSIC_OVERWORLD_STONY_PEAKS,
SoundEvents.MUSIC_NETHER_WARPED_FOREST,
SoundEvents.MUSIC_UNDER_WATER,
SoundEvents.AMBIENT_CAVE,
SoundEvents.AMBIENT_BASALT_DELTAS_ADDITIONS,
SoundEvents.AMBIENT_BASALT_DELTAS_LOOP,
SoundEvents.AMBIENT_BASALT_DELTAS_MOOD,
SoundEvents.AMBIENT_CRIMSON_FOREST_ADDITIONS,
SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP,
SoundEvents.AMBIENT_CRIMSON_FOREST_MOOD,
SoundEvents.AMBIENT_NETHER_WASTES_ADDITIONS,
SoundEvents.AMBIENT_NETHER_WASTES_LOOP,
SoundEvents.AMBIENT_NETHER_WASTES_MOOD,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_LOOP,
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD,
SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS,
SoundEvents.AMBIENT_WARPED_FOREST_LOOP,
SoundEvents.AMBIENT_WARPED_FOREST_MOOD,
SoundEvents.AMBIENT_UNDERWATER_ENTER,
SoundEvents.AMBIENT_UNDERWATER_EXIT,
SoundEvents.AMBIENT_UNDERWATER_LOOP,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE,
};
private static SoundEvent getRandomSound(Random random) {
SoundEvent event;
do {
Registry<SoundEvent> registry = Registry.SOUND_EVENT;
int size = registry.size();
int rand = random.nextInt(size);
event = registry.get(rand);
} while (Arrays.asList(soundBlocklist).contains(event));
return event;
}
public static void triggerSuperSecretSettings() {
MinecraftClient client = MinecraftClient.getInstance();
World world = client.world;
if (world instanceof ClientWorld) {
ShaderControls.setRandomShader();
// play a random noise
SoundEvent sound = getRandomSound(world.random);
world.playSound(
client.player,
client.player.getBlockPos(),
sound,
null,
1f,
0.5f
);
}
ShaderControls.setRandomShader();
RandomSoundPlayer.playRandomSound();
}
@Override

View File

@ -0,0 +1,139 @@
package zone.oat.supersecretrevival;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import java.util.Arrays;
public class RandomSoundPlayer {
private static final Random RANDOM = Random.create();
// prevent these sounds from playing
//
// in 1.8 this used to be a list of categories;
// however sounds no longer have an association
// to categories so we have to improvise
private static SoundEvent[] soundBlocklist = {
SoundEvents.MUSIC_CREATIVE.value(),
SoundEvents.MUSIC_CREDITS.value(),
SoundEvents.MUSIC_DISC_5,
SoundEvents.MUSIC_DISC_11,
SoundEvents.MUSIC_DISC_13,
SoundEvents.MUSIC_DISC_BLOCKS,
SoundEvents.MUSIC_DISC_CAT,
SoundEvents.MUSIC_DISC_CHIRP,
SoundEvents.MUSIC_DISC_FAR,
SoundEvents.MUSIC_DISC_MALL,
SoundEvents.MUSIC_DISC_MELLOHI,
SoundEvents.MUSIC_DISC_PIGSTEP,
SoundEvents.MUSIC_DISC_STAL,
SoundEvents.MUSIC_DISC_STRAD,
SoundEvents.MUSIC_DISC_WAIT,
SoundEvents.MUSIC_DISC_WARD,
SoundEvents.MUSIC_DISC_OTHERSIDE,
SoundEvents.MUSIC_DISC_RELIC,
SoundEvents.MUSIC_DRAGON.value(),
SoundEvents.MUSIC_END.value(),
SoundEvents.MUSIC_GAME.value(),
SoundEvents.MUSIC_MENU.value(),
SoundEvents.MUSIC_NETHER_BASALT_DELTAS.value(),
SoundEvents.MUSIC_NETHER_CRIMSON_FOREST.value(),
SoundEvents.MUSIC_OVERWORLD_DEEP_DARK.value(),
SoundEvents.MUSIC_OVERWORLD_DRIPSTONE_CAVES.value(),
SoundEvents.MUSIC_OVERWORLD_GROVE.value(),
SoundEvents.MUSIC_OVERWORLD_JAGGED_PEAKS.value(),
SoundEvents.MUSIC_OVERWORLD_LUSH_CAVES.value(),
SoundEvents.MUSIC_OVERWORLD_SWAMP.value(),
SoundEvents.MUSIC_OVERWORLD_FOREST.value(),
SoundEvents.MUSIC_OVERWORLD_OLD_GROWTH_TAIGA.value(),
SoundEvents.MUSIC_OVERWORLD_MEADOW.value(),
SoundEvents.MUSIC_OVERWORLD_CHERRY_GROVE.value(),
SoundEvents.MUSIC_NETHER_NETHER_WASTES.value(),
SoundEvents.MUSIC_OVERWORLD_FROZEN_PEAKS.value(),
SoundEvents.MUSIC_OVERWORLD_SNOWY_SLOPES.value(),
SoundEvents.MUSIC_NETHER_SOUL_SAND_VALLEY.value(),
SoundEvents.MUSIC_OVERWORLD_STONY_PEAKS.value(),
SoundEvents.MUSIC_NETHER_WARPED_FOREST.value(),
SoundEvents.MUSIC_OVERWORLD_FLOWER_FOREST.value(),
SoundEvents.MUSIC_OVERWORLD_DESERT.value(),
SoundEvents.MUSIC_OVERWORLD_BADLANDS.value(),
SoundEvents.MUSIC_OVERWORLD_JUNGLE.value(),
SoundEvents.MUSIC_OVERWORLD_SPARSE_JUNGLE.value(),
SoundEvents.MUSIC_OVERWORLD_BAMBOO_JUNGLE.value(),
SoundEvents.MUSIC_UNDER_WATER.value(),
SoundEvents.AMBIENT_CAVE.value(),
SoundEvents.AMBIENT_BASALT_DELTAS_ADDITIONS.value(),
SoundEvents.AMBIENT_BASALT_DELTAS_LOOP.value(),
SoundEvents.AMBIENT_BASALT_DELTAS_MOOD.value(),
SoundEvents.AMBIENT_CRIMSON_FOREST_ADDITIONS.value(),
SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP.value(),
SoundEvents.AMBIENT_CRIMSON_FOREST_MOOD.value(),
SoundEvents.AMBIENT_NETHER_WASTES_ADDITIONS.value(),
SoundEvents.AMBIENT_NETHER_WASTES_LOOP.value(),
SoundEvents.AMBIENT_NETHER_WASTES_MOOD.value(),
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS.value(),
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_LOOP.value(),
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD.value(),
SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS.value(),
SoundEvents.AMBIENT_WARPED_FOREST_LOOP.value(),
SoundEvents.AMBIENT_WARPED_FOREST_MOOD.value(),
SoundEvents.AMBIENT_UNDERWATER_ENTER,
SoundEvents.AMBIENT_UNDERWATER_EXIT,
SoundEvents.AMBIENT_UNDERWATER_LOOP,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE,
SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE,
};
private static SoundEvent getRandomSound(Random random) {
SoundEvent event;
do {
Registry<SoundEvent> registry = Registries.SOUND_EVENT;
int size = registry.size();
int rand = random.nextInt(size);
event = registry.get(rand);
} while (Arrays.asList(soundBlocklist).contains(event));
return event;
}
// money back guarantee. Bill mays. Phil swif
// In this phrase "money-back" is an adjective and needs to be spelled with a hyphen.
// Incorrect: We offer a 14-day money back guarantee.
// Correct: We offer a 14-day money-back guarantee.
public static void guaranteedPlaySound(SoundEvent sound, float volume, float pitch) {
MinecraftClient client = MinecraftClient.getInstance();
World world = client.world;
if (world instanceof ClientWorld) {
world.playSound(
client.player,
client.player.getBlockPos(),
sound,
SoundCategory.MASTER,
volume,
pitch
);
} else {
client.getSoundManager().play(PositionedSoundInstance.master(sound, pitch));
}
}
public static void playRandomSound() {
SoundEvent sound = getRandomSound(RANDOM);
guaranteedPlaySound(sound, 1f, 0.5f);
}
}

View File

@ -3,18 +3,19 @@ package zone.oat.supersecretrevival;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.util.Identifier;
import zone.oat.supersecretrevival.mixin.GameRendererAccessorMixin;
public class ShaderControls {
private static final GameRenderer renderer = MinecraftClient.getInstance().gameRenderer;
public static void setRandomShader() {
Identifier shader = GameRenderer.SHADERS_LOCATIONS[renderer.random.nextInt(GameRenderer.SHADER_COUNT)];
Identifier shader = GameRendererAccessorMixin.getShaderLocations()[((GameRendererAccessorMixin) renderer).getRandom().nextInt(GameRenderer.SUPER_SECRET_SETTING_COUNT)];
Mod.LOGGER.info("Loading shader " + shader.getPath());
renderer.loadShader(shader);
((GameRendererAccessorMixin) renderer).invokeLoadShader(shader);
}
public static void disableShader() {
Mod.LOGGER.info("Disabling all shaders");
renderer.disableShader();
renderer.disablePostProcessor();
}
}

View File

@ -0,0 +1,21 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.text.Text;
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.CallbackInfo;
import zone.oat.supersecretrevival.Mod;
@Mixin(ClickableWidget.class)
public class CancelClickSoundMixin {
@Shadow private Text message;
@Inject(method = "playDownSound", at = @At(value = "HEAD"), cancellable = true)
private void injected(SoundManager soundManager, CallbackInfo ci) {
if (this.message != null && this.message.equals(Mod.BUTTON_TEXT)) ci.cancel();
}
}

View File

@ -0,0 +1,22 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.util.math.random.Random;
@Mixin(GameRenderer.class)
public interface GameRendererAccessorMixin {
@Accessor
Random getRandom();
@Accessor("SUPER_SECRET_SETTING_PROGRAMS")
public static Identifier[] getShaderLocations() {
throw new AssertionError();
}
@Invoker("loadPostProcessor")
public void invokeLoadShader(Identifier id);
}

View File

@ -1,10 +1,10 @@
package zone.oat.supersecretrevival.mixin;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OnlineOptionsScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -19,16 +19,9 @@ public class SecretSettingsButtonMixin extends Screen {
@Inject(at = @At("HEAD"),method = "init")
private void injected(CallbackInfo ci) {
ButtonWidget b = new ButtonWidget(
this.width / 2 + 5,
this.height / 6 + 18,
150,
20,
new TranslatableText("options.supersecretrevival.super_secret_settings"),
(button) -> {
Mod.triggerSuperSecretSettings();
}
);
ButtonWidget b = ButtonWidget.builder(Mod.BUTTON_TEXT, (button) -> {
Mod.triggerSuperSecretSettings();
}).dimensions(this.width / 2 + 5, this.height / 6 + 18, 150, 20).build();
this.addDrawableChild(b);
}
}

View File

@ -28,8 +28,8 @@
],
"depends": {
"fabricloader": ">=0.14.10",
"fabricloader": ">=0.14.22",
"fabric": "*",
"minecraft": "~1.18"
"minecraft": ["1.20.1"]
}
}

View File

@ -1,8 +0,0 @@
accessWidener v1 named
# Lnet/minecraft/client/render/GameRenderer;SHADERS_LOCATIONS:[Lnet/minecraft/util/Identifier;
accessible field net/minecraft/client/render/GameRenderer SHADERS_LOCATIONS [Lnet/minecraft/util/Identifier;
# Lnet/minecraft/client/render/GameRenderer;random:Ljava/util/Random;
accessible field net/minecraft/client/render/GameRenderer random Ljava/util/Random;
# Lnet/minecraft/client/render/GameRenderer;loadShader(Lnet/minecraft/util/Identifier;)V
accessible method net/minecraft/client/render/GameRenderer loadShader (Lnet/minecraft/util/Identifier;)V

View File

@ -5,6 +5,8 @@
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [
"CancelClickSoundMixin",
"GameRendererAccessorMixin",
"SecretSettingsButtonMixin"
],
"server": [],