tangled
alpha
login
or
join now
codexarchonic.nekoweb.org
/
ProjectInfinity
0
fork
atom
Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
0
fork
atom
overview
issues
6
pulls
pipelines
Merge branch '2.4.3' into architectury/1.20
cassian.cc
1 year ago
cfb2bfef
bc9d5f38
+36
-48
13 changed files
expand all
collapse all
unified
split
common
src
main
java
net
lerariemann
infinity
InfinityModClient.java
compat
ComputerCraftCompat.java
dimensions
RandomDimension.java
iridescence
Iridescence.java
IridescenceLiquidBlock.java
item
F4Item.java
options
IridescentMap.java
registry
core
ModItemFunctions.java
var
ModDensityFunctionTypes.java
ModMaterialRules.java
util
InfinityMethods.java
resources
config
infinity.json
gradle.properties
-3
common/src/main/java/net/lerariemann/infinity/InfinityModClient.java
···
13
13
import net.minecraft.item.ItemStack;
14
14
import net.minecraft.util.Hand;
15
15
import net.minecraft.util.TypedActionResult;
16
16
-
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler;
17
17
-
import net.minecraft.util.math.random.CheckedRandom;
18
16
import org.lwjgl.glfw.GLFW;
19
17
20
18
public class InfinityModClient {
21
21
-
public final static DoublePerlinNoiseSampler sampler = DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -3, 1.0, 1.0, 1.0, 0.0);
22
19
public static KeyBinding f4ConfigKey = new KeyBinding("key.infinity.f4",
23
20
InputUtil.Type.KEYSYM,
24
21
GLFW.GLFW_KEY_F4,
+1
-1
common/src/main/java/net/lerariemann/infinity/compat/ComputerCraftCompat.java
···
6
6
public class ComputerCraftCompat {
7
7
8
8
public static String checkPrintedPage(ItemStack itemStack) {
9
9
-
var print = (PrintoutContents.get(itemStack));
9
9
+
var print = PrintoutContents.get(itemStack);
10
10
if (print != null) {
11
11
String string = "";
12
12
for (var l : print.getTextLines().toArray()) {
+3
-4
common/src/main/java/net/lerariemann/infinity/dimensions/RandomDimension.java
···
98
98
99
99
public void genBasics() {
100
100
type_alike = PROVIDER.randomName(random, "noise_presets");
101
101
-
min_y = 16*Math.min(0, (int)Math.floor(random.nextGaussian(-4.0, 4.0)));
102
102
-
if (!isOverworldLike()) min_y = Math.max(min_y, -48);
103
103
-
int max_y = 16*Math.max(1, Math.min(125, (int)Math.floor(random.nextGaussian(16.0, 4.0))));
104
104
-
if (!isOverworldLike()) max_y = Math.max(max_y, 80);
101
101
+
min_y = 16*Math.clamp((int)Math.floor(random.nextExponential() * 2), isOverworldLike() ? -125 : -3, 0);
102
102
+
int avgHeight = Math.clamp(RandomProvider.ruleInt("avgDimensionHeight"), 64, 1024);
103
103
+
int max_y = 16*Math.clamp((int)Math.floor(random.nextGaussian(avgHeight/16.0, avgHeight/64.0)), isOverworldLike() ? 1 : 5, 125);
105
104
randomiseblocks = PROVIDER.roll(random, "randomise_blocks");
106
105
int sea_level_default = 63;
107
106
if (!isOverworldLike()) sea_level_default = switch(type_alike) {
+1
-16
common/src/main/java/net/lerariemann/infinity/iridescence/Iridescence.java
···
39
39
import net.minecraft.util.Identifier;
40
40
import net.minecraft.util.math.BlockPos;
41
41
import net.minecraft.util.math.Box;
42
42
-
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler;
43
43
-
import net.minecraft.util.math.random.CheckedRandom;
44
42
import net.minecraft.world.*;
45
43
import net.minecraft.world.biome.Biome;
46
44
import org.jetbrains.annotations.Nullable;
···
49
47
import java.nio.file.Files;
50
48
import java.nio.file.Path;
51
49
import java.time.LocalTime;
52
52
-
import java.util.Arrays;
53
50
import java.util.List;
54
51
import java.util.Map;
55
52
import java.util.Random;
···
58
55
Identifier TEXTURE = InfinityMethods.getId("block/iridescence");
59
56
Identifier FLOWING_TEXTURE = InfinityMethods.getId("block/iridescence");
60
57
Identifier OVERLAY_TEXTURE = InfinityMethods.getId("block/iridescence_overlay");
61
61
-
DoublePerlinNoiseSampler sampler =
62
62
-
DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -5, genOctaves(2));
63
63
-
64
64
-
static double[] genOctaves(int octaves){
65
65
-
double[] a = new double[octaves];
66
66
-
Arrays.fill(a, 1);
67
67
-
return a;
68
68
-
}
69
69
-
70
70
-
static double sample(BlockPos pos) {
71
71
-
return sampler.sample(pos.getX(), pos.getY(), pos.getZ());
72
72
-
}
73
58
74
59
static boolean isInfinite(World world) {
75
60
return switch (world.getRegistryKey().getValue().toString()) {
···
92
77
}
93
78
94
79
static int getPosBasedColor(BlockPos pos) {
95
95
-
return Color.HSBtoRGB((float)sample(pos), 1.0F, 1.0F) & 0xFFFFFF;
80
80
+
return Color.HSBtoRGB((float)InfinityMethods.sample(pos), 1.0F, 1.0F) & 0xFFFFFF;
96
81
}
97
82
//todo: figure out how minecraft offsets animations to sync this with irid items' textures' animation loops
98
83
static int getTimeBasedColor() {
+1
-1
common/src/main/java/net/lerariemann/infinity/iridescence/IridescenceLiquidBlock.java
···
28
28
super.onEntityCollision(state, world, pos, entity);
29
29
if (world.getFluidState(pos).getLevel() > 3 && world instanceof ServerWorld w) {
30
30
if (Objects.requireNonNull(entity) instanceof PlayerEntity player) {
31
31
-
Iridescence.tryBeginJourney(player, 4, false);
31
31
+
Iridescence.tryBeginJourney(player, 0, false);
32
32
} else if (entity instanceof MobEntity ent) {
33
33
Iridescence.tryApplyEffect(ent);
34
34
} else if (entity instanceof ItemEntity item) {
+1
-3
common/src/main/java/net/lerariemann/infinity/item/F4Item.java
···
1
1
package net.lerariemann.infinity.item;
2
2
3
3
-
import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper;
4
3
import net.lerariemann.infinity.block.entity.InfinityPortalBlockEntity;
5
4
import net.lerariemann.infinity.registry.core.ModBlocks;
6
5
import net.lerariemann.infinity.registry.core.ModComponentTypes;
7
6
import net.lerariemann.infinity.util.BackportMethods;
8
7
import net.lerariemann.infinity.util.ClientMethods;
9
8
import net.lerariemann.infinity.util.InfinityMethods;
10
10
-
import net.lerariemann.infinity.util.screen.F4Screen;
11
9
import net.lerariemann.infinity.util.teleport.InfinityPortal;
12
10
import net.minecraft.block.BlockState;
13
11
import net.minecraft.block.Blocks;
···
273
271
world.setBlockState(bp, Blocks.AIR.getDefaultState(), 3, 0);
274
272
obsidian++;
275
273
}
276
276
-
for (int i = 0; i <= portal.width; i++) for (int j = -1; j <= portal.height; j++)
274
274
+
for (int i = 0; i < portal.width; i++) for (int j = 0; j < portal.height; j++)
277
275
world.setBlockState(portal.lowerLeft.offset(axis, i).up(j), Blocks.AIR.getDefaultState(), 3, 0);
278
276
BackportMethods.apply(stack, ModComponentTypes.F4_CHARGE, getCharge(stack) + obsidian);
279
277
world.playSound(null, origin, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 1, 0.75f);
+2
-2
common/src/main/java/net/lerariemann/infinity/options/IridescentMap.java
···
1
1
package net.lerariemann.infinity.options;
2
2
3
3
-
import net.lerariemann.infinity.iridescence.Iridescence;
4
3
import net.lerariemann.infinity.util.InfinityMethods;
5
4
import net.lerariemann.infinity.util.core.NbtUtils;
6
5
import net.minecraft.nbt.NbtCompound;
···
10
9
11
10
import static net.lerariemann.infinity.block.custom.IridescentBlock.num_models;
12
11
12
12
+
@Deprecated
13
13
public interface IridescentMap {
14
14
default int getColor(BlockPos pos) {
15
15
return InfinityMethods.properMod((int)(num_models * getHue(pos)), num_models);
16
16
}
17
17
default double getHue(BlockPos pos) {
18
18
-
return Iridescence.sample(pos);
18
18
+
return InfinityMethods.sample(pos);
19
19
}
20
20
21
21
static IridescentMap decode(NbtCompound data) {
+1
common/src/main/java/net/lerariemann/infinity/registry/core/ModItemFunctions.java
···
134
134
itemEntity.remove(Entity.RemovalReason.CHANGED_DIMENSION);
135
135
}
136
136
137
137
+
@Deprecated
137
138
@Environment(EnvType.CLIENT)
138
139
public static float iridPredicate(@Nullable ItemStack stack, ClientWorld world, @Nullable LivingEntity entity, int seed) {
139
140
if (entity == null) return 0;
+3
-3
common/src/main/java/net/lerariemann/infinity/registry/var/ModDensityFunctionTypes.java
···
4
4
import com.mojang.serialization.MapCodec;
5
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
6
import dev.architectury.registry.registries.DeferredRegister;
7
7
-
import net.lerariemann.infinity.iridescence.Iridescence;
7
7
+
import net.lerariemann.infinity.util.InfinityMethods;
8
8
import net.minecraft.registry.RegistryKeys;
9
9
import net.minecraft.util.dynamic.CodecHolder;
10
10
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler;
···
305
305
}
306
306
307
307
public static void registerFunctions() {
308
308
-
sampler = DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -5, Iridescence.genOctaves(8));
309
309
-
sampler2 = DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -6, Iridescence.genOctaves(8));
308
308
+
sampler = DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -5, InfinityMethods.genOctaves(8));
309
309
+
sampler2 = DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -6, InfinityMethods.genOctaves(8));
310
310
for (NonbinaryOperation.Type enum_ : NonbinaryOperation.Type.values()) {
311
311
register(enum_.name, enum_.codecHolder);
312
312
}
+2
-1
common/src/main/java/net/lerariemann/infinity/registry/var/ModMaterialRules.java
···
6
6
import dev.architectury.registry.registries.DeferredRegister;
7
7
import net.lerariemann.infinity.iridescence.Iridescence;
8
8
import net.lerariemann.infinity.registry.core.ModBlocks;
9
9
+
import net.lerariemann.infinity.util.InfinityMethods;
9
10
import net.lerariemann.infinity.util.core.RandomProvider;
10
11
import net.minecraft.block.BlockState;
11
12
import net.minecraft.block.Blocks;
···
65
66
{
66
67
@Override
67
68
public BlockState tryApply(int i, int j, int k) {
68
68
-
double d = Iridescence.sampler.sample(i, j, k);
69
69
+
double d = InfinityMethods.sampler.sample(i, j, k);
69
70
d = d - Math.floor(d);
70
71
BlockState st = Iridescence.getRandomColorBlock(d, str).getDefaultState();
71
72
if(st.contains(Properties.PERSISTENT)) st = st.with(Properties.PERSISTENT, Boolean.TRUE);
+17
-11
common/src/main/java/net/lerariemann/infinity/util/InfinityMethods.java
···
35
35
* @see PlatformMethods */
36
36
public interface InfinityMethods {
37
37
String ofRandomDim = "infinity:random";
38
38
+
DoublePerlinNoiseSampler sampler =
39
39
+
DoublePerlinNoiseSampler.create(new CheckedRandom(0L), -5, genOctaves(2));
40
40
+
41
41
+
static double[] genOctaves(int octaves){
42
42
+
double[] a = new double[octaves];
43
43
+
Arrays.fill(a, 1);
44
44
+
return a;
45
45
+
}
46
46
+
static double sample(BlockPos pos) {
47
47
+
return sampler.sample(pos.getX(), pos.getY(), pos.getZ());
48
48
+
}
38
49
39
50
/**
40
51
* Converts a string to an identifier in the Infinite Dimensions namespace.
···
136
147
return i;
137
148
}
138
149
139
139
-
/**
140
140
-
* Converts a coordinate value to a "random" color.
141
141
-
*/
142
142
-
static int posToColor(BlockPos pos) {
143
143
-
double r = sample(pos.getX(), pos.getY() - 10000, pos.getZ());
144
144
-
double g = sample(pos.getX(), pos.getY(), pos.getZ());
145
145
-
double b = sample(pos.getX(), pos.getY() + 10000, pos.getZ());
146
146
-
return (int)(256 * ((r + 1)/2)) + 256*((int)(256 * ((g + 1)/2)) + 256*(int)(256 * ((b + 1)/2)));
150
150
+
private static float bookBoxSample(BlockPos pos, int offset) {
151
151
+
return MathHelper.clamp(0.5f * (1f + (float)sampler.sample(4*pos.getX(), 4*(pos.getY() + offset), 4*pos.getZ())), 0f, 1f);
147
152
}
148
148
-
149
149
-
150
153
static int getBookBoxColor(BlockState state, BlockRenderView world, BlockPos pos, int tintIndex) {
151
154
if (pos != null) {
152
152
-
return posToColor(pos);
155
155
+
float r = bookBoxSample(pos, -1000);
156
156
+
float g = bookBoxSample(pos, 0);
157
157
+
float b = bookBoxSample(pos, 1000);
158
158
+
return MathHelper.packRgb(r, g, b);
153
159
}
154
160
return 16777215;
155
161
}
+2
-1
common/src/main/resources/config/infinity.json
···
1
1
{
2
2
-
"infinity_version": 2004001,
2
2
+
"infinity_version": 2004003,
3
3
"gameRules": {
4
4
"runtimeGenerationEnabled": true,
5
5
"longArithmeticEnabled": false,
···
12
12
"enforceModLoadedChecks": true,
13
13
"maxBiomeCount": 6,
14
14
"maxDimensionScale": 0,
15
15
+
"avgDimensionHeight": 256,
15
16
"iridescenceInitialDuration": 30,
16
17
"iridescenceCooldownDuration": 168,
17
18
"afterglowDuration": 24,
+2
-2
gradle.properties
···
3
3
org.gradle.parallel=true
4
4
5
5
# Mod properties
6
6
-
mod_version = 2.4.2
6
6
+
mod_version = 2.4.3
7
7
maven_group = net.lerariemann
8
8
archives_name = infinity
9
9
enabled_platforms = fabric,forge
10
10
-
tbversion = 3
10
10
+
tbversion = 4
11
11
12
12
# Minecraft properties
13
13
minecraft_version = 1.20.1