Skip to content

Commit e3752c3

Browse files
committed
First Commit
1 parent 703dd96 commit e3752c3

28 files changed

+1497
-261
lines changed

README.md

Lines changed: 24 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,42 @@
1-
**Always** use the latest (stable) version of SeedMapper! If you want to play on an older version of Minecraft, use [ViaFabricPlus](https://modrinth.com/mod/viafabricplus). This mod allows you to use the latest features of SeedMapper, while still being able to play on older Minecraft versions.
1+
# Seedmapper 2.16.x (MC1.21.10)- Modified by CevAPI
22

3-
# SeedMapper
4-
In-game Minecraft Fabric mod that allows you to do various things with the world seed. For reference, have a look at the [features](#features) this mod has. Keep in mind though, this mod requires you to have access to the seed. If the seed is not known, you could crack it using [SeedCrackerX](https://github.com/19MisterX98/SeedcrackerX/) by 19MisterX98. For questions and support please head to my [Discord](https://discord.xpple.dev/).
3+
Original Repo: https://github.com/xpple/SeedMapper/
54

6-
## Installation
7-
1. Install the [Fabric Loader](https://fabricmc.net/use/).
8-
2. Download the [Fabric API](https://minecraft.curseforge.com/projects/fabric/) and move it to your mods folder:
9-
- Linux/Windows: `.minecraft/mods`.
10-
- Mac: `minecraft/mods`.
11-
3. Download SeedMapper from the [releases page](https://modrinth.com/mod/seedmapper/versions/) and move it to your mods folder.
5+
## Relationship to upstream
126

13-
## IMPORTANT
14-
You need to have at least Java 23 installed to use this mod. I recommend to get Java 23 (or higher) from [adoptium.net](https://adoptium.net/temurin/releases/?version=23). Next, configure your Minecraft launcher to use this release of Java.
7+
This project is a friendly, independent fork of Seedmapper. I have not proposed any improvements or features to the upstream but I am welcome to them incorporating my changes. I will sporatically maintain this project and re-base/sync with the upstream project.
158

16-
- Vanilla launcher: Go to `Installations` -> `Edit` -> `More options` -> `Java executable`.
17-
- MultiMC: Go to `Edit Instance` -> `Settings` -> `Java` -> `Java Installation`.
18-
- PrismLauncher: Go to `Settings` -> `Java` -> `Java Runtime` -> `Auto-Detect...`.
19-
- Modrinth App: Go to `Instance settings` -> `Java and memory` -> `Custom Java installation` -> `Browse`
9+
## Installation and pre-requisites
2010

21-
Sometimes it may be necessary to click the option for skipping the Java compatibility check.
11+
See original [repo](https://github.com/xpple/SeedMapper) for the project. A precompiled version of my fork will be made available for download.
2212

23-
If you are on Windows, make sure to select `javaw.exe`, not `java.exe`.
13+
## Improvements
2414

25-
If you run into issues, contact your launcher's support.
15+
![Screenshot](https://i.imgur.com/m1lzryd.png)
2616

27-
## Features
28-
Before using any of these commands, make sure the seed has been configured using `/sm:config Seed set <seed>`.
17+
### Java 21
18+
Project now builds against Java 21 LTS, however, Minecraft/Fabric must have the flag ```--enable-preview``` added to the Java arguments.
2919

30-
### Seed map
31-
Usage: `/sm:seedmap`
20+
This tells the JVM to accept preview bytecode and APIs. Functionally nothing else changes in Minecraft, Fabric or any of the other mods you have installed.
3221

33-
Opens an explorable seed map based on the configured seed. You can move the map by dragging the mouse, and zoom in or out by using the scroll wheel. You can toggle what features are visible by clicking the feature toggles at the top of the screen. This command is especially useful in combination with the `/sm:source` command!
22+
![Flag](https://i.imgur.com/rOsP2H0.png)
3423

35-
### Biome locating
36-
Usage: `/sm:locate biome <biome>`.
24+
### Zoom
25+
Zoom further out on the SeedMap
3726

38-
Locates a given biome closest to the player. All biomes in all dimensions are supported.
27+
### Added Elytra/End Ship Locations
28+
Can now find Elytra via locating End Ships with the locate command ```/sm:locate feature end_city_ship``` or simply selecting the Elytra icon in the SeedMap
3929

40-
### Structure locating
41-
Usage: `/sm:locate feature <structure>[<pieces>]{<variants>}`.
30+
### Export SeedMap
31+
- Added **Export JSON** button on the top right of the SeedMap screen which will export all selected locations to a JSON
32+
- Added **Export Xaero** button on the top right of the SeedMap screen which will export all selected locations into Xaero World Map waypoints for the server you're in. Disconnect from the server you're in and reconnect and the waypoints will appear in Xaero.
4233

43-
Locates a given structure closest to the player. All structures in all dimensions are supported. However, due to limitations in the underlying library, some structures (in particular desert pyramids, jungle temples and woodland mansions) may result in occasional false positives. For more advanced querying you can also use piece and variant data to further restrict the search. For example, the following command will search for end cities with ships: `/sm:locate feature structure end_city[end_ship]`.
34+
### Improved ESP
4435

45-
### Ore vein locating
46-
Usage: `/sm:locate orevein (copper|iron)`.
36+
Configurable ESP settings allowing for custom colors, fill (imperfect) and transparency.
4737

48-
Locates an [ore vein](https://minecraft.wiki/w/Ore_vein) closest to the player. The coordinates of the first ore vein block found will be returned. After this, you can use [`/sm:highlight orevein [chunks]`](#ore-vein-highlighting) to highlight the other ores.
38+
Example: ```/sm:config blockhighlightesp set outlineColor #ff0000 outlineAlpha 0.5 fillEnabled true fillColor #00ff00 fillAlpha 0.35```
4939

50-
### Loot locating
51-
Usage: `/sm:locate loot <amount> <item> [<enchantment conditions>]`.
40+
### Highlight Timeout Setting
5241

53-
Locates chest loot closest to the player. All versions from 1.13 onwards are supported. SeedMapper will search through the chest loot of structures to find loot that matches the item and enchantment conditions. Note that queries for unobtainable loot and illegal enchantment combinations are not prevented by the command. If a search is taking too long, you should probably cancel it using `/sm:stoptask`.
54-
55-
### Ore highlighting
56-
Usage: `/sm:highlight block <block> [chunks]`.
57-
58-
Highlights the specified block in the world. All versions from 1.13 onwards are supported. Due to high dependence on the [`OCEAN_FLOOR_WG`](https://minecraft.wiki/w/Heightmap#OCEAN_FLOOR_WG) heightmap, coal, copper and emerald ore locations may be off.
59-
60-
### Ore vein highlighting
61-
Usage: `/sm:highlight orevein [chunks]`.
62-
63-
Highlights ore veins in the world. Raw ore blocks that generate as part of the ore vein are highlighted distinctly. Filler blocks are ignored.
64-
65-
### Slime chunk locating
66-
Usage: `/sm:locate slimechunk`.
67-
68-
Locates a slime chunk closest to the player. This will always be accurate.
69-
70-
### Source mutation
71-
Usage: `/sm:source (run)|(as <entity>)|(positioned <position>)|(rotated <rotation>)|(in <dimension>)|(versioned <version>)|(seeded <seed>)`.
72-
73-
Executes a given command from a modified source. For example, modifying the source's position will execute the command as if you were in that position. This command is really powerful, use it!
74-
75-
## Building from source
76-
This mod internally uses (a fork of) the C library [cubiomes](https://github.com/Cubitect/cubiomes) by Cubitect. Java bindings for this library were created with (also a fork of) [jextract](https://github.com/openjdk/jextract). The bindings use the [Foreign Function & Memory API](https://openjdk.org/jeps/454) from [Project Panama](https://openjdk.org/projects/panama/). See [CreateJavaBindingsTask.java](https://github.com/xpple/SeedMapper/blob/master/buildSrc/src/main/java/dev/xpple/seedmapper/buildscript/CreateJavaBindingsTask.java) for the Gradle task that automates this.
77-
78-
To build the mod locally, follow these steps:
79-
80-
1. Clone the repository:
81-
```shell
82-
git clone --recurse-submodules https://github.com/xpple/SeedMapper
83-
cd SeedMapper
84-
```
85-
2. Compile cubiomes to a shared library. MSVC cannot be used to build the project! The following is for Windows:
86-
```shell
87-
cd src/main/c/cubiomes
88-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
89-
cmake --build build --config Release
90-
cp build/cubiomes.dll ../../resources/cubiomes.dll
91-
cd ../../../../
92-
```
93-
3. Install LLVM (version 13.0.0 is recommended) and set the environment variable `LLVM_HOME` to the directory where LLVM was installed.
94-
4. Compile jextract. Again, the following is for Windows:
95-
```shell
96-
cd jextract
97-
./gradlew --stacktrace -Pjdk_home="$env:JAVA_HOME" -Pllvm_home="$env:LLVM_HOME" clean verify
98-
cd ../
99-
```
100-
5. Build the mod:
101-
```shell
102-
./gradlew build
103-
```
104-
You should find the Java bindings in `src/main/java/com/github/cubiomes`.
105-
106-
Lastly, you can also consult the [GitHub Actions workflow file](https://github.com/xpple/SeedMapper/blob/master/.github/workflows/build.yml), which contains complete build instructions for each major OS.
42+
Can now change the default 5 minute render timeout with ```/sm:config esptimeout```

build.gradle

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ base {
1515

1616
loom {
1717
accessWidenerPath = file('src/main/resources/seedmapper.aw')
18+
19+
runs {
20+
client {
21+
vmArgs '--enable-preview'
22+
}
23+
}
1824
}
1925

2026
repositories {
@@ -62,8 +68,39 @@ dependencies {
6268
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
6369
}
6470

65-
tasks.register('createJavaBindings', CreateJavaBindingsTask) {}
66-
compileJava.dependsOn('createJavaBindings')
71+
def regenerateBindings = (project.findProperty("seedmapperRegenerateBindings")
72+
?: System.getenv("SEEDMAPPER_REGENERATE_BINDINGS")
73+
?: "false").toString().toBoolean()
74+
75+
tasks.register('createJavaBindings', CreateJavaBindingsTask) {
76+
onlyIf { regenerateBindings }
77+
}
78+
79+
tasks.register('postProcessJavaBindings') {
80+
onlyIf { regenerateBindings }
81+
dependsOn 'createJavaBindings'
82+
doLast {
83+
def pattern = ~/(?<=\w)\$(?:get|set|slice)/
84+
fileTree('src/main/java/com/github/cubiomes').matching { include '**/*.java' }.files.each { file ->
85+
def original = file.getText('UTF-8')
86+
def updated = original.replaceAll(pattern, '')
87+
updated = updated.replaceAll(/(public\s+static\s+[^\s]+\s+)(\w+)\(MemorySegment seg, long index\)/, '$1$2AtIndex(MemorySegment seg, long index)')
88+
updated = updated.replaceAll(/(public\s+static\s+void\s+)(\w+)\(MemorySegment seg, long index,/, '$1$2AtIndex(MemorySegment seg, long index,')
89+
if (updated.contains('long sizeof()') && !updated.contains('MemorySegment asSlice(MemorySegment seg, long index)')) {
90+
def insertion = """
91+
public static MemorySegment asSlice(MemorySegment seg, long index) {
92+
return seg.asSlice(index*sizeof(), sizeof());
93+
}
94+
"""
95+
updated = updated.replaceFirst(/(?s)\n\}\s*$/, insertion + "\n}")
96+
}
97+
if (updated != original) {
98+
file.write(updated, 'UTF-8')
99+
}
100+
}
101+
}
102+
}
103+
compileJava.dependsOn('postProcessJavaBindings')
67104

68105
tasks.register('generateBuildInfo', GenerateBuildInfoTask) {
69106
outputFile = new File(temporaryDir, "build_info.json")
@@ -73,9 +110,10 @@ tasks.register("prodClient", ClientProductionRunTask) {
73110
runDir = file("run")
74111

75112
jvmArgs.add("-Ddevauth.enabled=true")
113+
jvmArgs.add("--enable-preview")
76114

77115
javaLauncher = javaToolchains.launcherFor {
78-
languageVersion = JavaLanguageVersion.of(23)
116+
languageVersion = JavaLanguageVersion.of(21)
79117
}
80118
}
81119

@@ -102,16 +140,26 @@ processResources {
102140
}
103141

104142
tasks.withType(JavaCompile).configureEach {
105-
it.options.release = 23
143+
it.options.compilerArgs += '--enable-preview'
144+
it.options.release = 21
106145
}
107146

108147
java {
109-
sourceCompatibility = JavaVersion.VERSION_23
110-
targetCompatibility = JavaVersion.VERSION_23
148+
sourceCompatibility = JavaVersion.VERSION_21
149+
targetCompatibility = JavaVersion.VERSION_21
150+
151+
toolchain {
152+
languageVersion = JavaLanguageVersion.of(21)
153+
}
154+
}
155+
156+
tasks.withType(JavaExec).configureEach {
157+
it.jvmArgs '--enable-preview'
111158
}
112159

113160
test {
114161
useJUnitPlatform()
162+
jvmArgs '--enable-preview'
115163
}
116164

117165
publishing {

buildSrc/src/main/java/dev/xpple/seedmapper/buildscript/CreateJavaBindingsTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public abstract class CreateJavaBindingsTask extends Exec {
99

1010
{
1111
// always run task
12-
this.getOutputs().upToDateWhen(_ -> false);
12+
this.getOutputs().upToDateWhen(task -> false);
1313

1414
this.setWorkingDir(this.getProject().getRootDir());
1515
this.setStandardOutput(System.out);
16-
this.commandLine("./jextract/build/jextract/bin/jextract" + EXTENSION, "--include-dir", "src/main/c/cubiomes", "--output", "src/main/java", "--use-system-load-library", "--target-package", "com.github.cubiomes", "--header-class-name", "Cubiomes", "@includes.txt", "biomenoise.h", "biomes.h", "finders.h", "generator.h", "layers.h", "biomenoise.h", "biomes.h", "noise.h", "rng.h", "util.h", "quadbase.h", "xrms.h", "loot/items.h", "loot/logging.h", "loot/loot_functions.h", "loot/loot_table_context.h", "loot/loot_table_parser.h", "loot/loot_tables.h", "loot/mc_loot.h");
16+
this.commandLine("./jextract/build/jextract/bin/jextract" + EXTENSION, "--include-dir", "src/main/c/cubiomes", "--output", "src/main/java", "--source", "--target-package", "com.github.cubiomes", "--header-class-name", "Cubiomes", "@includes.txt", "src/main/c/cubiomes/seedmapper_jextract.h");
1717
}
1818
}

buildSrc/src/main/java/dev/xpple/seedmapper/buildscript/GenerateBuildInfoTask.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class GenerateBuildInfoTask extends DefaultTask {
2727

2828
{
2929
// never reuse previous outputs
30-
this.getOutputs().upToDateWhen(_ -> false);
30+
this.getOutputs().upToDateWhen(task -> false);
3131
}
3232

3333
@TaskAction
@@ -52,10 +52,15 @@ protected void run() {
5252

5353
private String executeCommand(Object... args) {
5454
ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
55-
this.getExecOperations().exec(execSpec -> {
56-
execSpec.setStandardOutput(outputBytes);
57-
execSpec.commandLine(args);
58-
}).rethrowFailure();
59-
return outputBytes.toString(StandardCharsets.UTF_8).trim();
55+
try {
56+
this.getExecOperations().exec(execSpec -> {
57+
execSpec.setStandardOutput(outputBytes);
58+
execSpec.setErrorOutput(new ByteArrayOutputStream());
59+
execSpec.commandLine(args);
60+
}).rethrowFailure();
61+
return outputBytes.toString(StandardCharsets.UTF_8).trim();
62+
} catch (Exception e) {
63+
return "unknown";
64+
}
6065
}
6166
}

src/main/java/dev/xpple/seedmapper/SeedMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dev.xpple.seedmapper.command.commands.ClearCommand;
1111
import dev.xpple.seedmapper.command.commands.DiscordCommand;
1212
import dev.xpple.seedmapper.command.commands.HighlightCommand;
13+
import dev.xpple.seedmapper.command.commands.EspConfigCommand;
1314
import dev.xpple.seedmapper.command.commands.LocateCommand;
1415
import dev.xpple.seedmapper.command.commands.SampleCommand;
1516
import dev.xpple.seedmapper.command.commands.SeedMapCommand;
@@ -69,6 +70,9 @@ public void onInitializeClient() {
6970
} catch (IllegalStateException _) {
7071
}
7172
}
73+
if (event.config().equals("EspTimeoutMinutes")) {
74+
RenderManager.setHighlightTimeout(Configs.EspTimeoutMinutes);
75+
}
7276
})
7377
.build();
7478

@@ -93,6 +97,7 @@ private static void registerCommands(CommandDispatcher<FabricClientCommandSource
9397
CheckSeedCommand.register(dispatcher);
9498
BuildInfoCommand.register(dispatcher);
9599
HighlightCommand.register(dispatcher);
100+
EspConfigCommand.register(dispatcher);
96101
ClearCommand.register(dispatcher);
97102
StopTaskCommand.register(dispatcher);
98103
SeedMapCommand.register(dispatcher);

src/main/java/dev/xpple/seedmapper/command/arguments/ItemAndEnchantmentsPredicateArgument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private Parser(StringReader reader) {
407407
private EnchantedItem parse() throws CommandSyntaxException {
408408
int item = parseItem();
409409
// Predicate<ItemStack>
410-
Predicate<MemorySegment> predicate = _ -> true;
410+
Predicate<MemorySegment> predicate = segment -> true;
411411
if (!reader.canRead()) {
412412
return new EnchantedItem(item, predicate);
413413
}

src/main/java/dev/xpple/seedmapper/command/arguments/StructurePredicateArgument.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class StructurePredicateArgument implements ArgumentType<StructurePredicateArgument.StructureAndPredicate> {
3131

32-
private static final Collection<String> EXAMPLES = Arrays.asList("village", "end_city[end_ship]", "ruined_portal{giant=true, underground=true}", "fortress[bridge_spawner, corridor_nether_wart]");
32+
private static final Collection<String> EXAMPLES = Arrays.asList("village", "end_city_ship", "ruined_portal{giant=true, underground=true}", "fortress[bridge_spawner, corridor_nether_wart]");
3333

3434
//<editor-fold defaultstate="collapsed" desc="private static final Map<String, Integer> STRUCTURES;">
3535
private static final Map<String, Integer> STRUCTURES = ImmutableMap.<String, Integer>builder()
@@ -54,6 +54,7 @@ public class StructurePredicateArgument implements ArgumentType<StructurePredica
5454
.put("fortress", Cubiomes.Fortress())
5555
.put("bastion_remnant", Cubiomes.Bastion())
5656
.put("end_city", Cubiomes.End_City())
57+
.put("end_city_ship", Cubiomes.End_City())
5758
.put("end_gateway", Cubiomes.End_Gateway())
5859
.put("end_island", Cubiomes.End_Island())
5960
.put("trail_ruins", Cubiomes.Trail_Ruins())
@@ -105,6 +106,11 @@ public class StructurePredicateArgument implements ArgumentType<StructurePredica
105106
.build();
106107
//</editor-fold>
107108

109+
private static final int END_CITY_SHIP_PIECE = STRUCTURE_PIECES.get(Cubiomes.End_City()).get("end_ship");
110+
private static final PiecesPredicate HAS_END_SHIP = (numPieces, pieces) -> IntStream.range(0, numPieces)
111+
.mapToObj(i -> Piece.asSlice(pieces, i))
112+
.anyMatch(piece -> Piece.type(piece) == END_CITY_SHIP_PIECE);
113+
108114
//<editor-fold defaultstate="collapsed" desc="private static final Map<String, Pair<Map<String, Integer>, Function<MemorySegment, Integer>>> GENERAL_VARIANTS;">
109115
private static final Map<String, Pair<Map<String, Integer>, Function<MemorySegment, Integer>>> GENERAL_VARIANTS = ImmutableMap.<String, Pair<Map<String, Integer>, Function<MemorySegment, Integer>>>builder()
110116
.put("biome", Pair.of(BiomeArgument.BIOMES, m -> (int) StructureVariant.biome(m)))
@@ -257,6 +263,7 @@ private static final class Parser {
257263

258264
private final StringReader reader;
259265
private Consumer<SuggestionsBuilder> suggestor;
266+
private PiecesPredicate defaultPiecesPredicate = (numPieces, pieces) -> true;
260267

261268
private Parser(StringReader reader) {
262269
this.reader = reader;
@@ -265,7 +272,7 @@ private Parser(StringReader reader) {
265272
private StructureAndPredicate parse() throws CommandSyntaxException {
266273
int structure = parseStructure();
267274

268-
PiecesPredicate piecesPredicate = parsePieces(structure);
275+
PiecesPredicate piecesPredicate = this.defaultPiecesPredicate.and(parsePieces(structure));
269276

270277
VariantPredicate variantPredicate = parseVariant(structure);
271278

@@ -285,6 +292,11 @@ private int parseStructure() throws CommandSyntaxException {
285292
reader.setCursor(cursor);
286293
throw CommandExceptions.UNKNOWN_STRUCTURE_EXCEPTION.create(structureString);
287294
}
295+
if ("end_city_ship".equals(structureString)) {
296+
this.defaultPiecesPredicate = HAS_END_SHIP;
297+
} else {
298+
this.defaultPiecesPredicate = (numPieces, pieces) -> true;
299+
}
288300
return structure;
289301
}
290302

@@ -341,7 +353,7 @@ private PiecesPredicate parsePieces(int structure) throws CommandSyntaxException
341353
}
342354

343355
private VariantPredicate parseVariant(int structure) throws CommandSyntaxException {
344-
VariantPredicate variantPredicate = _ -> true;
356+
VariantPredicate variantPredicate = variant -> true;
345357
Map<String, Pair<Map<String, Integer>, Function<MemorySegment, Integer>>> specificVariantKeys = STRUCTURE_VARIANTS.get(structure);
346358
if (specificVariantKeys == null) {
347359
return variantPredicate;

0 commit comments

Comments
 (0)