Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
Jill | bca7d5185b | ||
Jill | b2cc5c7c93 | ||
Jill | d68e28ba0a | ||
Jill | 805a99b17e | ||
Jill | dfe9d5f54e | ||
Jill | c7cce9a4b8 |
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@ minecraft_version=1.18.2
|
|||
yarn_mappings=1.18.2+build.4
|
||||
loader_version=0.14.10
|
||||
# Mod Properties
|
||||
mod_version=1.0+1.18
|
||||
mod_version=1.3+1.18
|
||||
maven_group=zone.oat.supersecretrevival
|
||||
archives_base_name=super-secret-revival
|
||||
# Dependencies
|
||||
|
|
|
@ -3,28 +3,20 @@ 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 net.minecraft.text.TranslatableText;
|
||||
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 = new TranslatableText("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 +24,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
|
||||
|
|
124
src/main/java/zone/oat/supersecretrevival/RandomSoundPlayer.java
Normal file
124
src/main/java/zone/oat/supersecretrevival/RandomSoundPlayer.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
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.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomSoundPlayer {
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
|
@ -3,14 +3,15 @@ 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.SHADER_COUNT)];
|
||||
Mod.LOGGER.info("Loading shader " + shader.getPath());
|
||||
renderer.loadShader(shader);
|
||||
((GameRendererAccessorMixin) renderer).invokeLoadShader(shader);
|
||||
}
|
||||
|
||||
public static void disableShader() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
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 java.util.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);
|
||||
}
|
|
@ -24,7 +24,7 @@ public class SecretSettingsButtonMixin extends Screen {
|
|||
this.height / 6 + 18,
|
||||
150,
|
||||
20,
|
||||
new TranslatableText("options.supersecretrevival.super_secret_settings"),
|
||||
Mod.BUTTON_TEXT,
|
||||
(button) -> {
|
||||
Mod.triggerSuperSecretSettings();
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -5,6 +5,8 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [],
|
||||
"client": [
|
||||
"CancelClickSoundMixin",
|
||||
"GameRendererAccessorMixin",
|
||||
"SecretSettingsButtonMixin"
|
||||
],
|
||||
"server": [],
|
||||
|
|
Loading…
Reference in a new issue