1.20.1 port

This commit is contained in:
Jill 2023-08-27 16:59:33 +03:00
parent 2cb79838d3
commit 3415c1b2ba
Signed by: oat
GPG Key ID: 33489AA58A955108
12 changed files with 332 additions and 63 deletions

View File

@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
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.3+1.19
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.64.0+1.19.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,11 +3,13 @@ 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.util.registry.Registry;
import net.minecraft.world.World;
import java.util.Arrays;
@ -23,8 +25,8 @@ public class RandomSoundPlayer {
// to categories so we have to improvise
private static SoundEvent[] soundBlocklist = {
SoundEvents.MUSIC_CREATIVE,
SoundEvents.MUSIC_CREDITS,
SoundEvents.MUSIC_CREATIVE.value(),
SoundEvents.MUSIC_CREDITS.value(),
SoundEvents.MUSIC_DISC_5,
SoundEvents.MUSIC_DISC_11,
SoundEvents.MUSIC_DISC_13,
@ -40,45 +42,53 @@ public class RandomSoundPlayer {
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.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,
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_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,
@ -91,7 +101,7 @@ public class RandomSoundPlayer {
SoundEvent event;
do {
Registry<SoundEvent> registry = Registry.SOUND_EVENT;
Registry<SoundEvent> registry = Registries.SOUND_EVENT;
int size = registry.size();
int rand = random.nextInt(size);
event = registry.get(rand);

View File

@ -9,13 +9,13 @@ 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)];
Identifier shader = GameRendererAccessorMixin.getShaderLocations()[((GameRendererAccessorMixin) renderer).getRandom().nextInt(GameRenderer.SUPER_SECRET_SETTING_COUNT)];
Mod.LOGGER.info("Loading shader " + shader.getPath());
((GameRendererAccessorMixin) renderer).invokeLoadShader(shader);
}
public static void disableShader() {
Mod.LOGGER.info("Disabling all shaders");
renderer.disableShader();
renderer.disablePostProcessor();
}
}

View File

@ -12,11 +12,11 @@ public interface GameRendererAccessorMixin {
@Accessor
Random getRandom();
@Accessor("SHADERS_LOCATIONS")
@Accessor("SUPER_SECRET_SETTING_PROGRAMS")
public static Identifier[] getShaderLocations() {
throw new AssertionError();
}
@Invoker("loadShader")
@Invoker("loadPostProcessor")
public void invokeLoadShader(Identifier id);
}

View File

@ -1,6 +1,7 @@
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;
@ -18,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,
Mod.BUTTON_TEXT,
(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.19", "1.19.1", "1.19.2"]
"minecraft": ["1.20.1"]
}
}