Skip to content

Commit dc58a3d

Browse files
authored
Add loot finding (#86)
* [WIP] Add loot finding * Add multistructure loot search * Add enchantments filtering * Fix enchantment querying (for end cities) * Fix structure iteration * Update Cubiomes * Change error handling * Update Cubiomes * Add /sm:stoptask command * Update README * Update Cubiomes * Exclude structures that do not have the desired loot * infinity_enchantment -> infinity * Change Cubiomes branch to master
1 parent f30beeb commit dc58a3d

File tree

22 files changed

+1177
-193
lines changed

22 files changed

+1177
-193
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
1616
runs-on: ${{ matrix.os }}
17+
env:
18+
SRC_FILES: noise.c biomes.c layers.c biomenoise.c generator.c finders.c util.c quadbase.c loot/items.c loot/loot_functions.c loot/loot_tables.c loot/loot_table_context.c loot/loot_table_parser.c loot/loot_tables/buried_treasure_1_13.c loot/loot_tables/buried_treasure_1_18.c loot/loot_tables/desert_pyramid_1_13.c loot/loot_tables/desert_pyramid_1_20.c loot/loot_tables/end_city_treasure_1_13.c loot/loot_tables/end_city_treasure_1_20.c loot/loot_tables/igloo_chest_1_13.c loot/loot_tables/nether_bridge_1_13.c loot/loot_tables/nether_bridge_1_20.c loot/loot_tables/ruined_portal_1_16_1.c loot/loot_tables/ruined_portal_1_21_5.c loot/cjson/cJSON.c
1719
steps:
1820
- name: Checkout repository
1921
uses: actions/checkout@v4
@@ -22,16 +24,21 @@ jobs:
2224

2325
- name: Compile shared library (ubuntu-latest)
2426
if: matrix.os == 'ubuntu-latest'
25-
run: gcc -shared -o src/main/resources/libcubiomes.so src/main/c/noise.c src/main/c/biomes.c src/main/c/layers.c src/main/c/biomenoise.c src/main/c/generator.c src/main/c/finders.c src/main/c/util.c src/main/c/quadbase.c -O3 -fPIC
27+
working-directory: src/main/c/cubiomes
28+
run: gcc -shared -o ../../resources/libcubiomes.so $SRC_FILES -O3 -fPIC
2629
- name: Compile shared library (macos-latest)
2730
if: matrix.os == 'macos-latest'
31+
working-directory: src/main/c/cubiomes
2832
run: |
29-
gcc -shared -o src/main/resources/libcubiomes_arm64.dylib -arch arm64 src/main/c/noise.c src/main/c/biomes.c src/main/c/layers.c src/main/c/biomenoise.c src/main/c/generator.c src/main/c/finders.c src/main/c/util.c src/main/c/quadbase.c -O3 -fPIC
30-
gcc -shared -o src/main/resources/libcubiomes_x86_64.dylib -arch x86_64 src/main/c/noise.c src/main/c/biomes.c src/main/c/layers.c src/main/c/biomenoise.c src/main/c/generator.c src/main/c/finders.c src/main/c/util.c src/main/c/quadbase.c -O3 -fPIC
31-
lipo -create -output src/main/resources/libcubiomes.dylib src/main/resources/libcubiomes_arm64.dylib src/main/resources/libcubiomes_x86_64.dylib
33+
gcc -shared -o ../../resources/libcubiomes_arm64.dylib -arch arm64 $SRC_FILES -O3 -fPIC
34+
gcc -shared -o ../../resources/libcubiomes_x86_64.dylib -arch x86_64 $SRC_FILES -O3 -fPIC
35+
lipo -create -output ../../resources/libcubiomes.dylib ../../resources/libcubiomes_arm64.dylib ../../resources/libcubiomes_x86_64.dylib
3236
- name: Compile shared library (windows-latest)
3337
if: matrix.os == 'windows-latest'
34-
run: gcc -shared -o src/main/resources/cubiomes.dll src/main/c/noise.c src/main/c/biomes.c src/main/c/layers.c src/main/c/biomenoise.c src/main/c/generator.c src/main/c/finders.c src/main/c/util.c src/main/c/quadbase.c -O3
38+
working-directory: src/main/c/cubiomes
39+
run: |
40+
$src = $env:SRC_FILES.Split(" ")
41+
gcc -shared -o ../../resources/cubiomes.dll $src -O3
3542
3643
- name: Compute SHA256 hash (ubuntu-latest)
3744
if: matrix.os == 'ubuntu-latest'

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[submodule "src/main/c"]
2-
path = src/main/c
1+
[submodule "src/main/c/cubiomes"]
2+
path = src/main/c/cubiomes
33
url = https://github.com/xpple/cubiomes
44
[submodule "jextract"]
55
path = jextract

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Usage: `/sm:locate orevein`.
3939

4040
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.
4141

42+
### Loot locating
43+
Usage: `/sm:locate loot <amount> <item> [<enchantment conditions>]`.
44+
45+
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`.
46+
4247
### Ore highlighting
4348
Usage: `/sm:highlight block <block> [chunks]`.
4449

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ processResources {
7676
rename {"${it}_${project.base.archivesName.get()}"}
7777
}
7878

79-
from("src/main/c/LICENSE") {
79+
from("src/main/c/cubiomes/LICENSE") {
8080
rename {"${it}_cubiomes"}
8181
}
8282

83+
from("src/main/c/cubiomes/loot/LICENSE_loot_library.h.txt")
84+
8385
from generateBuildInfo
8486
}
8587

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public abstract class CreateJavaBindingsTask extends Exec {
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", "--output", "src/main/java", "--use-system-load-library", "--target-package", "com.github.cubiomes", "--header-class-name", "Cubiomes", "@includes.txt", "src/main/c/tables/btree18.h", "tables/btree19.h", "tables/btree20.h", "tables/btree192.h", "tables/btree21wd.h", "biomenoise.h", "biomes.h", "finders.h", "generator.h", "layers.h", "noise.h", "quadbase.h", "rng.h", "util.h");
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", "noise.h", "quadbase.h", "rng.h", "util.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");
1717
}
1818
}

0 commit comments

Comments
 (0)