From 75741137d14b90dd48ce17c69f8d23c579133e71 Mon Sep 17 00:00:00 2001 From: doctor4t Date: Mon, 30 Dec 2024 14:10:36 +0100 Subject: [PATCH] Add random block display tick customization --- changelog.md | 7 +++ .../effective/core/EffectiveConfig.java | 17 +++++++ ...layTickBlockMixin.java => BlockMixin.java} | 2 +- ...tWorldMixin.java => ClientWorldMixin.java} | 46 +++++++++++++++---- .../choruspetals/ChorusPetalSpawner.java | 4 +- .../assets/effective/lang/en_us.json | 20 ++++++++ .../resources/effective_core.mixins.json | 4 +- 7 files changed, 85 insertions(+), 15 deletions(-) rename src/client/java/org/ladysnake/effective/core/mixin/{RandomDisplayTickBlockMixin.java => BlockMixin.java} (92%) rename src/client/java/org/ladysnake/effective/core/mixin/{ParticleSpawningClientWorldMixin.java => ClientWorldMixin.java} (61%) diff --git a/changelog.md b/changelog.md index f91e0d7..d11ef52 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +------------------------------------------------------ +Effective 2.4.1 (Alpha) - 1.21.1 +------------------------------------------------------ +- Rewrote underwater chest bubbles and ender chest bubbles + - Added a new particle type for ender chest bubbles instead of changing the regular bubbles' rendering +- Cleaned up particle registration code + ------------------------------------------------------ Effective 2.4 (Alpha) - 1.21.1 ------------------------------------------------------ diff --git a/src/client/java/org/ladysnake/effective/core/EffectiveConfig.java b/src/client/java/org/ladysnake/effective/core/EffectiveConfig.java index 0768799..9b2c193 100644 --- a/src/client/java/org/ladysnake/effective/core/EffectiveConfig.java +++ b/src/client/java/org/ladysnake/effective/core/EffectiveConfig.java @@ -95,6 +95,7 @@ public class EffectiveConfig extends MidnightConfig { public static int cascadeSoundsVolume = 30; @Entry(category = audio, min = 0, max = 400, isSlider = true) public static int cascadeSoundDistanceBlocks = 100; + @Comment(category = audio, centered = true) public static Comment biomeAmbience; @Entry(category = audio, min = 0, max = 100, isSlider = true) @@ -106,6 +107,22 @@ public class EffectiveConfig extends MidnightConfig { @Entry(category = audio, min = 0, max = 100, isSlider = true) public static int animalAmbienceVolume = 100; + /* TECHNICAL CATEGORY */ + public static final String technical = "technical"; + + @Comment(category = technical, centered = true) + public static Comment randomBlockDisplayTicks; + @Comment(category = technical, centered = false) + public static Comment randomBlockDisplayTicksTooltip; + @Comment(category = technical, centered = false) + public static Comment emptyComment1; + @Entry(category = technical, min = 0, max = 25, isSlider = true) + public static float randomBlockDisplayTicksFrequencyMultiplier = 1f; + @Entry(category = technical, min = 0, max = 160, isSlider = true) + public static int randomBlockDisplayTicksDistanceClose = 16; + @Entry(category = technical, min = 0, max = 320, isSlider = true) + public static int randomBlockDisplayTicksDistanceFar = 32; + public static boolean shouldGlowSquidsHypnotize() { return glowSquidHypnotize == GlowSquidHypnoOptions.ATTRACT || glowSquidHypnotize == GlowSquidHypnoOptions.VISUAL; } diff --git a/src/client/java/org/ladysnake/effective/core/mixin/RandomDisplayTickBlockMixin.java b/src/client/java/org/ladysnake/effective/core/mixin/BlockMixin.java similarity index 92% rename from src/client/java/org/ladysnake/effective/core/mixin/RandomDisplayTickBlockMixin.java rename to src/client/java/org/ladysnake/effective/core/mixin/BlockMixin.java index e92807d..b3b2e0e 100644 --- a/src/client/java/org/ladysnake/effective/core/mixin/RandomDisplayTickBlockMixin.java +++ b/src/client/java/org/ladysnake/effective/core/mixin/BlockMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Block.class) -public abstract class RandomDisplayTickBlockMixin { +public abstract class BlockMixin { @Inject(method = "randomDisplayTick", at = @At("RETURN")) protected void effective$randomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/src/client/java/org/ladysnake/effective/core/mixin/ParticleSpawningClientWorldMixin.java b/src/client/java/org/ladysnake/effective/core/mixin/ClientWorldMixin.java similarity index 61% rename from src/client/java/org/ladysnake/effective/core/mixin/ParticleSpawningClientWorldMixin.java rename to src/client/java/org/ladysnake/effective/core/mixin/ClientWorldMixin.java index aba3047..4e64624 100644 --- a/src/client/java/org/ladysnake/effective/core/mixin/ParticleSpawningClientWorldMixin.java +++ b/src/client/java/org/ladysnake/effective/core/mixin/ClientWorldMixin.java @@ -1,7 +1,7 @@ package org.ladysnake.effective.core.mixin; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import net.minecraft.block.Block; -import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.world.ClientWorld; import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.registry.RegistryKey; @@ -16,15 +16,13 @@ import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.dimension.DimensionType; +import org.jetbrains.annotations.Nullable; import org.ladysnake.effective.core.Effective; import org.ladysnake.effective.core.EffectiveConfig; import org.ladysnake.effective.core.utils.EffectiveUtils; -import org.spongepowered.asm.mixin.Final; 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.Slice; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.time.LocalDate; @@ -32,18 +30,46 @@ import java.util.function.Supplier; @Mixin(ClientWorld.class) -public abstract class ParticleSpawningClientWorldMixin extends World { +public abstract class ClientWorldMixin extends World { @Shadow - @Final - private WorldRenderer worldRenderer; + @Nullable + protected abstract Block getBlockParticle(); - protected ParticleSpawningClientWorldMixin(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, Supplier profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) { + @Shadow + public abstract void randomBlockDisplayTick(int centerX, int centerY, int centerZ, int radius, Random random, @Nullable Block block, BlockPos.Mutable pos); + + protected ClientWorldMixin(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, Supplier profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) { super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates); } + @ModifyConstant(method = "doRandomBlockDisplayTicks", constant = @Constant(intValue = 667)) + public int effective$multiplyRandomBlockDisplayTicksFrequency(int constant) { + return Math.round(667 * EffectiveConfig.randomBlockDisplayTicksFrequencyMultiplier); + } + + @ModifyConstant(method = "doRandomBlockDisplayTicks", constant = @Constant(intValue = 16)) + public int effective$overwriteRandomBlockDisplayTicksDistanceClose(int constant) { + return EffectiveConfig.randomBlockDisplayTicksDistanceClose; + } + + @ModifyConstant(method = "doRandomBlockDisplayTicks", constant = @Constant(intValue = 32)) + public int effective$overwriteRandomBlockDisplayTicksDistanceFar(int constant) { + return EffectiveConfig.randomBlockDisplayTicksDistanceFar; + } + + @WrapWithCondition(method = "doRandomBlockDisplayTicks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;randomBlockDisplayTick(IIIILnet/minecraft/util/math/random/Random;Lnet/minecraft/block/Block;Lnet/minecraft/util/math/BlockPos$Mutable;)V", ordinal = 0)) + public boolean effective$cancelRandomBlockDisplayTicksClose(ClientWorld instance, int centerX, int centerY, int centerZ, int radius, Random random, Block block, BlockPos.Mutable pos) { + return EffectiveConfig.randomBlockDisplayTicksDistanceClose > 0; + } + + @WrapWithCondition(method = "doRandomBlockDisplayTicks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;randomBlockDisplayTick(IIIILnet/minecraft/util/math/random/Random;Lnet/minecraft/block/Block;Lnet/minecraft/util/math/BlockPos$Mutable;)V", ordinal = 1)) + public boolean effective$cancelRandomBlockDisplayTicksFar(ClientWorld instance, int centerX, int centerY, int centerZ, int radius, Random random, Block block, BlockPos.Mutable pos) { + return EffectiveConfig.randomBlockDisplayTicksDistanceFar > 0; + } + @Inject(method = "randomBlockDisplayTick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getParticleConfig()Ljava/util/Optional;")), at = @At(value = "INVOKE", target = "Ljava/util/Optional;ifPresent(Ljava/util/function/Consumer;)V", ordinal = 0, shift = At.Shift.AFTER)) - private void randomBlockDisplayTick(int centerX, int centerY, int centerZ, int radius, Random random, Block block, BlockPos.Mutable blockPos, CallbackInfo ci) { + private void effective$spawnEffectsFromRandomBlockDisplayTicks(int centerX, int centerY, int centerZ, int radius, Random random, Block block, BlockPos.Mutable blockPos, CallbackInfo ci) { BlockPos.Mutable pos = blockPos.add(MathHelper.floor(EffectiveUtils.getRandomFloatOrNegative(this.random) * 50), MathHelper.floor(EffectiveUtils.getRandomFloatOrNegative(this.random) * 10), MathHelper.floor(EffectiveUtils.getRandomFloatOrNegative(this.random) * 50)).mutableCopy(); BlockPos.Mutable pos2 = pos.mutableCopy(); RegistryEntry biome = this.getBiome(pos); diff --git a/src/client/java/org/ladysnake/effective/core/mixin/choruspetals/ChorusPetalSpawner.java b/src/client/java/org/ladysnake/effective/core/mixin/choruspetals/ChorusPetalSpawner.java index e8c3468..d6b4390 100644 --- a/src/client/java/org/ladysnake/effective/core/mixin/choruspetals/ChorusPetalSpawner.java +++ b/src/client/java/org/ladysnake/effective/core/mixin/choruspetals/ChorusPetalSpawner.java @@ -7,13 +7,13 @@ import net.minecraft.world.World; import org.ladysnake.effective.core.Effective; import org.ladysnake.effective.core.EffectiveConfig; -import org.ladysnake.effective.core.mixin.RandomDisplayTickBlockMixin; +import org.ladysnake.effective.core.mixin.BlockMixin; import org.ladysnake.effective.core.utils.EffectiveUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChorusFlowerBlock.class) -public abstract class ChorusPetalSpawner extends RandomDisplayTickBlockMixin { +public abstract class ChorusPetalSpawner extends BlockMixin { @Override protected void effective$randomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo ci) { for (int i = 0; i < (6 - state.get(ChorusFlowerBlock.AGE)) * EffectiveConfig.chorusPetalDensity; i++) { diff --git a/src/client/resources/assets/effective/lang/en_us.json b/src/client/resources/assets/effective/lang/en_us.json index 990719d..a940011 100644 --- a/src/client/resources/assets/effective/lang/en_us.json +++ b/src/client/resources/assets/effective/lang/en_us.json @@ -1,9 +1,12 @@ { "effective.subtitles.ambience.waterfall": "Water falls", "effective.subtitles.entity.parry": "I'm not gonna sugarcoat it", + "effective.midnightconfig.title": "Effective Config", "effective.midnightconfig.category.visuals": "Visuals", "effective.midnightconfig.category.audio": "Audio", + "effective.midnightconfig.category.technical": "Technical", + "effective.midnightconfig.waterEffects": "Water", "effective.midnightconfig.splashes": "Enable Splashes", "effective.midnightconfig.splashThreshold": "Splash Velocity Threshold", @@ -21,6 +24,7 @@ "effective.midnightconfig.enum.ChestsOpenOptions.ON_SOUL_SAND": "On Soul Sand", "effective.midnightconfig.enum.ChestsOpenOptions.RANDOMLY": "Randomly", "effective.midnightconfig.enum.ChestsOpenOptions.NEVER": "Never", + "effective.midnightconfig.entityEffects": "Entities", "effective.midnightconfig.glowSquidHypnotize": "Glow Squid Hypnotizing", "effective.midnightconfig.enum.GlowSquidHypnoOptions.ATTRACT": "Attract Cursor", @@ -32,6 +36,7 @@ "effective.midnightconfig.enum.TrailOptions.TWINKLE": "Twinkle only", "effective.midnightconfig.enum.TrailOptions.NONE": "None", "effective.midnightconfig.goldenAllays": "Enable Golden Allays", + "effective.midnightconfig.screenShakeEffects": "Screen Shake", "effective.midnightconfig.screenShakeIntensity": "Screen Shake Intensity", "effective.midnightconfig.wardenScreenShake": "Warden Roars Cause Screen Shake", @@ -46,11 +51,13 @@ "effective.midnightconfig.enum.EyesInTheDarkOptions.HALLOWEEN": "On Halloween", "effective.midnightconfig.enum.EyesInTheDarkOptions.ALWAYS": "Always", "effective.midnightconfig.enum.EyesInTheDarkOptions.NEVER": "Never", + "effective.midnightconfig.improvedEffects": "Improvements", "effective.midnightconfig.improvedFireballs": "Improved Fireballs", "effective.midnightconfig.improvedDragonFireballsAndBreath": "Improved Dragon Fireballs and Breath", "effective.midnightconfig.spectralArrowTrails": "Spectral Arrow Trails", "effective.midnightconfig.improvedGlowSquidParticles": "Improved Glow Squid Particles", + "effective.midnightconfig.miscellaneous": "Miscellaneous", "effective.midnightconfig.sculkDustDensity": "Sculk Dust Density", "effective.midnightconfig.cosmetics": "Enable Cosmetics", @@ -58,13 +65,26 @@ "effective.midnightconfig.enum.CosmeticsOptions.FIRST_PERSON": "Yes and in First Person", "effective.midnightconfig.enum.CosmeticsOptions.DISABLE": "No", "effective.midnightconfig.ultrakill": "ULTRAKILL", + "effective.midnightconfig.cascadeAudio": "Cascade Audio", "effective.midnightconfig.cascadeSoundsVolume": "Cascade Sound Volume", "effective.midnightconfig.cascadeSoundDistanceBlocks": "Distance to Hear Cascades (in blocks)", + "effective.midnightconfig.biomeAmbience": "Ambience", "effective.midnightconfig.windAmbienceVolume": "Wind Volume", "effective.midnightconfig.waterAmbienceVolume": "Water Volume", "effective.midnightconfig.foliageAmbienceVolume": "Foliage Volume", "effective.midnightconfig.animalAmbienceVolume": "Animal Volume", + + "effective.midnightconfig.randomBlockDisplayTicks": "Random Block Display Ticks", + "effective.midnightconfig.randomBlockDisplayTicksTooltip": "Some Minecraft blocks have visual effects that tick randomly. These options override the Vanilla ticker values to allow these effects to play from further or more frequently, e.g. cherry leaves, rain ripples on water, sculk dust spawning, etc...", + "effective.midnightconfig.emptyComment1": "", + "effective.midnightconfig.randomBlockDisplayTicksFrequencyMultiplier": "Frequency Multiplier", + "effective.midnightconfig.randomBlockDisplayTicksFrequencyMultiplier.tooltip": "Multiplies how frequently the game runs random block display ticks. The higher the value, the higher the impact on performance.", + "effective.midnightconfig.randomBlockDisplayTicksDistanceClose": "Close Distance", + "effective.midnightconfig.randomBlockDisplayTicksDistanceClose.tooltip": "Minecraft runs two passes at two distances for random block display ticks to make closer blocks tick more and have further blocks still tick, albeit less. This is the first and closest distance. If you want random block display ticks to be linear and not have closer blocks tick more, you can put this value to 0 and the other one to how far you want random block display ticks.", + "effective.midnightconfig.randomBlockDisplayTicksDistanceFar": "Far Distance", + "effective.midnightconfig.randomBlockDisplayTicksDistanceFar.tooltip": "Minecraft runs two passes at two distances for random block display ticks to make closer blocks tick more and have further blocks still tick, albeit less. This is the first and closest distance.", + "effective:modmenu.dashboard": "Dashboard" } diff --git a/src/client/resources/effective_core.mixins.json b/src/client/resources/effective_core.mixins.json index 82fd397..0670eeb 100644 --- a/src/client/resources/effective_core.mixins.json +++ b/src/client/resources/effective_core.mixins.json @@ -6,8 +6,8 @@ "compatibilityLevel": "JAVA_17", "mixins": [], "client": [ - "ParticleSpawningClientWorldMixin", - "RandomDisplayTickBlockMixin", + "ClientWorldMixin", + "BlockMixin", "allays.GoldenAllayTextureSwapper", "chest_bubbles.UnderwaterChestRandomOpener", "chest_bubbles.UnderwaterEnderChestRandomOpener",