Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pitch shifter; lv 0 irid fix

+121 -7
+4 -4
common/src/main/java/net/lerariemann/infinity/iridescence/Iridescence.java
··· 129 129 } 130 130 131 131 public static void tryBeginJourney(LivingEntity entity, int amplifier) { 132 - int i = Iridescence.getAmplifierOnApply(entity, amplifier); 133 - if (i >= 0) { 132 + int amplifier1 = Iridescence.getAmplifierOnApply(entity, amplifier); 133 + if (amplifier1 >= 0) { 134 134 entity.addStatusEffect(new StatusEffectInstance(ModStatusEffects.IRIDESCENT_EFFECT, 135 - Iridescence.getEffectLength(amplifier), i)); 135 + Iridescence.getEffectLength(amplifier1), amplifier1)); 136 136 entity.removeStatusEffect(ModStatusEffects.IRIDESCENT_COOLDOWN); 137 137 entity.addStatusEffect(new StatusEffectInstance(ModStatusEffects.IRIDESCENT_COOLDOWN, 138 - Iridescence.getCooldownDuration(), amplifier > 0 ? 1 : 0, false, false, false)); 138 + Iridescence.getCooldownDuration(), amplifier1 > 0 ? 1 : 0, false, false, false)); 139 139 if (entity instanceof ServerPlayerEntity player) { 140 140 player.increaseStat(ModStats.IRIDESCENCE, 1); 141 141 ModCriteria.IRIDESCENT.get().trigger(player);
+19
common/src/main/java/net/lerariemann/infinity/mixin/options/SoundSystemMixin.java
··· 1 + package net.lerariemann.infinity.mixin.options; 2 + 3 + import com.llamalad7.mixinextras.injector.ModifyExpressionValue; 4 + import net.lerariemann.infinity.access.InfinityOptionsAccess; 5 + import net.lerariemann.infinity.options.InfinityOptions; 6 + import net.minecraft.client.MinecraftClient; 7 + import net.minecraft.client.sound.SoundSystem; 8 + import org.spongepowered.asm.mixin.Mixin; 9 + import org.spongepowered.asm.mixin.injection.At; 10 + 11 + @Mixin(SoundSystem.class) 12 + public class SoundSystemMixin { 13 + @ModifyExpressionValue(method = "getAdjustedPitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundInstance;getPitch()F")) 14 + float inj(float original) { 15 + InfinityOptions options =((InfinityOptionsAccess) MinecraftClient.getInstance()).infinity$getOptions(); 16 + if (!options.isEmpty()) return options.getSoundPitch().apply(original); 17 + return original; 18 + } 19 + }
+18 -1
common/src/main/java/net/lerariemann/infinity/options/InfinityOptions.java
··· 11 11 import org.joml.Vector3f; 12 12 13 13 import java.io.File; 14 + import java.util.function.Function; 14 15 15 - public record InfinityOptions(NbtCompound data) { 16 + public class InfinityOptions { 17 + public NbtCompound data; 18 + public PitchShifter shifter; 19 + 20 + public InfinityOptions(NbtCompound data) { 21 + this.data = data; 22 + this.shifter = data.contains("pitch_shift") ? new PitchShifter(data.getCompound("pitch_shift")) : new PitchShifter(); 23 + } 24 + 25 + public NbtCompound data() { 26 + return data; 27 + } 28 + 16 29 public static InfinityOptions empty() { 17 30 return new InfinityOptions(new NbtCompound()); 18 31 } ··· 150 163 151 164 public float getLunarOffset(int i) { 152 165 return fullLunarTest("lunar_offset", i, 0.0f); 166 + } 167 + 168 + public Function<Float, Float> getSoundPitch() { 169 + return shifter.applier(); 153 170 } 154 171 155 172 public float getHorizonShadingRatio() {
+54
common/src/main/java/net/lerariemann/infinity/options/PitchShifter.java
··· 1 + package net.lerariemann.infinity.options; 2 + 3 + import net.minecraft.nbt.NbtCompound; 4 + import net.minecraft.nbt.NbtElement; 5 + 6 + import java.util.function.Function; 7 + 8 + public class PitchShifter { 9 + Type type; 10 + float value; 11 + 12 + String getString(NbtCompound comp, String s) { 13 + if (!comp.contains(s, NbtElement.STRING_TYPE)) return "empty"; 14 + return comp.getString(s); 15 + } 16 + 17 + float getFloat(NbtCompound comp, String s) { 18 + if (!comp.contains(s, NbtElement.FLOAT_TYPE)) return 1; 19 + return comp.getFloat(s); 20 + } 21 + 22 + PitchShifter(NbtCompound comp) { 23 + type = decodeType(getString(comp, "type")); 24 + if (type != Type.EMPTY) { 25 + value = getFloat(comp, "value"); 26 + } 27 + } 28 + 29 + PitchShifter() { 30 + type = Type.EMPTY; 31 + } 32 + 33 + Function<Float, Float> applier() { 34 + return switch (type) { 35 + case EMPTY -> f -> f; 36 + case CONSTANT -> f -> value; 37 + case ADD -> f -> f + value; 38 + }; 39 + } 40 + 41 + Type decodeType(String s) { 42 + return switch (s) { 43 + case "constant" -> Type.CONSTANT; 44 + case "add" -> Type.ADD; 45 + default -> Type.EMPTY; 46 + }; 47 + } 48 + 49 + enum Type { 50 + EMPTY, 51 + CONSTANT, 52 + ADD 53 + } 54 + }
+23
common/src/main/java/net/lerariemann/infinity/options/RandomInfinityOptions.java
··· 51 51 data.putFloat("star_size_modifier", (float)(0.03*r.nextExponential())); 52 52 data.putDouble("time_scale", timeScale(r)); 53 53 data.putDouble("mavity", mavity(r)); 54 + data.put("pitch_shift", pitchShift(r)); 54 55 } 55 56 56 57 public static double timeScale(Random r) { ··· 84 85 res[i] = points.get(i+1) - points.get(i); 85 86 } 86 87 return res; 88 + } 89 + 90 + public static NbtCompound pitchShift(Random r) { 91 + NbtCompound comp = new NbtCompound(); 92 + int i = r.nextInt(-1, 2); 93 + switch (i) { 94 + case -1 -> { 95 + comp.putString("type", "empty"); 96 + return comp; 97 + } 98 + case 0 -> { 99 + comp.putString("type", "constant"); 100 + comp.putFloat("value", r.nextFloat(0.5f, 2.0f)); 101 + return comp; 102 + } 103 + case 1 -> { 104 + comp.putString("type", "add"); 105 + comp.putFloat("value", r.nextFloat(-1.0f, 1.0f)); 106 + return comp; 107 + } 108 + } 109 + return comp; 87 110 } 88 111 }
+3 -2
common/src/main/resources/infinity.mixins.json
··· 41 41 "mobs.passive.TurtleEntityMixin", 42 42 "mobs.passive.WolfEntityMixin", 43 43 "options.DimensionTypeMixin", 44 + "options.EntityMixin", 44 45 "options.PlayerManagerMixin", 45 - "options.ServerWorldMixin", 46 - "options.EntityMixin" 46 + "options.ServerWorldMixin" 47 47 ], 48 48 "client": [ 49 49 "iridescence.LivingEntityRendererMixin", ··· 52 52 "options.ClientWorldMixin", 53 53 "options.GameRendererMixin", 54 54 "options.MinecraftClientMixin", 55 + "options.SoundSystemMixin", 55 56 "options.WorldRendererMixin" 56 57 ], 57 58 "injectors": {