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

everyone gets stars!

+107 -56
+1 -1
common/src/main/java/net/lerariemann/infinity/access/WorldRendererAccess.java
··· 1 1 package net.lerariemann.infinity.access; 2 2 3 3 public interface WorldRendererAccess { 4 - void projectInfinity$setNeedsStars(boolean b); 4 + void infinity$setNeedsStars(boolean b); 5 5 }
+16 -26
common/src/main/java/net/lerariemann/infinity/mixin/options/WorldRendererMixin.java
··· 17 17 import org.spongepowered.asm.mixin.Shadow; 18 18 import org.spongepowered.asm.mixin.Unique; 19 19 import org.spongepowered.asm.mixin.injection.At; 20 - import org.spongepowered.asm.mixin.injection.Constant; 21 20 import org.spongepowered.asm.mixin.injection.Inject; 22 - import org.spongepowered.asm.mixin.injection.ModifyConstant; 23 21 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 24 22 25 23 @Environment(EnvType.CLIENT) ··· 33 31 34 32 @Shadow protected abstract boolean hasBlindnessOrDarkness(Camera camera); 35 33 36 - @Shadow protected abstract void renderStars(); 37 - 38 34 @Shadow public abstract void render(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2); 39 35 40 36 @Unique 41 37 public boolean infinity$needsStars; 42 - 43 - @Unique 44 - public void infinity$testRerenderStars() { 45 - if (infinity$needsStars) { 46 - renderStars(); 47 - infinity$needsStars = false; 48 - } 49 - } 50 38 @Override 51 - public void projectInfinity$setNeedsStars(boolean b) { 39 + public void infinity$setNeedsStars(boolean b) { 52 40 infinity$needsStars = b; 53 41 } 54 42 ··· 60 48 ci.cancel(); 61 49 } 62 50 } 63 - @ModifyConstant(method = "buildStarsBuffer(Lnet/minecraft/client/render/Tessellator;)Lnet/minecraft/client/render/BuiltBuffer;", constant = @Constant(intValue = 1500)) 64 - private int injected(int constant) { 65 - return infinity$options().getNumStars(); 66 - } 67 - @ModifyConstant(method = "buildStarsBuffer(Lnet/minecraft/client/render/Tessellator;)Lnet/minecraft/client/render/BuiltBuffer;", constant = @Constant(floatValue = 0.15f)) 68 - private float injected2(float constant) { 69 - return infinity$options().getStarSizeBase(); 70 - } 71 - @ModifyConstant(method = "buildStarsBuffer(Lnet/minecraft/client/render/Tessellator;)Lnet/minecraft/client/render/BuiltBuffer;", constant = @Constant(floatValue = 0.1f)) 72 - private float injected3(float constant) { 73 - return infinity$options().getStarSizeModifier(); 74 - } 75 51 76 52 @Unique 77 53 private void infinity$renderEntireSky(Matrix4f matrix4f, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback) { ··· 83 59 matrices, tickDelta, projectionMatrix, 84 60 lightSkyBuffer, starsBuffer); 85 61 if (renderer.testAndRenderNonOverworldySkies()) return; 86 - infinity$testRerenderStars(); 62 + infinity$createStarsIfNeeded(); 87 63 renderer.setupOverworldySky(); 88 64 renderer.renderAllCelestialBodies(fogCallback); 89 65 renderer.finish(); 66 + } 67 + 68 + @Unique 69 + public void infinity$createStarsIfNeeded() { 70 + if (infinity$needsStars) { 71 + if (this.starsBuffer != null) { 72 + this.starsBuffer.close(); 73 + } 74 + this.starsBuffer = new VertexBuffer(VertexBuffer.Usage.STATIC); 75 + this.starsBuffer.bind(); 76 + this.starsBuffer.upload(SkyRenderer.buildStarsBuffer(Tessellator.getInstance(), infinity$options())); 77 + VertexBuffer.unbind(); 78 + infinity$needsStars = false; 79 + } 90 80 } 91 81 92 82 @Unique
+15 -5
common/src/main/java/net/lerariemann/infinity/options/InfinityOptions.java
··· 73 73 public static double test(NbtCompound data, String key, double def) { 74 74 return data.contains(key, NbtElement.DOUBLE_TYPE) ? data.getDouble(key) : def; 75 75 } 76 + public static boolean test(NbtCompound data, String key, boolean def) { 77 + return data.contains(key) ? data.getBoolean(key) : def; 78 + } 76 79 77 80 public boolean isEmpty() { 78 81 return data.isEmpty(); ··· 98 101 } 99 102 public float getHorizonShadingRatio() { 100 103 return test(data, "horizon_shading_ratio", 1.0f); 104 + } 105 + public boolean endSkyLike() { 106 + return test(data, "end_sky_like", false); 107 + } 108 + public boolean hasDawn() { 109 + return test(data, "dawn", !getSkyType().equals("rainbow")); 101 110 } 102 111 103 112 //sun ··· 134 143 public float getStellarVelocity() { 135 144 return test(data, "stellar_velocity", 1.0f); 136 145 } 146 + public float getDayStarBrightness() { 147 + return test(data, "star_brightness_day", 0.0f); 148 + } 149 + public float getNightStarBrightness() { 150 + return test(data, "star_brightness_night", 0.5f); 151 + } 137 152 public Vector3f getStellarColor() { 138 153 int color = test(data, "stellar_color",16777215); 139 154 return new Vector3f((float)(color >> 16 & 0xFF) / 255.0f, (float)(color >> 8 & 0xFF) / 255.0f, (float)(color & 0xFF) / 255.0f); ··· 174 189 } 175 190 public float getLunarOffset(int i) { 176 191 return fullLunarTest("lunar_offset", i, 0.0f); 177 - } 178 - 179 - //skybox 180 - public boolean endSkyLike() { 181 - return data.contains("end_sky_like") && data.getBoolean("end_sky_like"); 182 192 } 183 193 }
+4
common/src/main/java/net/lerariemann/infinity/options/RandomInfinityOptions.java
··· 55 55 data.putFloat("stellar_velocity", (float)(r.nextDouble() * 4 - 2)); 56 56 data.putFloat("stellar_tilt_y", (float)(r.nextDouble() * 180 - 90)); 57 57 data.putFloat("stellar_tilt_z", (float)(r.nextDouble() * 180 - 90)); 58 + float a = r.nextFloat(); 59 + float b = r.nextFloat(); 60 + data.putFloat("star_brightness_day", Math.min(a, b)); 61 + data.putFloat("star_brightness_night", Math.max(a, b)); 58 62 //other stuff 59 63 data.putDouble("time_scale", timeScale(r)); 60 64 data.putDouble("mavity", prov.roll(r, "use_mavity") ? mavity(r) : 1.0);
+37 -3
common/src/main/java/net/lerariemann/infinity/options/SkyRenderer.java
··· 14 14 import net.minecraft.util.math.MathHelper; 15 15 import net.minecraft.util.math.RotationAxis; 16 16 import net.minecraft.util.math.Vec3d; 17 + import net.minecraft.util.math.random.Random; 17 18 import org.joml.Matrix4f; 19 + import org.joml.Quaternionf; 18 20 import org.joml.Vector3f; 19 21 20 22 import java.awt.*; ··· 68 70 public void renderRainbowBackground() { 69 71 float main = world.getSkyAngle(tickDelta) * 2; 70 72 int color = Color.getHSBColor(main - (int)main, 1.0f, 1.0f).getRGB(); 71 - float f = MathHelper.clamp(MathHelper.cos(world.getSkyAngle(tickDelta) * ((float)Math.PI * 2)) * 2.0f + 0.5f, 0.2f, 1.0f); 73 + float f = MathHelper.clamp(MathHelper.cos(world.getSkyAngle(tickDelta) * ((float)Math.PI * 2)) * 2.0f + 0.5f, 0.0f, 1.0f); 72 74 renderSingleColorBackground(f * (float)(color >> 16 & 0xFF) / 255.0f, f * (float)(color >> 8 & 0xFF) / 255.0f, f * (float)(color & 0xFF) / 255.0f, 1.0f); 73 75 } 74 76 public void renderSingleColorBackground(float f, float g, float h, float a) { ··· 81 83 public void handleFog() { 82 84 RenderSystem.enableBlend(); 83 85 float[] fs = this.world.getDimensionEffects().getFogColorOverride(this.world.getSkyAngle(tickDelta), tickDelta); 84 - if (fs != null && !options().getSkyType().equals("rainbow")) handleSunriseFog(fs); 86 + if (fs != null && options().hasDawn()) handleSunriseFog(fs); 85 87 RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); 86 88 } 87 89 public void handleSunriseFog(float[] fs) { ··· 221 223 matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-tilt_y)); 222 224 } 223 225 public void renderStars(Matrix4f matrix4f2, Matrix4f projectionMatrix, Runnable fogCallback, float rain_alpha) { 224 - float u = world.getStarBrightness(tickDelta) * rain_alpha; 226 + float u = getStarBrightness(tickDelta) * rain_alpha; 225 227 Vector3f color = options.getStellarColor(); 226 228 if (u > 0.0f) { 227 229 RenderSystem.setShaderColor(u*color.x, u*color.y, u*color.z, u); ··· 231 233 VertexBuffer.unbind(); 232 234 fogCallback.run(); 233 235 } 236 + } 237 + public float getStarBrightness(float tickDelta) { 238 + float f = world.getSkyAngle(tickDelta); 239 + float g = 1.0F - (MathHelper.cos(f * (float) (Math.PI * 2)) * 2.0F + 0.25F); 240 + g = MathHelper.clamp(g, 0.0f, 1.0f); 241 + float day = options.getDayStarBrightness(); 242 + float night = options.getNightStarBrightness(); 243 + return day + g*g*(night-day); 244 + } 245 + 246 + public static BuiltBuffer buildStarsBuffer(Tessellator tessellator, InfinityOptions options) { 247 + Random random = Random.create(10842L); 248 + int num_stars = options.getNumStars(); 249 + float distance_to_stars = 100.0F; 250 + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION); 251 + for (int star = 0; star < num_stars; star++) { 252 + float star_x = random.nextFloat() * 2.0F - 1.0F; 253 + float star_y = random.nextFloat() * 2.0F - 1.0F; 254 + float star_z = random.nextFloat() * 2.0F - 1.0F; 255 + float star_size = options.getStarSizeBase() + random.nextFloat() * options.getStarSizeModifier(); 256 + float m = MathHelper.magnitude(star_x, star_y, star_z); 257 + if (!(m <= 0.010000001F) && !(m >= 1.0F)) { 258 + Vector3f star_coords = new Vector3f(star_x, star_y, star_z).normalize(distance_to_stars); 259 + float rotation_angle = (float)(random.nextDouble() * (float) Math.PI * 2.0); 260 + Quaternionf quaternionf = new Quaternionf().rotateTo(new Vector3f(0.0F, 0.0F, -1.0F), star_coords).rotateZ(rotation_angle); 261 + bufferBuilder.vertex(star_coords.add(new Vector3f(star_size, -star_size, 0.0F).rotate(quaternionf))); 262 + bufferBuilder.vertex(star_coords.add(new Vector3f(star_size, star_size, 0.0F).rotate(quaternionf))); 263 + bufferBuilder.vertex(star_coords.add(new Vector3f(-star_size, star_size, 0.0F).rotate(quaternionf))); 264 + bufferBuilder.vertex(star_coords.add(new Vector3f(-star_size, -star_size, 0.0F).rotate(quaternionf))); 265 + } 266 + } 267 + return bufferBuilder.end(); 234 268 } 235 269 236 270 public void renderSkybox(Identifier texture, float copies, int brightness, int alpha) {
+1 -1
common/src/main/java/net/lerariemann/infinity/var/ModPayloads.java
··· 104 104 } 105 105 } 106 106 public static void receiveStars(StarsRePayLoad payload, Object context) { 107 - ((WorldRendererAccess)(client(context).worldRenderer)).projectInfinity$setNeedsStars(true); 107 + ((WorldRendererAccess)(client(context).worldRenderer)).infinity$setNeedsStars(true); 108 108 } 109 109 110 110 public static ShaderRePayload setShaderFromWorld(ServerWorld destination) {
common/src/main/resources/assets/infinity/textures/item/fine_item.png

This is a binary file and will not be displayed.

+4 -4
common/src/main/resources/config/easter/blue.json
··· 1 1 { 2 - "infinity_version": 2000003, 2 + "infinity_version": 2001005, 3 3 "easter-options": { 4 4 "portal_color": 255, 5 5 "shader": { ··· 14 14 "uniforms": [ 15 15 { 16 16 "name": "RedMatrix", 17 - "values": [ 0.0, 0.0, 0.0 ] 17 + "values": [ 0.7, 0.0, 0.0 ] 18 18 }, 19 19 { 20 20 "name": "GreenMatrix", 21 - "values": [ 0.0, 0.0, 0.0 ] 21 + "values": [ 0.0, 0.7, 0.0 ] 22 22 }, 23 23 { 24 24 "name": "BlueMatrix", 25 - "values": [ 1.0, 1.0, 1.0 ] 25 + "values": [ 0.7, 0.7, 1.0 ] 26 26 } 27 27 ] 28 28 },
+3 -1
common/src/main/resources/config/easter/chaos.json
··· 5 5 "type": "random_hue" 6 6 }, 7 7 "time_scale": 50.0, 8 - "sky_type": "rainbow" 8 + "sky_type": "rainbow", 9 + "star_brightness_day": 0.5, 10 + "star_brightness_night": 1.0 9 11 }, 10 12 "easter-type": "chaos", 11 13 "type": "minecraft:noise",
+4 -2
common/src/main/resources/config/easter/chess.json
··· 1 1 { 2 - "infinity_version": 2000005, 2 + "infinity_version": 2001005, 3 3 "easter-type": "chess", 4 4 "easter-options": { 5 5 "portal_color": { ··· 8 8 0, 9 9 16777215 10 10 ] 11 - } 11 + }, 12 + "dawn": false, 13 + "star_brightness_night": 0.0 12 14 }, 13 15 "type": "minecraft:noise", 14 16 "settings": {
+5 -2
common/src/main/resources/config/easter/classic.json
··· 1 1 { 2 - "infinity_version": 2000003, 2 + "infinity_version": 2001005, 3 3 "easter-options": { 4 - "portal_color": 65535 4 + "portal_color": 65535, 5 + "star_size_base": 0.25, 6 + "star_size_modifier": 0.25, 7 + "star_brightness_night": 0.75 5 8 }, 6 9 "type": "minecraft:noise", 7 10 "settings": {
+4 -4
common/src/main/resources/config/easter/green.json
··· 1 1 { 2 - "infinity_version": 2000003, 2 + "infinity_version": 2001005, 3 3 "easter-options": { 4 4 "portal_color": 65280, 5 5 "shader": { ··· 14 14 "uniforms": [ 15 15 { 16 16 "name": "RedMatrix", 17 - "values": [ 0.0, 0.0, 0.0 ] 17 + "values": [ 0.7, 0.0, 0.0 ] 18 18 }, 19 19 { 20 20 "name": "GreenMatrix", 21 - "values": [ 1.0, 1.0, 1.0 ] 21 + "values": [ 0.7, 1.0, 0.7 ] 22 22 }, 23 23 { 24 24 "name": "BlueMatrix", 25 - "values": [ 0.0, 0.0, 0.0 ] 25 + "values": [ 0.0, 0.0, 0.7 ] 26 26 } 27 27 ] 28 28 },
+4 -2
common/src/main/resources/config/easter/pride.json
··· 1 1 { 2 - "infinity_version": 2000005, 2 + "infinity_version": 2001005, 3 3 "easter-options": { 4 4 "portal_color": { 5 5 "type": "checker", ··· 7 7 7848414, 8 8 14331317, 9 9 16777215 10 - ] 10 + ], 11 + "star_brightness_night": 1.0, 12 + "num_stars": 3000 11 13 } 12 14 }, 13 15 "type": "minecraft:noise",
+4 -4
common/src/main/resources/config/easter/red.json
··· 1 1 { 2 - "infinity_version": 2000003, 2 + "infinity_version": 2001005, 3 3 "easter-options": { 4 4 "portal_color": 16711680, 5 5 "shader": { ··· 14 14 "uniforms": [ 15 15 { 16 16 "name": "RedMatrix", 17 - "values": [ 1.0, 1.0, 1.0 ] 17 + "values": [ 1.0, 0.7, 0.7 ] 18 18 }, 19 19 { 20 20 "name": "GreenMatrix", 21 - "values": [ 0.0, 0.0, 0.0 ] 21 + "values": [ 0.0, 0.7, 0.0 ] 22 22 }, 23 23 { 24 24 "name": "BlueMatrix", 25 - "values": [ 0.0, 0.0, 0.0 ] 25 + "values": [ 0.0, 0.0, 0.7 ] 26 26 } 27 27 ] 28 28 },
+5 -1
docs/dimension-options.mdx
··· 37 37 for the sky to stop being darkened by void fog. With 0 it's always darkened, and with 1 - never (which is the case for all 38 38 of the mod's dimensions). The overworld uses 0.03125. 39 39 - `end_sky_like`: setting this to true disables the rendering of stellar bodies completely even in a world with overworld dimension effects. 40 + - `dawn`: a boolean dictating if skies get shading on sunrise and sunset. They do by default except when they're rainbow. 40 41 - `time_scale`: how fast does the Sun move across the sky! affects most things the day length in minecraft should logically affect, 41 42 including undead mobs burning. 0.0 is fixed time, 1.0 is normal time, negatives make the sun rise in the west. 42 43 - `solar_size`: the size of the Sun :D the Overworld uses 30.0 ··· 51 52 rotates the orbit in a perpendicular direction, lowering its highest point from the zenith. 52 53 - `lunar_velocity`, multiplicative with `time_scale`, defines how fast each moon moves. 53 54 - `lunar_offset` defines the starting position the moon has on its orbit (observed when you execute `/time set 0`). 54 - - `num_stars`: the amount of stars in the night sky. 1500 is the vanilla value. 55 + - `num_stars`: the amount of stars in the night sky. 1500 is the vanilla value. Needs to be above 0 (to disable the stars, set their 56 + brightness to 0 instead). 55 57 - `star_size_base` and `star_size_modifier` are the minimum and width of the star size distribution. Actual star sizes are distributed 56 58 uniformly between base and base+modifier. 0.15 and 0.1 are corresponding vanilla options. 57 59 - `stellar_color`: the tint for stars. 58 60 - `stellar_tilt_y`, `stellar_tilt_z`, `stellar_velocity` mirror the lunar options for the movement of the entire star-filled sphere. 61 + - `star_brightness_day`, `star_brightness_night`: self-explanatory. Need to be between 0 and 1. Vanilla uses 0.0 and 0.5 respectfully, 62 + and that's a pity, cause stars are very beautiful when `star_brightness_night` is raised to 1.0 :D 59 63 60 64 Here's an example of an options file from the wild, edited a bit for your readability: 61 65