Skip to content

Commit

Permalink
Add random block display tick customization
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Dec 30, 2024
1 parent 87b7b41 commit 7574113
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 15 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions src/client/java/org/ladysnake/effective/core/EffectiveConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,34 +16,60 @@
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;
import java.time.Month;
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<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, Supplier<Profiler> 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<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, Supplier<Profiler> 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> biome = this.getBiome(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
20 changes: 20 additions & 0 deletions src/client/resources/assets/effective/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -46,25 +51,40 @@
"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",
"effective.midnightconfig.enum.CosmeticsOptions.ENABLE": "Yes",
"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"
}
4 changes: 2 additions & 2 deletions src/client/resources/effective_core.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [
"ParticleSpawningClientWorldMixin",
"RandomDisplayTickBlockMixin",
"ClientWorldMixin",
"BlockMixin",
"allays.GoldenAllayTextureSwapper",
"chest_bubbles.UnderwaterChestRandomOpener",
"chest_bubbles.UnderwaterEnderChestRandomOpener",
Expand Down

0 comments on commit 7574113

Please sign in to comment.