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

lowercase; fix for double value recording

Lera 35b37d0b ab31d0ed

+11 -2
+6
common/src/main/java/net/lerariemann/infinity/util/InfinityMethods.java
··· 94 94 player.sendMessage(Text.translatable("error.infinity." + type + ".unexpected")); 95 95 } 96 96 97 + static String dimTextPreprocess(String text) { 98 + if (RandomProvider.rule("forceLowercase")) text = text.toLowerCase(); 99 + text = text.replaceAll("\n", " "); 100 + return text; 101 + } 102 + 97 103 /** 98 104 * Convert a provided string into a dimension ID. 99 105 * This also checks if it matches an Easter Egg dimension.
+3 -2
common/src/main/java/net/lerariemann/infinity/util/teleport/PortalCreator.java
··· 88 88 } 89 89 if (writableComponent != null || writtenComponent != null || printedComponent != null) { 90 90 String content = parseComponents(writableComponent, writtenComponent, printedComponent); 91 + content = InfinityMethods.dimTextPreprocess(content); 91 92 Identifier id = InfinityMethods.dimTextToId(content); 92 93 boolean bl = modifyOnInitialCollision(id, world, pos); 93 94 if (bl) entity.remove(Entity.RemovalReason.CHANGED_DIMENSION); ··· 315 316 } 316 317 317 318 static void recordIdTranslation(MinecraftServer server, Identifier id, String value) { 318 - value = value.replaceAll("\n", "/n"); 319 319 Path dir = server.getSavePath(WorldSavePath.DATAPACKS).resolve("infinity"); 320 320 String filename = "translation_tables.json"; 321 321 NbtCompound comp = CommonIO.read(dir.resolve(filename)); ··· 327 327 l.add(comp.get(key)); 328 328 } 329 329 else l = comp.getList(key, NbtElement.STRING_TYPE); 330 - l.add(NbtString.of(value)); 330 + NbtString nbts = NbtString.of(value); 331 + if (l.contains(nbts)) return; //no need to record a value twice 331 332 comp.remove(key); 332 333 comp.put(key, l); 333 334 }
+1
common/src/main/java/net/lerariemann/infinity/util/teleport/WarpLogic.java
··· 54 54 * Handles the /warp text command, warping the player to a specified dimension. This is the same as writing the input into a book. 55 55 */ 56 56 static void requestWarpByText(CommandContext<ServerCommandSource> context, String value) { 57 + value = InfinityMethods.dimTextPreprocess(value); 57 58 Identifier id = InfinityMethods.dimTextToId(value); 58 59 requestWarp(context.getSource().getPlayer(), id, true); 59 60 PortalCreator.recordIdTranslation(context.getSource().getServer(), id, value);
+1
common/src/main/resources/config/infinity.json
··· 10 10 "pawnsCanDropIllegalItems": false, 11 11 "useSoundSyncPackets": true, 12 12 "enforceModLoadedChecks": true, 13 + "forceLowercase": false, 13 14 "maxBiomeCount": 6, 14 15 "maxDimensionScale": 0, 15 16 "avgDimensionHeight": 256,