diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dd947a..35e54fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(HEADERS util.h quadbase.h xrms.h + features/stronghold.h loot/items.h loot/logging.h loot/loot_functions.h @@ -84,6 +85,14 @@ set(HEADERS loot/loot_tables/shipwreck_treasure_1_13.h loot/loot_tables/shipwreck_treasure_1_20.h loot/loot_tables/shipwreck_treasure_1_21_11.h + loot/loot_tables/stronghold_corridor_1_13.h + loot/loot_tables/stronghold_corridor_1_18.h + loot/loot_tables/stronghold_corridor_1_20.h + loot/loot_tables/stronghold_corridor_1_21_6.h + loot/loot_tables/stronghold_corridor_1_21_9.h + loot/loot_tables/stronghold_crossing_1_13.h + loot/loot_tables/stronghold_library_1_13.h + loot/loot_tables/stronghold_library_1_20.h loot/cjson/cJSON.h ) set(SOURCES @@ -97,6 +106,7 @@ set(SOURCES util.c quadbase.c xradv.c + features/stronghold.c loot/items.c loot/loot_functions.c loot/loot_tables.c @@ -151,6 +161,14 @@ set(SOURCES loot/loot_tables/shipwreck_treasure_1_13.c loot/loot_tables/shipwreck_treasure_1_20.c loot/loot_tables/shipwreck_treasure_1_21_11.c + loot/loot_tables/stronghold_corridor_1_13.c + loot/loot_tables/stronghold_corridor_1_18.c + loot/loot_tables/stronghold_corridor_1_20.c + loot/loot_tables/stronghold_corridor_1_21_6.c + loot/loot_tables/stronghold_corridor_1_21_9.c + loot/loot_tables/stronghold_crossing_1_13.c + loot/loot_tables/stronghold_library_1_13.c + loot/loot_tables/stronghold_library_1_20.c loot/cjson/cJSON.c ) diff --git a/README.md b/README.md index 9ef353c..8ae207c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ Below is a list of all the major additions: - Ore generation (1.13+). - Ore vein generation (1.18+). -- Structure loot support (1.13+). At the time of writing, the following structures are supported: Bastions (limited), Buried Treasures, Desert Pyramids, End Cities, Igloos, Jungle Temples, Nether Fortresses, Pillager Outposts, Ruined Portals (OW/NE) and Shipwrecks. +- Stronghold generation (1.8+). +- Structure loot support (1.13+). At the time of writing, the following structures are supported: Bastions (limited), Buried Treasures, Desert Pyramids, End Cities, Igloos, Jungle Temples, Nether Fortresses, Pillager Outposts, Ruined Portals (OW/NE), Shipwrecks and Strongholds. - Fast Xoroshiro128++ state advancement. - Canyon/cave carvers (1.13+). - Terrain generation (1.18+). diff --git a/features/stronghold.c b/features/stronghold.c new file mode 100644 index 0000000..a1c1432 --- /dev/null +++ b/features/stronghold.c @@ -0,0 +1,703 @@ +#include "stronghold.h" + +#include + +#include "../finders.h" + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +STRUCT(StrongholdPieceEnv) { + int mc; + Piece *list; + int *n; + uint64_t *rng; + int *portal; + int imposedPiece; + int typlast; + int nmax; + int ntyp[SH_PIECE_COUNT]; + uint16_t deltyp; // 16 > SH_PIECE_COUNT + int totalWeight; + int generationStopped; +}; + +static const struct { + const Pos3 offset, size; + const int weight, maxPlaceCount, minDepth; + const char *name; +} stronghold_info[] = { + {{-1, -1, 0}, { 5, 5, 7}, 40, 0, 0, "SHS" }, // STRAIGHT + {{-1, -1, 0}, { 9, 5, 11}, 5, 5, 0, "SHPH" }, // PRISON_HALL + {{-1, -1, 0}, { 5, 5, 5}, 20, 0, 0, "SHLT" }, // LEFT_TURN + {{-1, -1, 0}, { 5, 5, 5}, 20, 0, 0, "SHRT" }, // RIGHT_TURN + {{-4, -1, 0}, {11, 7, 11}, 10, 6, 0, "SHRC" }, // ROOM_CROSSING + {{-1, -7, 0}, { 5, 11, 8}, 5, 5, 0, "SHSSD"}, // STRAIGHT_STAIRS_DOWN + {{-1, -7, 0}, { 5, 11, 5}, 5, 5, 0, "SHSD" }, // STAIRS_DOWN + {{-4, -3, 0}, {10, 9, 11}, 5, 4, 0, "SH5C" }, // FIVE_CROSSING + {{-1, -1, 0}, { 5, 5, 7}, 5, 4, 0, "SHCC" }, // CHEST_CORRIDOR + {{-4, -1, 0}, {14, 11, 15}, 10, 2, 5, "SHLi" }, // LIBRARY + {{-4, -1, 0}, {11, 8, 16}, 20, 1, 6, "SHPR" }, // PORTAL_ROOM + {{-1, -1, 0}, { 5, 5, 4}, -1, -1, -1, "SHFC" }, // FILLER_CORRIDOR +}; + +static inline int isValid(int piecePlaceCount, int pieceType) { + int maxPlaceCount = stronghold_info[pieceType].maxPlaceCount; + return maxPlaceCount == 0 || piecePlaceCount < maxPlaceCount; +} + +static inline int canPlace(int piecePlaceCount, int pieceType, int depth) { + return isValid(piecePlaceCount, pieceType) && depth >= stronghold_info[pieceType].minDepth; +} + +static inline void updateGenerationStatus(StrongholdPieceEnv *env) { + for (int pieceType = 0; pieceType < 11; pieceType++) { + if ((env->deltyp >> pieceType) & 1) continue; + int piecePlaceCount = env->ntyp[pieceType]; + int maxPlaceCount = stronghold_info[pieceType].maxPlaceCount; + int pieceWeight = stronghold_info[pieceType].weight; + if (maxPlaceCount > 0 && piecePlaceCount < pieceWeight) { + return; + } + } + env->generationStopped = 1; +} + +static inline Piece* hasCollision(StrongholdPieceEnv *env, Pos3 b0, Pos3 b1) { + int i, n = *env->n; + for (i = 0; i < n; i++) { + Piece *q = env->list + i; + if (hasIntersection(q->bb0, q->bb1, b0, b1)) { + return q; + } + } + return NULL; +} + +static int addStrongholdPiece(StrongholdPieceEnv *env, int typ, int x, int y, int z, int depth, int facing) { + if (env->mc < MC_1_14 && typ == SH_RIGHT_TURN) { + typ = SH_LEFT_TURN; + } + + Pos3 pos = {x, y, z}; + Pos3 b0, b1; + Pos3 offset; Pos3 size; + + switch (typ) { + case SH_STRAIGHT: + case SH_PRISON_HALL: + case SH_LEFT_TURN: + case SH_RIGHT_TURN: + case SH_ROOM_CROSSING: + case SH_STRAIGHT_STAIRS_DOWN: + case SH_STAIRS_DOWN: + case SH_FIVE_CROSSING: + case SH_CHEST_CORRIDOR: + case SH_PORTAL_ROOM: + offset = stronghold_info[typ].offset; size = stronghold_info[typ].size; break; + case SH_LIBRARY: + offset = (Pos3) stronghold_info[typ].offset; size = (Pos3) stronghold_info[typ].size; + orientBox(pos, offset, size, facing, &b0, &b1); + if (b0.y > 10 && !hasCollision(env, b0, b1)) { + goto L_box_end; + } + size.y = 6; + break; + case SH_FILLER_CORRIDOR: + offset = (Pos3) stronghold_info[typ].offset; size = (Pos3) stronghold_info[typ].size; + orientBox(pos, offset, size, facing, &b0, &b1); + Piece *p = hasCollision(env, b0, b1); + if (!p) { + return 0; + } + if (p->bb0.y != b0.y) { + return 0; + } + int minI = env->mc < MC_1_17 ? 0 : 1; + for (int i = 2; i >= minI; --i) { + size.z = i; + orientBox(pos, offset, size, facing, &b0, &b1); + if (hasIntersection(p->bb0, p->bb1, b0, b1)) { + continue; + } + size.z = i + 1; + orientBox(pos, offset, size, facing, &b0, &b1); + if (b0.y > 1) { + goto L_box_end; + } + } + return 0; + default: UNREACHABLE(); + } + + orientBox(pos, offset, size, facing, &b0, &b1); + if (b0.y > 10 && hasCollision(env, b0, b1)) { + return 0; + } + +L_box_end: + + Piece *p = env->list + *env->n; + p->name = stronghold_info[typ].name; + p->pos = pos; + p->bb0 = b0; + p->bb1 = b1; + p->rot = facing; + p->depth = depth; + p->type = typ; + p->next = NULL; + + int additionalData = 0; + switch (typ) { + case SH_STRAIGHT: + nextInt(env->rng, 5); + additionalData |= (nextInt(env->rng, 2) == 0) << 0; + additionalData |= (nextInt(env->rng, 2) == 0) << 1; + break; + case SH_PRISON_HALL: + case SH_LEFT_TURN: + case SH_RIGHT_TURN: + case SH_STRAIGHT_STAIRS_DOWN: + case SH_STAIRS_DOWN: + case SH_CHEST_CORRIDOR: + case SH_LIBRARY: + nextInt(env->rng, 5); + break; + case SH_ROOM_CROSSING: + nextInt(env->rng, 5); + additionalData |= (nextInt(env->rng, 5) == 2) << 0; + break; + case SH_FIVE_CROSSING: + nextInt(env->rng, 5); + additionalData |= (next(env->rng, 1)) << 0; + additionalData |= (next(env->rng, 1)) << 1; + additionalData |= (next(env->rng, 1)) << 2; + additionalData |= (nextInt(env->rng, 3) > 0) << 3; + break; + case SH_PORTAL_ROOM: + *env->portal = 1; + break; + case SH_FILLER_CORRIDOR: break; + default: UNREACHABLE(); + } + + p->additionalData = additionalData; + + // accept the piece and append it to the processing front + //int queue = 0; + (*env->n)++; + Piece *q = env->list; + while (q->next) { + q = q->next; //queue++; + } + q->next = p; + + return 1; +} + +static void extendStronghold(StrongholdPieceEnv *env, Piece *piece, int x, int y, int z, int facing) { + if (piece->depth > 50) { + return; + } + + if (IABS(x - env->list->bb0.x) > 112 || IABS(z - env->list->bb0.z) > 112) { + return; + } + + if (env->generationStopped) { + return; + } + + int depth = piece->depth + 1; + + if (env->imposedPiece != -1) { + int imposedPiece = env->imposedPiece; + env->imposedPiece = -1; + if (addStrongholdPiece(env, imposedPiece, x, y, z, depth, facing)) { + return; + } + } + + for (int attempt = 0; attempt < 5; attempt++) { + int selectedWeight = nextInt(env->rng, env->totalWeight); + for (int pieceType = 0; pieceType < 11; pieceType++) { + if ((env->deltyp >> pieceType) & 1) continue; + + int *piecePlaceCount = &env->ntyp[pieceType]; + int pieceWeight = stronghold_info[pieceType].weight; + + if ((selectedWeight -= pieceWeight) >= 0) continue; + + if (!canPlace(*piecePlaceCount, pieceType, depth) || pieceType == env->typlast) break; + if (!addStrongholdPiece(env, pieceType, x, y, z, depth, facing)) continue; + (*piecePlaceCount)++; + env->typlast = pieceType; + if (!isValid(*piecePlaceCount, pieceType)) { + env->totalWeight -= pieceWeight; + env->deltyp |= 1 << pieceType; + updateGenerationStatus(env); + } + return; + } + } + + addStrongholdPiece(env, SH_FILLER_CORRIDOR, x, y, z, depth, facing); +} + +static void generateSmallDoorChildForward(StrongholdPieceEnv *env, Piece *piece, int offx, int offy) { + // WEST and EAST are swapped on old versions + switch (piece->rot) { + case 0: // facing 2 + return extendStronghold(env, piece, piece->bb0.x + offx, piece->bb0.y + offy, piece->bb0.z - 1, 0); + case 2: // facing 0 + return extendStronghold(env, piece, piece->bb0.x + offx, piece->bb0.y + offy, piece->bb1.z + 1, 2); + case 3: // facing 1 + return extendStronghold(env, piece, piece->bb0.x - 1, piece->bb0.y + offy, piece->bb0.z + offx, 3); + case 1: // facing 3 + return extendStronghold(env, piece, piece->bb1.x + 1, piece->bb0.y + offy, piece->bb0.z + offx, 1); + default: UNREACHABLE(); + } +} + +static void generateSmallDoorChildLeft(StrongholdPieceEnv *env, Piece *piece, int offy, int offz) { + switch (piece->rot) { + case 0: + case 2: + return extendStronghold(env, piece, piece->bb0.x - 1, piece->bb0.y + offy, piece->bb0.z + offz, 3); + case 3: + case 1: + return extendStronghold(env, piece, piece->bb0.x + offz, piece->bb0.y + offy, piece->bb0.z - 1, 0); + default: UNREACHABLE(); + } +} + +static void generateSmallDoorChildRight(StrongholdPieceEnv *env, Piece *piece, int offy, int offz) { + switch (piece->rot) { + case 0: + case 2: + return extendStronghold(env, piece, piece->bb1.x + 1, piece->bb0.y + offy, piece->bb0.z + offz, 1); + case 3: + case 1: + return extendStronghold(env, piece, piece->bb0.x + offz, piece->bb0.y + offy, piece->bb1.z + 1, 2); + default: UNREACHABLE(); + } +} + +static void extendStrongholdPiece(StrongholdPieceEnv *env, Piece *piece) { + switch (piece->type) { + case SH_STRAIGHT: + generateSmallDoorChildForward(env, piece, 1, 1); + if ((piece->additionalData & (1 << 0)) != 0) { + generateSmallDoorChildLeft(env, piece, 1, 2); + } + if ((piece->additionalData & (1 << 1)) != 0) { + generateSmallDoorChildRight(env, piece, 1, 2); + } + break; + case SH_PRISON_HALL: + generateSmallDoorChildForward(env, piece, 1, 1); + break; + case SH_LEFT_TURN: { + int rot = piece->rot; + if (rot == 0 || rot == 1) { + generateSmallDoorChildLeft(env, piece, 1, 1); + } else { + generateSmallDoorChildRight(env, piece, 1, 1); + } + } break; + case SH_RIGHT_TURN: { + int rot = piece->rot; + if (rot == 0 || rot == 1) { + generateSmallDoorChildRight(env, piece, 1, 1); + } else { + generateSmallDoorChildLeft(env, piece, 1, 1); + } + } break; + case SH_ROOM_CROSSING: + generateSmallDoorChildForward(env, piece, 4, 1); + generateSmallDoorChildLeft(env, piece, 1, 4); + generateSmallDoorChildRight(env, piece, 1, 4); + break; + case SH_STRAIGHT_STAIRS_DOWN: + generateSmallDoorChildForward(env, piece, 1, 1); + break; + case SH_STAIRS_DOWN: + if (piece->additionalData != 0) { + env->imposedPiece = SH_FIVE_CROSSING; + } + generateSmallDoorChildForward(env, piece, 1, 1); + break; + case SH_FIVE_CROSSING: { + int n = 3; + int n2 = 5; + int rot = piece->rot; + if (rot == 3 || rot == 0) { + n = 8 - n; + n2 = 8 - n2; + } + generateSmallDoorChildForward(env, piece, 5, 1); + if ((piece->additionalData & (1 << 0)) != 0) { + generateSmallDoorChildLeft(env, piece, n, 1); + } + if ((piece->additionalData & (1 << 1)) != 0) { + generateSmallDoorChildLeft(env, piece, n2, 7); + } + if ((piece->additionalData & (1 << 2)) != 0) { + generateSmallDoorChildRight(env, piece, n, 1); + } + if ((piece->additionalData & (1 << 3)) != 0) { + generateSmallDoorChildRight(env, piece, n2, 7); + } + } break; + case SH_CHEST_CORRIDOR: + generateSmallDoorChildForward(env, piece, 1, 1); + break; + case SH_LIBRARY: + case SH_PORTAL_ROOM: + case SH_FILLER_CORRIDOR: + break; + default: UNREACHABLE(); + } +} + +int getStrongholdPieces(Piece *list, int n, int mc, uint64_t seed, int chunkX, int chunkZ) { + static const int OLD_ROTATIONS[] = {2, 3, 0, 1}; + + int x = (chunkX << 4) + 2; + int z = (chunkZ << 4) + 2; + + uint64_t rng; + if (mc <= MC_1_12_2) { + rng = chunkGenerateRnd(seed, chunkX, chunkZ); + next(&rng, 32); + } + + uint64_t attempt = 0; + + int count, portal = 0; + StrongholdPieceEnv env; + do { + count = 1; + + // reset pieces + memset(&env, 0, sizeof(env)); + env.mc = mc; + env.list = list; + env.n = &count; + env.rng = &rng; + env.portal = &portal; + env.imposedPiece = -1; + env.ntyp[0] = 1; + env.typlast = -1; + env.nmax = n; + env.totalWeight = 145; + + if (mc > MC_1_12_2) { + rng = chunkGenerateRnd(seed + attempt++, chunkX, chunkZ); + } + + Piece *p = list; + p->type = SH_STAIRS_DOWN; + p->name = stronghold_info[SH_STAIRS_DOWN].name; + p->bb0 = p->bb1 = p->pos = (Pos3) {x, 64, z}; + int sizeX = stronghold_info[SH_STAIRS_DOWN].size.x; + int sizeY = stronghold_info[SH_STAIRS_DOWN].size.y; + int sizeZ = stronghold_info[SH_STAIRS_DOWN].size.z; + int rotation = nextInt(&rng, 4); + if (mc < MC_1_8) rotation = OLD_ROTATIONS[rotation]; + p->rot = rotation; + switch (p->rot) { + case 0: case 2: + p->bb1.x += sizeX - 1; p->bb1.y += sizeY - 1; p->bb1.z += sizeZ - 1; break; + case 1: case 3: + p->bb1.x += sizeZ - 1; p->bb1.y += sizeY - 1; p->bb1.z += sizeX - 1; break; + default: UNREACHABLE(); + } + p->additionalData = 1; + + p->depth = 0; + p->next = NULL; + + extendStrongholdPiece(&env, p); + while (list->next && !env.generationStopped) { + Piece *q = list; + int len = 0; + while (q->next) { + q = q->next; + len++; + } + int i = nextInt(&rng, len); + for (p = list, q = list->next; i-->0; p = q, q = q->next); + p->next = q->next; + q->next = NULL; + extendStrongholdPiece(&env, q); + } + + // necessary for <=1.12.2 to simulate random calls + // optional for >1.12.2, could add flag for accurate heights + if (mc <= MC_1_12_2 && !env.portal) { + int minY = p->bb0.y; + int maxY = p->bb1.y; + for (int i = 0; i < count; i++) { + Piece q = list[i]; + int bMin = q.bb0.y; + int bMax = q.bb1.y; + minY = MIN(minY, bMin); + maxY = MAX(maxY, bMax); + } + int height = maxY - minY + 1; + + int seaLevel = 63; + int offset = 10; + int minWorldY = mc < MC_1_18 ? 0 : -64; + + int maxAllowedY = seaLevel - offset; + int k = height + minWorldY + 1; + if (k < maxAllowedY) { + k += nextInt(&rng, maxAllowedY - k); + } + + int dy = k - maxY; + for (int i = 0; i < count; i++) { + Piece *q = &list[i]; + q->bb0.y += dy; + q->bb1.y += dy; + q->pos.y += dy; + } + } + } while (!*env.portal); + + return *env.n; +} + +static inline void rotPos(Pos3 bb0, Pos3 bb1, int *x, int *z, int rot) { + int posX, posZ; + switch (rot) { + case 0: posX = bb0.x + *x, posZ = bb1.z - *z; break; + case 1: posX = bb0.x + *z, posZ = bb0.z + *x; break; + case 2: posX = bb0.x + *x, posZ = bb0.z + *z; break; + case 3: posX = bb1.x - *z, posZ = bb0.z + *x; break; + default: UNREACHABLE(); + } + *x = posX, *z = posZ; +} + +static void generateBox(Piece *p, int cx, int cz, int x0, int y0, int z0, int x1, int y1, int z1, int skipAir, RandomSource rnd) { + if (!skipAir) { + int w = x1 - x0 + 1; + int d = z1 - z0 + 1; + int h = y1 - y0 + 1; + int skips = w * d * h; + if (!(w == 1 || d == 1 || h == 1)) { + skips -= (w - 2) * (d - 2) * (h - 2); + } + rnd.skipN(rnd.state, skips); + return; + } + + for (int y = y0; y <= y1; y++) { + for (int x = x0; x <= x1; x++) { + for (int z = z0; z <= z1; z++) { + int tx = x, tz = z; + rotPos(p->bb0, p->bb1, &tx, &tz, p->rot); + if (tx >= cx && tx < cx + 16 && tz >= cz && tz < cz + 16) { + if (y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1) { + rnd.nextFloat(rnd.state); + } + } + } + } + } +} + +ATTR(always_inline) +static inline void generateMaybeBox(int x0, int y0, int z0, int x1, int y1, int z1, RandomSource rnd) { + rnd.skipN(rnd.state, (y1-y0+1) * (x1-x0+1) * (z1-z0+1)); +} + +static const Pos eye_positions[] = { + {4, 8}, + {5, 8}, + {6, 8}, + {4, 12}, + {5, 12}, + {6, 12}, + {3, 9}, + {3, 10}, + {3, 11}, + {7, 9}, + {7, 10}, + {7, 11}, +}; + +int getStrongholdLoot(Piece *list, int n, StructureSaltConfig ssconf, int mc, uint64_t seed, int chunkX, int chunkZ) { + int count = getStrongholdPieces(list, n, mc, seed, chunkX, chunkZ); + if (!count) { + return 0; + } + const int legacy = mc <= MC_1_17; + int minX = list->bb0.x; + int minZ = list->bb0.z; + int maxX = list->bb1.x; + int maxZ = list->bb1.z; + for (int i = 0; i < count; ++i) { + Piece *p = &list[i]; + minX = MIN(minX, p->bb0.x); + minZ = MIN(minZ, p->bb0.z); + maxX = MAX(maxX, p->bb1.x); + maxZ = MAX(maxZ, p->bb1.z); + } + int cMinX = minX & ~15; + int cMinZ = minZ & ~15; + int cMaxX = maxX & ~15; + int cMaxZ = maxZ & ~15; + + // slow code ahead + for (int cx = cMinX; cx <= cMaxX; cx += 16) { + for (int cz = cMinZ; cz <= cMaxZ; cz += 16) { + CREATE_RANDOM_SOURCE(rnd, legacy); + uint64_t populationSeed = getPopulationSeed(mc, seed, cx, cz); + rnd.setSeed(rnd.state, populationSeed + ssconf.generationStep * 10000 + ssconf.decoratorIndex); + for (int i = 0; i < count; ++i) { + Piece *p = &list[i]; + if (!(p->bb1.x >= cx && p->bb0.x <= cx + 15 && + p->bb1.z >= cz && p->bb0.z <= cz + 15)) { + continue; + } + switch (p->type) { + case SH_STRAIGHT: + generateBox(p, cx, cz, 0, 0, 0, 4, 4, 6, 1, rnd); + rnd.nextFloat(rnd.state); + rnd.nextFloat(rnd.state); + rnd.nextFloat(rnd.state); + rnd.nextFloat(rnd.state); + p->chestCount = 0; + break; + case SH_PRISON_HALL: + generateBox(p, cx, cz, 0, 0, 0, 8, 4, 10, 1, rnd); + generateBox(p, cx, cz, 4, 1, 1, 4, 3, 1, 0, rnd); + generateBox(p, cx, cz, 4, 1, 3, 4, 3, 3, 0, rnd); + generateBox(p, cx, cz, 4, 1, 7, 4, 3, 7, 0, rnd); + generateBox(p, cx, cz, 4, 1, 9, 4, 3, 9, 0, rnd); + p->chestCount = 0; + break; + case SH_LEFT_TURN: + case SH_RIGHT_TURN: + generateBox(p, cx, cz, 0, 0, 0, 4, 4, 4, 1, rnd); + p->chestCount = 0; + break; + case SH_ROOM_CROSSING: { + generateBox(p, cx, cz, 0, 0, 0, 10, 6, 10, 1, rnd); + if (!p->additionalData) { + p->chestCount = 0; + break; + } + + int chestPosX = 3, chestPosZ = 8; + rotPos(p->bb0, p->bb1, &chestPosX, &chestPosZ, p->rot); + if (chestPosX >= cx && chestPosX < cx + 16 && chestPosZ >= cz && chestPosZ < cz + 16) { + p->chestCount = 1; + p->chestPoses[0] = (Pos) {chestPosX, chestPosZ}; + p->lootTables[0] = "stronghold_crossing"; + p->lootSeeds[0] = rnd.nextLong(rnd.state); + } + break; + } + case SH_STRAIGHT_STAIRS_DOWN: + generateBox(p, cx, cz, 0, 0, 0, 4, 10, 7, 1, rnd); + p->chestCount = 0; + break; + case SH_STAIRS_DOWN: + generateBox(p, cx, cz, 0, 0, 0, 4, 10, 4, 1, rnd); + p->chestCount = 0; + break; + case SH_FIVE_CROSSING: + generateBox(p, cx, cz, 0, 0, 0, 9, 8, 10, 1, rnd); + generateBox(p, cx, cz, 1, 2, 1, 8, 2, 6, 0, rnd); + generateBox(p, cx, cz, 4, 1, 5, 4, 4, 9, 0, rnd); + generateBox(p, cx, cz, 8, 1, 5, 8, 4, 9, 0, rnd); + generateBox(p, cx, cz, 1, 4, 7, 3, 4, 9, 0, rnd); + generateBox(p, cx, cz, 1, 3, 5, 3, 3, 6, 0, rnd); + generateBox(p, cx, cz, 5, 1, 7, 7, 1, 8, 0, rnd); + p->chestCount = 0; + break; + case SH_CHEST_CORRIDOR: { + generateBox(p, cx, cz, 0, 0, 0, 4, 4, 6, 1, rnd); + int chestPosX = 3, chestPosZ = 3; + rotPos(p->bb0, p->bb1, &chestPosX, &chestPosZ, p->rot); + if (chestPosX >= cx && chestPosX < cx + 16 && chestPosZ >= cz && chestPosZ < cz + 16) { + p->chestCount = 1; + p->chestPoses[0] = (Pos) {chestPosX, chestPosZ}; + p->lootTables[0] = "stronghold_corridor"; + p->lootSeeds[0] = rnd.nextLong(rnd.state); + } + break; + } + case SH_LIBRARY: { + int isTall = p->bb1.y - p->bb0.y + 1 > 6; + int currentHeight; + if (isTall) { + currentHeight = 11; + p->chestCount = 2; + } else { + currentHeight = 6; + p->chestCount = 1; + } + + generateBox(p, cx, cz, 0, 0, 0, 13, currentHeight - 1, 14, 1, rnd); + generateMaybeBox(2, 1, 1, 11, 4, 13, rnd); + int chestPosX = 3, chestPosZ = 5; + rotPos(p->bb0, p->bb1, &chestPosX, &chestPosZ, p->rot); + if (chestPosX >= cx && chestPosX < cx + 16 && chestPosZ >= cz && chestPosZ < cz + 16) { + p->chestPoses[0] = (Pos) {chestPosX, chestPosZ}; + p->lootTables[0] = "stronghold_library"; + p->lootSeeds[0] = rnd.nextLong(rnd.state); + } + if (isTall) { + chestPosX = 12, chestPosZ = 1; + rotPos(p->bb0, p->bb1, &chestPosX, &chestPosZ, p->rot); + if (chestPosX >= cx && chestPosX < cx + 16 && chestPosZ >= cz && chestPosZ < cz + 16) { + p->chestPoses[1] = (Pos) {chestPosX, chestPosZ}; + p->lootTables[1] = "stronghold_library"; + p->lootSeeds[1] = rnd.nextLong(rnd.state); + } + } + break; + } + case SH_PORTAL_ROOM: + // the famous 760 skips + rnd.skipN(rnd.state, 760); + // generateBox(p, cx, cz, 0, 0, 0, 10, 7, 15, 0, rnd); + // generateBox(p, cx, cz, 1, 6, 1, 1, 6, 14, 0, rnd); + // generateBox(p, cx, cz, 9, 6, 1, 9, 6, 14, 0, rnd); + // generateBox(p, cx, cz, 2, 6, 1, 8, 6, 2, 0, rnd); + // generateBox(p, cx, cz, 2, 6, 14, 8, 6, 14, 0, rnd); + // generateBox(p, cx, cz, 1, 1, 1, 2, 1, 4, 0, rnd); + // generateBox(p, cx, cz, 8, 1, 1, 9, 1, 4, 0, rnd); + // generateBox(p, cx, cz, 3, 1, 8, 7, 1, 12, 0, rnd); + // generateBox(p, cx, cz, 4, 1, 5, 6, 1, 7, 0, rnd); + // generateBox(p, cx, cz, 4, 2, 6, 6, 2, 7, 0, rnd); + // generateBox(p, cx, cz, 4, 3, 7, 6, 3, 7, 0, rnd); + + for (int j = 0; j < 12; j++) { + if (rnd.nextFloat(rnd.state) > 0.9F) { + Pos relPos = eye_positions[j]; + int eyePosX = relPos.x, eyePosZ = relPos.z; + rotPos(p->bb0, p->bb1, &eyePosX, &eyePosZ, p->rot); + if (eyePosX >= cx && eyePosX < cx + 16 && eyePosZ >= cz && eyePosZ < cz + 16) { + p->additionalData |= (1 << j); + } + } + } + p->chestCount = 0; + break; + case SH_FILLER_CORRIDOR: + p->chestCount = 0; + break; + default: UNREACHABLE(); + } + } + } + } + return count; +} diff --git a/features/stronghold.h b/features/stronghold.h new file mode 100644 index 0000000..1c11497 --- /dev/null +++ b/features/stronghold.h @@ -0,0 +1,67 @@ +#ifndef STRONGHOLD_H_ +#define STRONGHOLD_H_ + +#include "../finders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Generate the structure pieces of a Stronghold. The maximum number of pieces + * that are generated is limited to 'n'. A buffer length of around 400 should + * be sufficient in practice, but a stronghold can in theory contain many more + * than that. The number of generated pieces is given by the return value. + * + * This function does not compute loot seeds or portal room eye count, use + * `getStrongholdLoot` for that. + * + * @param list the pieces list + * @param n the maximum number of pieces to generate + * @param mc the Minecraft version + * @param seed the world seed (lower 48 bits suffice) + * @param chunkX the chunk X-coordinate + * @param chunkZ the chunk Z-coordinate + * @return the number of pieces that were generated + */ +int getStrongholdPieces(Piece *list, int n, int mc, uint64_t seed, int chunkX, int chunkZ); + +enum { + SH_STRAIGHT = 0, + SH_PRISON_HALL, + SH_LEFT_TURN, + SH_RIGHT_TURN, + SH_ROOM_CROSSING, + SH_STRAIGHT_STAIRS_DOWN, + SH_STAIRS_DOWN, + SH_FIVE_CROSSING, + SH_CHEST_CORRIDOR, + SH_LIBRARY, + SH_PORTAL_ROOM, + SH_FILLER_CORRIDOR, + SH_PIECE_COUNT, +}; + +/** + * First generates the Stronghold's pieces using getStrongholdPieces. Then + * for each pieces with chests, the chest's position, loot table and loot + * seed is written. For the portal room, the eye final eye count is written + * to p.additionalData using a bit array (e.g. 0b101011011100 would mean + * 7 eyes are generated). + * + * @param list the pieces list + * @param n the maximum number of pieces to generate + * @param ssconf the salt config, use getStructureSaltConfig to obtain it + * @param mc the Minecraft version + * @param seed the world seed (lower 48 bits suffice) + * @param chunkX the chunk X-coordinate + * @param chunkZ the chunk Z-coordinate + * @return the number of pieces that were generated + */ +int getStrongholdLoot(Piece *list, int n, StructureSaltConfig ssconf, int mc, uint64_t seed, int chunkX, int chunkZ); + +#ifdef __cplusplus +} +#endif + +#endif //STRONGHOLD_H_ diff --git a/finders.c b/finders.c index e272022..f9ac33c 100644 --- a/finders.c +++ b/finders.c @@ -1,6 +1,7 @@ #include "finders.h" #include "biomes.h" #include "util.h" +#include "features/stronghold.h" #include #include @@ -304,6 +305,11 @@ int getStructureSaltConfig(int structureType, int mc, int biome, StructureSaltCo ss_ruined_portal_ocean_1192 = {4, 24}, ss_ruined_portal_ocean_1194 = {4, 15}, + ss_stronghold_113 = {2, 1}, + ss_stronghold_116 = {5, 0}, + ss_stronghold_1192 = {4, 8}, + ss_stronghold_1194 = {4, 19}, + ss_ruined_portal_nether_118 = {4, 24}, ss_ruined_portal_nether_1192 = {4, 25}, ss_ruined_portal_nether_1194 = {4, 14}, @@ -387,6 +393,12 @@ int getStructureSaltConfig(int structureType, int mc, int biome, StructureSaltCo else *ssconf = ss_ruined_portal_1194; // assuming biome != deep_dark } return mc >= MC_1_16_1; + case Stronghold: + if (mc < MC_1_16_1) *ssconf = ss_stronghold_113; + else if (mc < MC_1_19_2) *ssconf = ss_stronghold_116; + else if (mc < MC_1_19_4) *ssconf = ss_stronghold_1192; + else *ssconf = ss_stronghold_1194; + return mc >= MC_1_13; case Ruined_Portal_N: if (mc < MC_1_19_2) *ssconf = ss_ruined_portal_nether_118; else if (mc < MC_1_19_4) *ssconf = ss_ruined_portal_nether_1192; @@ -4480,6 +4492,7 @@ int getStructurePieces(Piece *list, int n, int stype, StructureSaltConfig ssconf } return count; } + case Stronghold: return getStrongholdLoot(list, n, ssconf, mc, seed, posX >> 4, posZ >> 4); // structures that have one piece and one chest case Treasure: { Piece* p = list; @@ -4842,10 +4855,7 @@ Piece *addFortressPiece(PieceEnv *env, int typ, int x, int y, int z, int depth, for (i = 0; i < n; i++) { Piece *q = env->list + i; - if (q->bb1.x >= p->bb0.x && q->bb0.x <= p->bb1.x && - q->bb1.z >= p->bb0.z && q->bb0.z <= p->bb1.z && - q->bb1.y >= p->bb0.y && q->bb0.y <= p->bb1.y) - { + if (hasIntersection(q->bb0, q->bb1, p->bb0, p->bb1)) { return NULL; // collision } } @@ -5035,7 +5045,6 @@ int getFortressPieces(Piece *list, int n, int mc, uint64_t seed, int chunkX, int return count; } - uint64_t getHouseList(int *out, uint64_t seed, int chunkX, int chunkZ) { uint64_t rng = chunkGenerateRnd(seed, chunkX, chunkZ); diff --git a/finders.h b/finders.h index 746af59..141a89d 100644 --- a/finders.h +++ b/finders.h @@ -39,6 +39,7 @@ enum StructureType End_Island, Trail_Ruins, Trial_Chambers, + Stronghold, // not like the other structures, but nice to have a constant for it FEATURE_NUM }; @@ -62,6 +63,41 @@ STRUCT(StructureSaltConfig) { STRUCT(Pos) { int x, z; }; STRUCT(Pos3) { int x, y, z; }; + +static inline void orientBox(Pos3 pos, Pos3 offset, Pos3 size, int facing, Pos3 *b0, Pos3 *b1) { + *b0 = pos, *b1 = pos; + Pos3 d0 = offset, d1 = size; + b0->y += d0.y; + b1->y += d0.y+d1.y-1; + + switch (facing) { + case 0: // 0, north + b0->x += d0.x; b0->z += d0.z-d1.z+1; + b1->x += d0.x+d1.x-1; b1->z += d0.z; + break; + case 1: // 90, east + b0->x += d0.z; b0->z += d0.x; + b1->x += d0.z+d1.z-1; b1->z += d0.x+d1.x-1; + break; + case 2: // 180, south + b0->x += d0.x; b0->z += d0.z; + b1->x += d0.x+d1.x-1; b1->z += d0.z+d1.z-1; + break; + case 3: // 270, west + b0->x += d0.z-d1.z+1; b0->z += d0.x; + b1->x += d0.z; b1->z += d0.x+d1.x-1; + break; + default: UNREACHABLE(); + } +} + +ATTR(always_inline) +static inline int hasIntersection(Pos3 bmin0, Pos3 bmax0, Pos3 bmin1, Pos3 bmax1) { + return bmax0.x >= bmin1.x && bmin0.x <= bmax1.x && + bmax0.z >= bmin1.z && bmin0.z <= bmax1.z && + bmax0.y >= bmin1.y && bmin0.y <= bmax1.y; +} + STRUCT(Pos3List) { Pos3* pos3s; @@ -118,6 +154,7 @@ STRUCT(Piece) Pos chestPoses[4]; // assume a maximum of four chests uint64_t lootSeeds[4]; const char* lootTables[4]; + int additionalData; Piece *next; }; diff --git a/includes.txt b/includes.txt index 96d0a9e..e5002a0 100644 --- a/includes.txt +++ b/includes.txt @@ -332,6 +332,7 @@ --include-function getPopulationSeed --include-function getPossibleBiomesForLimits --include-function getSpawn +--include-function getStrongholdPieces --include-function getStructureConfig --include-function getStructurePieces --include-function getStructurePos @@ -482,12 +483,26 @@ --include-constant SECOND_FLOOR_1 --include-constant SECOND_FLOOR_2 --include-constant SECOND_ROOF +--include-constant SH_STRAIGHT +--include-constant SH_PRISON_HALL +--include-constant SH_LEFT_TURN +--include-constant SH_RIGHT_TURN +--include-constant SH_ROOM_CROSSING +--include-constant SH_STRAIGHT_STAIRS_DOWN +--include-constant SH_STAIRS_DOWN +--include-constant SH_FIVE_CROSSING +--include-constant SH_CHEST_CORRIDOR +--include-constant SH_LIBRARY +--include-constant SH_PORTAL_ROOM +--include-constant SH_FILLER_CORRIDOR +--include-constant SH_PIECE_COUNT --include-constant SOUL_SAND --include-constant STONE --include-constant Shipwreck --include-constant SmallDebrisOre --include-constant SmallIronOre --include-constant SoulSandOre +--include-constant Stronghold --include-constant Swamp_Hut --include-constant THIRD_FLOOR_1 --include-constant THIRD_FLOOR_2 @@ -684,6 +699,7 @@ --include-constant ITEM_BONE --include-constant ITEM_BONE_BLOCK --include-constant ITEM_BOOK +--include-constant ITEM_BREAD --include-constant ITEM_CARROT --include-constant ITEM_CHAIN --include-constant ITEM_CLOCK @@ -712,7 +728,9 @@ --include-constant ITEM_DUNE_ARMOR_TRIM_SMITHING_TEMPLATE --include-constant ITEM_EMERALD --include-constant ITEM_ENCHANTED_GOLDEN_APPLE +--include-constant ITEM_ENDER_PEARL --include-constant ITEM_EXPERIENCE_BOTTLE +--include-constant ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE --include-constant ITEM_FEATHER --include-constant ITEM_FIRE_CHARGE --include-constant ITEM_FLINT @@ -763,6 +781,7 @@ --include-constant ITEM_MAGMA_CREAM --include-constant ITEM_MAP --include-constant ITEM_MOSS_BLOCK +--include-constant ITEM_MUSIC_DISC_OTHERSIDE --include-constant ITEM_MUSIC_DISC_PIGSTEP --include-constant ITEM_NETHERITE_SCRAP --include-constant ITEM_NETHERITE_UPGRADE_SMITHING_TEMPLATE @@ -775,6 +794,7 @@ --include-constant ITEM_POTATO --include-constant ITEM_PRISMARINE_CRYSTALS --include-constant ITEM_PUMPKIN +--include-constant ITEM_REDSTONE --include-constant ITEM_RIB_ARMOR_TRIM_SMITHING_TEMPLATE --include-constant ITEM_ROTTEN_FLESH --include-constant ITEM_SADDLE diff --git a/loot/items.c b/loot/items.c index 2d5dbdf..82d1afd 100644 --- a/loot/items.c +++ b/loot/items.c @@ -14,6 +14,7 @@ int item_name2global_id(const char* name) { if (strcmp(name, "minecraft:bone") == 0) return ITEM_BONE; if (strcmp(name, "minecraft:bone_block") == 0) return ITEM_BONE_BLOCK; if (strcmp(name, "minecraft:book") == 0) return ITEM_BOOK; + if (strcmp(name, "minecraft:bread") == 0) return ITEM_BREAD; if (strcmp(name, "minecraft:carrot") == 0) return ITEM_CARROT; if (strcmp(name, "minecraft:chain") == 0) return ITEM_CHAIN; if (strcmp(name, "minecraft:clock") == 0) return ITEM_CLOCK; @@ -42,7 +43,9 @@ int item_name2global_id(const char* name) { if (strcmp(name, "minecraft:dune_armor_trim_smithing_template") == 0) return ITEM_DUNE_ARMOR_TRIM_SMITHING_TEMPLATE; if (strcmp(name, "minecraft:emerald") == 0) return ITEM_EMERALD; if (strcmp(name, "minecraft:enchanted_golden_apple") == 0) return ITEM_ENCHANTED_GOLDEN_APPLE; + if (strcmp(name, "minecraft:ender_pearl") == 0) return ITEM_ENDER_PEARL; if (strcmp(name, "minecraft:experience_bottle") == 0) return ITEM_EXPERIENCE_BOTTLE; + if (strcmp(name, "minecraft:eye_armor_trim_smithing_template") == 0) return ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE; if (strcmp(name, "minecraft:feather") == 0) return ITEM_FEATHER; if (strcmp(name, "minecraft:fire_charge") == 0) return ITEM_FIRE_CHARGE; if (strcmp(name, "minecraft:flint") == 0) return ITEM_FLINT; @@ -93,6 +96,7 @@ int item_name2global_id(const char* name) { if (strcmp(name, "minecraft:magma_cream") == 0) return ITEM_MAGMA_CREAM; if (strcmp(name, "minecraft:map") == 0) return ITEM_MAP; if (strcmp(name, "minecraft:moss_block") == 0) return ITEM_MOSS_BLOCK; + if (strcmp(name, "minecraft:music_disc_otherside") == 0) return ITEM_MUSIC_DISC_OTHERSIDE; if (strcmp(name, "minecraft:music_disc_pigstep") == 0) return ITEM_MUSIC_DISC_PIGSTEP; if (strcmp(name, "minecraft:netherite_scrap") == 0) return ITEM_NETHERITE_SCRAP; if (strcmp(name, "minecraft:netherite_upgrade_smithing_template") == 0) return ITEM_NETHERITE_UPGRADE_SMITHING_TEMPLATE; @@ -105,6 +109,7 @@ int item_name2global_id(const char* name) { if (strcmp(name, "minecraft:potato") == 0) return ITEM_POTATO; if (strcmp(name, "minecraft:prismarine_crystals") == 0) return ITEM_PRISMARINE_CRYSTALS; if (strcmp(name, "minecraft:pumpkin") == 0) return ITEM_PUMPKIN; + if (strcmp(name, "minecraft:redstone") == 0) return ITEM_REDSTONE; if (strcmp(name, "minecraft:rib_armor_trim_smithing_template") == 0) return ITEM_RIB_ARMOR_TRIM_SMITHING_TEMPLATE; if (strcmp(name, "minecraft:rotten_flesh") == 0) return ITEM_ROTTEN_FLESH; if (strcmp(name, "minecraft:saddle") == 0) return ITEM_SADDLE; @@ -139,6 +144,7 @@ const char* global_id2item_name(int global_id, int mc) { case ITEM_BONE: return "minecraft:bone"; case ITEM_BONE_BLOCK: return "minecraft:bone_block"; case ITEM_BOOK: return "minecraft:book"; + case ITEM_BREAD: return "minecraft:bread"; case ITEM_CARROT: return "minecraft:carrot"; case ITEM_CHAIN: return "minecraft:chain"; case ITEM_CLOCK: return "minecraft:clock"; @@ -167,7 +173,9 @@ const char* global_id2item_name(int global_id, int mc) { case ITEM_DUNE_ARMOR_TRIM_SMITHING_TEMPLATE: return "minecraft:dune_armor_trim_smithing_template"; case ITEM_EMERALD: return "minecraft:emerald"; case ITEM_ENCHANTED_GOLDEN_APPLE: return "minecraft:enchanted_golden_apple"; + case ITEM_ENDER_PEARL: return "minecraft:ender_pearl"; case ITEM_EXPERIENCE_BOTTLE: return "minecraft:experience_bottle"; + case ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE: return "minecraft:eye_armor_trim_smithing_template"; case ITEM_FEATHER: return "minecraft:feather"; case ITEM_FIRE_CHARGE: return "minecraft:fire_charge"; case ITEM_FLINT: return "minecraft:flint"; @@ -217,6 +225,7 @@ const char* global_id2item_name(int global_id, int mc) { case ITEM_MAGMA_CREAM: return "minecraft:magma_cream"; case ITEM_MAP: return "minecraft:map"; case ITEM_MOSS_BLOCK: return "minecraft:moss_block"; + case ITEM_MUSIC_DISC_OTHERSIDE: return "minecraft:music_disc_otherside"; case ITEM_MUSIC_DISC_PIGSTEP: return "minecraft:music_disc_pigstep"; case ITEM_NETHERITE_SCRAP: return "minecraft:netherite_scrap"; case ITEM_NETHERITE_UPGRADE_SMITHING_TEMPLATE: return "minecraft:netherite_upgrade_smithing_template"; @@ -229,6 +238,7 @@ const char* global_id2item_name(int global_id, int mc) { case ITEM_POTATO: return "minecraft:potato"; case ITEM_PRISMARINE_CRYSTALS: return "minecraft:prismarine_crystals"; case ITEM_PUMPKIN: return "minecraft:pumpkin"; + case ITEM_REDSTONE: return "minecraft:redstone"; case ITEM_RIB_ARMOR_TRIM_SMITHING_TEMPLATE: return "minecraft:rib_armor_trim_smithing_template"; case ITEM_ROTTEN_FLESH: return "minecraft:rotten_flesh"; case ITEM_SADDLE: return "minecraft:saddle"; diff --git a/loot/items.h b/loot/items.h index 90021b8..977ec40 100644 --- a/loot/items.h +++ b/loot/items.h @@ -12,6 +12,7 @@ enum Item { ITEM_BONE, ITEM_BONE_BLOCK, ITEM_BOOK, + ITEM_BREAD, ITEM_CARROT, ITEM_CHAIN, ITEM_IRON_CHAIN = ITEM_CHAIN, @@ -41,7 +42,9 @@ enum Item { ITEM_DUNE_ARMOR_TRIM_SMITHING_TEMPLATE, ITEM_EMERALD, ITEM_ENCHANTED_GOLDEN_APPLE, + ITEM_ENDER_PEARL, ITEM_EXPERIENCE_BOTTLE, + ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE, ITEM_FEATHER, ITEM_FIRE_CHARGE, ITEM_FLINT, @@ -91,6 +94,7 @@ enum Item { ITEM_MAGMA_CREAM, ITEM_MAP, ITEM_MOSS_BLOCK, + ITEM_MUSIC_DISC_OTHERSIDE, ITEM_MUSIC_DISC_PIGSTEP, ITEM_NETHERITE_SCRAP, ITEM_NETHERITE_UPGRADE_SMITHING_TEMPLATE, @@ -103,6 +107,7 @@ enum Item { ITEM_POTATO, ITEM_PRISMARINE_CRYSTALS, ITEM_PUMPKIN, + ITEM_REDSTONE, ITEM_RIB_ARMOR_TRIM_SMITHING_TEMPLATE, ITEM_ROTTEN_FLESH, ITEM_SADDLE, diff --git a/loot/loot_tables.c b/loot/loot_tables.c index 3f05ffa..1271820 100644 --- a/loot/loot_tables.c +++ b/loot/loot_tables.c @@ -54,6 +54,14 @@ #include "loot_tables/shipwreck_treasure_1_13.h" #include "loot_tables/shipwreck_treasure_1_20.h" #include "loot_tables/shipwreck_treasure_1_21_11.h" +#include "loot_tables/stronghold_corridor_1_13.h" +#include "loot_tables/stronghold_corridor_1_18.h" +#include "loot_tables/stronghold_corridor_1_20.h" +#include "loot_tables/stronghold_corridor_1_21_6.h" +#include "loot_tables/stronghold_corridor_1_21_9.h" +#include "loot_tables/stronghold_crossing_1_13.h" +#include "loot_tables/stronghold_library_1_13.h" +#include "loot_tables/stronghold_library_1_20.h" int init_loot_table_name(LootTableContext** context, const char* loot_table, int version) { if (strcmp(loot_table, "bastion_bridge") == 0) { @@ -98,6 +106,15 @@ int init_loot_table_name(LootTableContext** context, const char* loot_table, int if (strcmp(loot_table, "shipwreck_treasure") == 0) { return init_shipwreck_treasure(context, version); } + if (strcmp(loot_table, "stronghold_corridor") == 0) { + return init_stronghold_corridor(context, version); + } + if (strcmp(loot_table, "stronghold_crossing") == 0) { + return init_stronghold_crossing(context, version); + } + if (strcmp(loot_table, "stronghold_library") == 0) { + return init_stronghold_library(context, version); + } fprintf(stderr, "ERR init_loot_table_name: unsupported loot_table %s\n", loot_table); *context = NULL; return 0; @@ -207,3 +224,23 @@ int init_shipwreck_treasure(LootTableContext** context, int version) { else *context = init_shipwreck_treasure_1_21_11(); return version > MC_1_12; } + +int init_stronghold_corridor(LootTableContext** context, int version) { + if (version < MC_1_18) *context = init_stronghold_corridor_1_13(); + else if (version < MC_1_20) *context = init_stronghold_corridor_1_18(); + else if (version < MC_1_21_6) *context = init_stronghold_corridor_1_20(); + else if (version < MC_1_21_9) *context = init_stronghold_corridor_1_21_6(); + else *context = init_stronghold_corridor_1_21_9(); + return version > MC_1_12; +} + +int init_stronghold_crossing(LootTableContext** context, int version) { + *context = init_stronghold_crossing_1_13(); + return version > MC_1_12; +} + +int init_stronghold_library(LootTableContext** context, int version) { + if (version < MC_1_20) *context = init_stronghold_library_1_13(); + else *context = init_stronghold_library_1_20(); + return version > MC_1_12; +} diff --git a/loot/loot_tables.h b/loot/loot_tables.h index ea57679..51565c9 100644 --- a/loot/loot_tables.h +++ b/loot/loot_tables.h @@ -19,5 +19,8 @@ int init_ruined_portal(LootTableContext** context, int version); int init_shipwreck_map(LootTableContext** context, int version); int init_shipwreck_supply(LootTableContext** context, int version); int init_shipwreck_treasure(LootTableContext** context, int version); +int init_stronghold_corridor(LootTableContext** context, int version); +int init_stronghold_crossing(LootTableContext** context, int version); +int init_stronghold_library(LootTableContext** context, int version); #endif //LOOT_TABLES_H diff --git a/loot/loot_tables/stronghold_corridor.1_13.json b/loot/loot_tables/stronghold_corridor.1_13.json new file mode 100644 index 0000000..75a3f23 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor.1_13.json @@ -0,0 +1,168 @@ +{ + "pools": [ + { + "rolls": { + "min": 2, + "max": 3 + }, + "entries": [ + { + "type": "item", + "name": "minecraft:ender_pearl", + "weight": 10 + }, + { + "type": "item", + "name": "minecraft:diamond", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 3 + }, + { + "type": "item", + "name": "minecraft:iron_ingot", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 5 + } + } + ], + "weight": 10 + }, + { + "type": "item", + "name": "minecraft:gold_ingot", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:redstone", + "functions": [ + { + "function": "set_count", + "count": { + "min": 4, + "max": 9 + } + } + ], + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:bread", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 15 + }, + { + "type": "item", + "name": "minecraft:apple", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 15 + }, + { + "type": "item", + "name": "minecraft:iron_pickaxe", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:iron_sword", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:iron_chestplate", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:iron_helmet", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:iron_leggings", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:iron_boots", + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:golden_apple", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:saddle", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:iron_horse_armor", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:golden_horse_armor", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:diamond_horse_armor", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:book", + "weight": 1, + "functions": [ + { + "function": "enchant_with_levels", + "levels": 30, + "treasure": true + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_corridor.1_18.json b/loot/loot_tables/stronghold_corridor.1_18.json new file mode 100644 index 0000000..3b26502 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor.1_18.json @@ -0,0 +1,181 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "rolls": { + "type": "minecraft:uniform", + "min": 2.0, + "max": 3.0 + }, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "weight": 10, + "name": "minecraft:ender_pearl" + }, + { + "type": "minecraft:item", + "weight": 3, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 3.0 + }, + "add": false + } + ], + "name": "minecraft:diamond" + }, + { + "type": "minecraft:item", + "weight": 10, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 5.0 + }, + "add": false + } + ], + "name": "minecraft:iron_ingot" + }, + { + "type": "minecraft:item", + "weight": 5, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 3.0 + }, + "add": false + } + ], + "name": "minecraft:gold_ingot" + }, + { + "type": "minecraft:item", + "weight": 5, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 4.0, + "max": 9.0 + }, + "add": false + } + ], + "name": "minecraft:redstone" + }, + { + "type": "minecraft:item", + "weight": 15, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 3.0 + }, + "add": false + } + ], + "name": "minecraft:bread" + }, + { + "type": "minecraft:item", + "weight": 15, + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "type": "minecraft:uniform", + "min": 1.0, + "max": 3.0 + }, + "add": false + } + ], + "name": "minecraft:apple" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_pickaxe" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_sword" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_chestplate" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_helmet" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_leggings" + }, + { + "type": "minecraft:item", + "weight": 5, + "name": "minecraft:iron_boots" + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_apple" + }, + { + "type": "minecraft:item", + "name": "minecraft:saddle" + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:diamond_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:music_disc_otherside" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": 30.0, + "treasure": true + } + ], + "name": "minecraft:book" + } + ] + } + ] +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_corridor.1_20.json b/loot/loot_tables/stronghold_corridor.1_20.json new file mode 100644 index 0000000..d9572b8 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor.1_20.json @@ -0,0 +1,196 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:ender_pearl", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:diamond", + "weight": 3 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:iron_ingot", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:gold_ingot", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 9.0, + "min": 4.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:redstone", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:bread", + "weight": 15 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:apple", + "weight": 15 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_pickaxe", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_sword", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_chestplate", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_helmet", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_leggings", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_boots", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_apple" + }, + { + "type": "minecraft:item", + "name": "minecraft:saddle" + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:diamond_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:music_disc_otherside" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": 30.0, + "treasure": true + } + ], + "name": "minecraft:book" + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 2.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:empty", + "weight": 9 + }, + { + "type": "minecraft:item", + "name": "minecraft:eye_armor_trim_smithing_template" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:chests/stronghold_corridor" +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_corridor.1_21_6.json b/loot/loot_tables/stronghold_corridor.1_21_6.json new file mode 100644 index 0000000..91c541b --- /dev/null +++ b/loot/loot_tables/stronghold_corridor.1_21_6.json @@ -0,0 +1,207 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:ender_pearl", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:diamond", + "weight": 3 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:iron_ingot", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:gold_ingot", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 9.0, + "min": 4.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:redstone", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:bread", + "weight": 15 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:apple", + "weight": 15 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_pickaxe", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_sword", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_chestplate", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_helmet", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_leggings", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_boots", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_apple" + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:leather" + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:diamond_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:music_disc_otherside" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": 30.0, + "options": "#minecraft:on_random_loot" + } + ], + "name": "minecraft:book" + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 2.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:empty", + "weight": 9 + }, + { + "type": "minecraft:item", + "name": "minecraft:eye_armor_trim_smithing_template" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:chests/stronghold_corridor" +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_corridor.1_21_9.json b/loot/loot_tables/stronghold_corridor.1_21_9.json new file mode 100644 index 0000000..4a5db69 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor.1_21_9.json @@ -0,0 +1,211 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:ender_pearl", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:diamond", + "weight": 3 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:iron_ingot", + "weight": 10 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:gold_ingot", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 9.0, + "min": 4.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:redstone", + "weight": 5 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:bread", + "weight": 15 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:apple", + "weight": 15 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_pickaxe", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_sword", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_chestplate", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_helmet", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_leggings", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_boots", + "weight": 5 + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_apple" + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:leather" + }, + { + "type": "minecraft:item", + "name": "minecraft:copper_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:iron_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:golden_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:diamond_horse_armor" + }, + { + "type": "minecraft:item", + "name": "minecraft:music_disc_otherside" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": 30.0, + "options": "#minecraft:on_random_loot" + } + ], + "name": "minecraft:book" + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 2.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:empty", + "weight": 9 + }, + { + "type": "minecraft:item", + "name": "minecraft:eye_armor_trim_smithing_template" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:chests/stronghold_corridor" +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_corridor_1_13.c b/loot/loot_tables/stronghold_corridor_1_13.c new file mode 100644 index 0000000..f1cc5ab --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_13.c @@ -0,0 +1,64 @@ +// this file is automatically generated, do not edit! +#include "stronghold_corridor_1_13.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[19] = {"minecraft:ender_pearl", "minecraft:diamond", "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:iron_sword", "minecraft:iron_chestplate", "minecraft:iron_helmet", "minecraft:iron_leggings", "minecraft:iron_boots", "minecraft:golden_apple", "minecraft:saddle", "minecraft:iron_horse_armor", "minecraft:golden_horse_armor", "minecraft:diamond_horse_armor", "minecraft:book"}; +static int global_item_ids[19] = {ITEM_ENDER_PEARL, ITEM_DIAMOND, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_IRON_SWORD, ITEM_IRON_CHESTPLATE, ITEM_IRON_HELMET, ITEM_IRON_LEGGINGS, ITEM_IRON_BOOTS, ITEM_GOLDEN_APPLE, ITEM_SADDLE, ITEM_IRON_HORSE_ARMOR, ITEM_GOLDEN_HORSE_ARMOR, ITEM_DIAMOND_HORSE_ARMOR, ITEM_BOOK}; + +static int precomputed_loot__0[99] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, 18}; +static int entry_to_item__0[19] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; +static int entry_functions_count__0[19] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_functions_index__0[19] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}; +static LootFunction loot_functions__0[7]; +static const LootPool stronghold_corridor_1_13__0 = { + .min_rolls = 2, + .max_rolls = 3, + .roll_count_function = roll_count_uniform, + .entry_count = 19, + .total_weight = 99, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; + +static LootPool loot_pools[1] = {stronghold_corridor_1_13__0}; +static LootTableContext context = { + .version = MC_1_13, + .item_count = 19, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 1, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[2]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[3]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_enchant_with_levels(&(loot_pool__0->loot_functions[6]), MC_1_13, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); +} + +LootTableContext* init_stronghold_corridor_1_13() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_corridor_1_13.h b/loot/loot_tables/stronghold_corridor_1_13.h new file mode 100644 index 0000000..a630c42 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_13.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CORRIDOR_1_13_H +#define STRONGHOLD_CORRIDOR_1_13_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_corridor_1_13(); + +#endif //STRONGHOLD_CORRIDOR_1_13_H diff --git a/loot/loot_tables/stronghold_corridor_1_18.c b/loot/loot_tables/stronghold_corridor_1_18.c new file mode 100644 index 0000000..2eb6ca3 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_18.c @@ -0,0 +1,64 @@ +// this file is automatically generated, do not edit! +#include "stronghold_corridor_1_18.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[20] = {"minecraft:ender_pearl", "minecraft:diamond", "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:iron_sword", "minecraft:iron_chestplate", "minecraft:iron_helmet", "minecraft:iron_leggings", "minecraft:iron_boots", "minecraft:golden_apple", "minecraft:saddle", "minecraft:iron_horse_armor", "minecraft:golden_horse_armor", "minecraft:diamond_horse_armor", "minecraft:music_disc_otherside", "minecraft:book"}; +static int global_item_ids[20] = {ITEM_ENDER_PEARL, ITEM_DIAMOND, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_IRON_SWORD, ITEM_IRON_CHESTPLATE, ITEM_IRON_HELMET, ITEM_IRON_LEGGINGS, ITEM_IRON_BOOTS, ITEM_GOLDEN_APPLE, ITEM_SADDLE, ITEM_IRON_HORSE_ARMOR, ITEM_GOLDEN_HORSE_ARMOR, ITEM_DIAMOND_HORSE_ARMOR, ITEM_MUSIC_DISC_OTHERSIDE, ITEM_BOOK}; + +static int precomputed_loot__0[100] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_to_item__0[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_functions_count__0[20] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_functions_index__0[20] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}; +static LootFunction loot_functions__0[7]; +static const LootPool stronghold_corridor_1_18__0 = { + .min_rolls = 2, + .max_rolls = 3, + .roll_count_function = roll_count_uniform, + .entry_count = 20, + .total_weight = 100, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; + +static LootPool loot_pools[1] = {stronghold_corridor_1_18__0}; +static LootTableContext context = { + .version = MC_1_18, + .item_count = 20, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 1, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[2]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[3]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_enchant_with_levels(&(loot_pool__0->loot_functions[6]), MC_1_18, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); +} + +LootTableContext* init_stronghold_corridor_1_18() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_corridor_1_18.h b/loot/loot_tables/stronghold_corridor_1_18.h new file mode 100644 index 0000000..6c896aa --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_18.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CORRIDOR_1_18_H +#define STRONGHOLD_CORRIDOR_1_18_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_corridor_1_18(); + +#endif //STRONGHOLD_CORRIDOR_1_18_H diff --git a/loot/loot_tables/stronghold_corridor_1_20.c b/loot/loot_tables/stronghold_corridor_1_20.c new file mode 100644 index 0000000..8780fb2 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_20.c @@ -0,0 +1,82 @@ +// this file is automatically generated, do not edit! +#include "stronghold_corridor_1_20.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[21] = {"minecraft:ender_pearl", "minecraft:diamond", "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:iron_sword", "minecraft:iron_chestplate", "minecraft:iron_helmet", "minecraft:iron_leggings", "minecraft:iron_boots", "minecraft:golden_apple", "minecraft:saddle", "minecraft:iron_horse_armor", "minecraft:golden_horse_armor", "minecraft:diamond_horse_armor", "minecraft:music_disc_otherside", "minecraft:book", "minecraft:eye_armor_trim_smithing_template"}; +static int global_item_ids[21] = {ITEM_ENDER_PEARL, ITEM_DIAMOND, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_IRON_SWORD, ITEM_IRON_CHESTPLATE, ITEM_IRON_HELMET, ITEM_IRON_LEGGINGS, ITEM_IRON_BOOTS, ITEM_GOLDEN_APPLE, ITEM_SADDLE, ITEM_IRON_HORSE_ARMOR, ITEM_GOLDEN_HORSE_ARMOR, ITEM_DIAMOND_HORSE_ARMOR, ITEM_MUSIC_DISC_OTHERSIDE, ITEM_BOOK, ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE}; + +static int precomputed_loot__0[100] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_to_item__0[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_functions_count__0[20] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_functions_index__0[20] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}; +static LootFunction loot_functions__0[7]; +static const LootPool stronghold_corridor_1_20__0 = { + .min_rolls = 2, + .max_rolls = 3, + .roll_count_function = roll_count_uniform, + .entry_count = 20, + .total_weight = 100, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; +static int precomputed_loot__1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_to_item__1[2] = {-1, 20}; +static int entry_functions_count__1[2] = {0, 0}; +static int entry_functions_index__1[2] = {0, 0}; +static LootFunction loot_functions__1[0]; +static const LootPool stronghold_corridor_1_20__1 = { + .min_rolls = 1, + .max_rolls = 1, + .roll_count_function = roll_count_constant, + .entry_count = 2, + .total_weight = 10, + .precomputed_loot = precomputed_loot__1, + .entry_to_item = entry_to_item__1, + .entry_functions_count = entry_functions_count__1, + .entry_functions_index = entry_functions_index__1, + .loot_functions = loot_functions__1, +}; + +static LootPool loot_pools[2] = {stronghold_corridor_1_20__0, stronghold_corridor_1_20__1}; +static LootTableContext context = { + .version = MC_1_20, + .item_count = 21, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 2, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[2]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[3]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_enchant_with_levels(&(loot_pool__0->loot_functions[6]), MC_1_20, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); + LootPool* loot_pool__1 = &(context.loot_pools[1]); +} + +LootTableContext* init_stronghold_corridor_1_20() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_corridor_1_20.h b/loot/loot_tables/stronghold_corridor_1_20.h new file mode 100644 index 0000000..8cdd8f7 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_20.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CORRIDOR_1_20_H +#define STRONGHOLD_CORRIDOR_1_20_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_corridor_1_20(); + +#endif //STRONGHOLD_CORRIDOR_1_20_H diff --git a/loot/loot_tables/stronghold_corridor_1_21_6.c b/loot/loot_tables/stronghold_corridor_1_21_6.c new file mode 100644 index 0000000..3cb7f1b --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_21_6.c @@ -0,0 +1,83 @@ +// this file is automatically generated, do not edit! +#include "stronghold_corridor_1_21_6.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[21] = {"minecraft:ender_pearl", "minecraft:diamond", "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:iron_sword", "minecraft:iron_chestplate", "minecraft:iron_helmet", "minecraft:iron_leggings", "minecraft:iron_boots", "minecraft:golden_apple", "minecraft:leather", "minecraft:iron_horse_armor", "minecraft:golden_horse_armor", "minecraft:diamond_horse_armor", "minecraft:music_disc_otherside", "minecraft:book", "minecraft:eye_armor_trim_smithing_template"}; +static int global_item_ids[21] = {ITEM_ENDER_PEARL, ITEM_DIAMOND, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_IRON_SWORD, ITEM_IRON_CHESTPLATE, ITEM_IRON_HELMET, ITEM_IRON_LEGGINGS, ITEM_IRON_BOOTS, ITEM_GOLDEN_APPLE, ITEM_LEATHER, ITEM_IRON_HORSE_ARMOR, ITEM_GOLDEN_HORSE_ARMOR, ITEM_DIAMOND_HORSE_ARMOR, ITEM_MUSIC_DISC_OTHERSIDE, ITEM_BOOK, ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE}; + +static int precomputed_loot__0[100] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_to_item__0[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +static int entry_functions_count__0[20] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; +static int entry_functions_index__0[20] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7}; +static LootFunction loot_functions__0[8]; +static const LootPool stronghold_corridor_1_21_6__0 = { + .min_rolls = 2, + .max_rolls = 3, + .roll_count_function = roll_count_uniform, + .entry_count = 20, + .total_weight = 100, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; +static int precomputed_loot__1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_to_item__1[2] = {-1, 20}; +static int entry_functions_count__1[2] = {0, 0}; +static int entry_functions_index__1[2] = {0, 0}; +static LootFunction loot_functions__1[0]; +static const LootPool stronghold_corridor_1_21_6__1 = { + .min_rolls = 1, + .max_rolls = 1, + .roll_count_function = roll_count_constant, + .entry_count = 2, + .total_weight = 10, + .precomputed_loot = precomputed_loot__1, + .entry_to_item = entry_to_item__1, + .entry_functions_count = entry_functions_count__1, + .entry_functions_index = entry_functions_index__1, + .loot_functions = loot_functions__1, +}; + +static LootPool loot_pools[2] = {stronghold_corridor_1_21_6__0, stronghold_corridor_1_21_6__1}; +static LootTableContext context = { + .version = MC_1_21_6, + .item_count = 21, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 2, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[2]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[3]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[6]), 1, 5); + create_enchant_with_levels_tag(&(loot_pool__0->loot_functions[7]), MC_1_21_6, "minecraft:book", get_item_type("minecraft:book"), 30, 30, "#minecraft:on_random_loot", 1); + LootPool* loot_pool__1 = &(context.loot_pools[1]); +} + +LootTableContext* init_stronghold_corridor_1_21_6() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_corridor_1_21_6.h b/loot/loot_tables/stronghold_corridor_1_21_6.h new file mode 100644 index 0000000..4c665e2 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_21_6.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CORRIDOR_1_21_6_H +#define STRONGHOLD_CORRIDOR_1_21_6_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_corridor_1_21_6(); + +#endif //STRONGHOLD_CORRIDOR_1_21_6_H diff --git a/loot/loot_tables/stronghold_corridor_1_21_9.c b/loot/loot_tables/stronghold_corridor_1_21_9.c new file mode 100644 index 0000000..7086f1d --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_21_9.c @@ -0,0 +1,83 @@ +// this file is automatically generated, do not edit! +#include "stronghold_corridor_1_21_9.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[22] = {"minecraft:ender_pearl", "minecraft:diamond", "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:iron_sword", "minecraft:iron_chestplate", "minecraft:iron_helmet", "minecraft:iron_leggings", "minecraft:iron_boots", "minecraft:golden_apple", "minecraft:leather", "minecraft:copper_horse_armor", "minecraft:iron_horse_armor", "minecraft:golden_horse_armor", "minecraft:diamond_horse_armor", "minecraft:music_disc_otherside", "minecraft:book", "minecraft:eye_armor_trim_smithing_template"}; +static int global_item_ids[22] = {ITEM_ENDER_PEARL, ITEM_DIAMOND, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_IRON_SWORD, ITEM_IRON_CHESTPLATE, ITEM_IRON_HELMET, ITEM_IRON_LEGGINGS, ITEM_IRON_BOOTS, ITEM_GOLDEN_APPLE, ITEM_LEATHER, ITEM_COPPER_HORSE_ARMOR, ITEM_IRON_HORSE_ARMOR, ITEM_GOLDEN_HORSE_ARMOR, ITEM_DIAMOND_HORSE_ARMOR, ITEM_MUSIC_DISC_OTHERSIDE, ITEM_BOOK, ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE}; + +static int precomputed_loot__0[101] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +static int entry_to_item__0[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +static int entry_functions_count__0[21] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}; +static int entry_functions_index__0[21] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7}; +static LootFunction loot_functions__0[8]; +static const LootPool stronghold_corridor_1_21_9__0 = { + .min_rolls = 2, + .max_rolls = 3, + .roll_count_function = roll_count_uniform, + .entry_count = 21, + .total_weight = 101, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; +static int precomputed_loot__1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static int entry_to_item__1[2] = {-1, 21}; +static int entry_functions_count__1[2] = {0, 0}; +static int entry_functions_index__1[2] = {0, 0}; +static LootFunction loot_functions__1[0]; +static const LootPool stronghold_corridor_1_21_9__1 = { + .min_rolls = 1, + .max_rolls = 1, + .roll_count_function = roll_count_constant, + .entry_count = 2, + .total_weight = 10, + .precomputed_loot = precomputed_loot__1, + .entry_to_item = entry_to_item__1, + .entry_functions_count = entry_functions_count__1, + .entry_functions_index = entry_functions_index__1, + .loot_functions = loot_functions__1, +}; + +static LootPool loot_pools[2] = {stronghold_corridor_1_21_9__0, stronghold_corridor_1_21_9__1}; +static LootTableContext context = { + .version = MC_1_21_9, + .item_count = 22, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 2, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[2]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[3]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[6]), 1, 5); + create_enchant_with_levels_tag(&(loot_pool__0->loot_functions[7]), MC_1_21_9, "minecraft:book", get_item_type("minecraft:book"), 30, 30, "#minecraft:on_random_loot", 1); + LootPool* loot_pool__1 = &(context.loot_pools[1]); +} + +LootTableContext* init_stronghold_corridor_1_21_9() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_corridor_1_21_9.h b/loot/loot_tables/stronghold_corridor_1_21_9.h new file mode 100644 index 0000000..d546af5 --- /dev/null +++ b/loot/loot_tables/stronghold_corridor_1_21_9.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CORRIDOR_1_21_9_H +#define STRONGHOLD_CORRIDOR_1_21_9_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_corridor_1_21_9(); + +#endif //STRONGHOLD_CORRIDOR_1_21_9_H diff --git a/loot/loot_tables/stronghold_crossing.1_13.json b/loot/loot_tables/stronghold_crossing.1_13.json new file mode 100644 index 0000000..3ae1faf --- /dev/null +++ b/loot/loot_tables/stronghold_crossing.1_13.json @@ -0,0 +1,113 @@ +{ + "pools": [ + { + "rolls": { + "min": 1, + "max": 4 + }, + "entries": [ + { + "type": "item", + "name": "minecraft:iron_ingot", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 5 + } + } + ], + "weight": 10 + }, + { + "type": "item", + "name": "minecraft:gold_ingot", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:redstone", + "functions": [ + { + "function": "set_count", + "count": { + "min": 4, + "max": 9 + } + } + ], + "weight": 5 + }, + { + "type": "item", + "name": "minecraft:coal", + "functions": [ + { + "function": "set_count", + "count": { + "min": 3, + "max": 8 + } + } + ], + "weight": 10 + }, + { + "type": "item", + "name": "minecraft:bread", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 15 + }, + { + "type": "item", + "name": "minecraft:apple", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 15 + }, + { + "type": "item", + "name": "minecraft:iron_pickaxe", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:book", + "weight": 1, + "functions": [ + { + "function": "enchant_with_levels", + "levels": 30, + "treasure": true + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_crossing_1_13.c b/loot/loot_tables/stronghold_crossing_1_13.c new file mode 100644 index 0000000..0de8694 --- /dev/null +++ b/loot/loot_tables/stronghold_crossing_1_13.c @@ -0,0 +1,64 @@ +// this file is automatically generated, do not edit! +#include "stronghold_crossing_1_13.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[8] = {"minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:redstone", "minecraft:coal", "minecraft:bread", "minecraft:apple", "minecraft:iron_pickaxe", "minecraft:book"}; +static int global_item_ids[8] = {ITEM_IRON_INGOT, ITEM_GOLD_INGOT, ITEM_REDSTONE, ITEM_COAL, ITEM_BREAD, ITEM_APPLE, ITEM_IRON_PICKAXE, ITEM_BOOK}; + +static int precomputed_loot__0[62] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7}; +static int entry_to_item__0[8] = {0, 1, 2, 3, 4, 5, 6, 7}; +static int entry_functions_count__0[8] = {1, 1, 1, 1, 1, 1, 0, 1}; +static int entry_functions_index__0[8] = {0, 1, 2, 3, 4, 5, 6, 6}; +static LootFunction loot_functions__0[7]; +static const LootPool stronghold_crossing_1_13__0 = { + .min_rolls = 1, + .max_rolls = 4, + .roll_count_function = roll_count_uniform, + .entry_count = 8, + .total_weight = 62, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; + +static LootPool loot_pools[1] = {stronghold_crossing_1_13__0}; +static LootTableContext context = { + .version = MC_1_13, + .item_count = 8, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 1, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 5); + create_set_count(&(loot_pool__0->loot_functions[1]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[2]), 4, 9); + create_set_count(&(loot_pool__0->loot_functions[3]), 3, 8); + create_set_count(&(loot_pool__0->loot_functions[4]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[5]), 1, 3); + create_enchant_with_levels(&(loot_pool__0->loot_functions[6]), MC_1_13, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); +} + +LootTableContext* init_stronghold_crossing_1_13() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_crossing_1_13.h b/loot/loot_tables/stronghold_crossing_1_13.h new file mode 100644 index 0000000..5b9afa2 --- /dev/null +++ b/loot/loot_tables/stronghold_crossing_1_13.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_CROSSING_1_13_H +#define STRONGHOLD_CROSSING_1_13_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_crossing_1_13(); + +#endif //STRONGHOLD_CROSSING_1_13_H diff --git a/loot/loot_tables/stronghold_library.1_13.json b/loot/loot_tables/stronghold_library.1_13.json new file mode 100644 index 0000000..1805bb6 --- /dev/null +++ b/loot/loot_tables/stronghold_library.1_13.json @@ -0,0 +1,62 @@ +{ + "pools": [ + { + "rolls": { + "min": 2, + "max": 10 + }, + "entries": [ + { + "type": "item", + "name": "minecraft:book", + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 3 + } + } + ], + "weight": 20 + }, + { + "type": "item", + "name": "minecraft:paper", + "functions": [ + { + "function": "set_count", + "count": { + "min": 2, + "max": 7 + } + } + ], + "weight": 20 + }, + { + "type": "item", + "name": "minecraft:map", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:compass", + "weight": 1 + }, + { + "type": "item", + "name": "minecraft:book", + "weight": 10, + "functions": [ + { + "function": "enchant_with_levels", + "levels": 30, + "treasure": true + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_library.1_20.json b/loot/loot_tables/stronghold_library.1_20.json new file mode 100644 index 0000000..6e7519f --- /dev/null +++ b/loot/loot_tables/stronghold_library.1_20.json @@ -0,0 +1,78 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:book", + "weight": 20 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 7.0, + "min": 2.0 + }, + "function": "minecraft:set_count" + } + ], + "name": "minecraft:paper", + "weight": 20 + }, + { + "type": "minecraft:item", + "name": "minecraft:map" + }, + { + "type": "minecraft:item", + "name": "minecraft:compass" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:enchant_with_levels", + "levels": 30.0, + "treasure": true + } + ], + "name": "minecraft:book", + "weight": 10 + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 10.0, + "min": 2.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:eye_armor_trim_smithing_template" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:chests/stronghold_library" +} \ No newline at end of file diff --git a/loot/loot_tables/stronghold_library_1_13.c b/loot/loot_tables/stronghold_library_1_13.c new file mode 100644 index 0000000..8d4f4cb --- /dev/null +++ b/loot/loot_tables/stronghold_library_1_13.c @@ -0,0 +1,60 @@ +// this file is automatically generated, do not edit! +#include "stronghold_library_1_13.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[5] = {"minecraft:book", "minecraft:paper", "minecraft:map", "minecraft:compass", "minecraft:book"}; +static int global_item_ids[5] = {ITEM_BOOK, ITEM_PAPER, ITEM_MAP, ITEM_COMPASS, ITEM_BOOK}; + +static int precomputed_loot__0[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; +static int entry_to_item__0[5] = {0, 1, 2, 3, 0}; +static int entry_functions_count__0[5] = {1, 1, 0, 0, 1}; +static int entry_functions_index__0[5] = {0, 1, 2, 2, 2}; +static LootFunction loot_functions__0[3]; +static const LootPool stronghold_library_1_13__0 = { + .min_rolls = 2, + .max_rolls = 10, + .roll_count_function = roll_count_uniform, + .entry_count = 5, + .total_weight = 52, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; + +static LootPool loot_pools[1] = {stronghold_library_1_13__0}; +static LootTableContext context = { + .version = MC_1_13, + .item_count = 5, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 1, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 2, 7); + create_enchant_with_levels(&(loot_pool__0->loot_functions[2]), MC_1_13, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); +} + +LootTableContext* init_stronghold_library_1_13() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_library_1_13.h b/loot/loot_tables/stronghold_library_1_13.h new file mode 100644 index 0000000..f106220 --- /dev/null +++ b/loot/loot_tables/stronghold_library_1_13.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_LIBRARY_1_13_H +#define STRONGHOLD_LIBRARY_1_13_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_library_1_13(); + +#endif //STRONGHOLD_LIBRARY_1_13_H diff --git a/loot/loot_tables/stronghold_library_1_20.c b/loot/loot_tables/stronghold_library_1_20.c new file mode 100644 index 0000000..b342513 --- /dev/null +++ b/loot/loot_tables/stronghold_library_1_20.c @@ -0,0 +1,78 @@ +// this file is automatically generated, do not edit! +#include "stronghold_library_1_20.h" + +#include "../../biomes.h" + +#include "../items.h" +#include "../loot_table_context.h" +#include "../loot_table_parser.h" + +static int initialised = 0; + +static char* item_names[6] = {"minecraft:book", "minecraft:paper", "minecraft:map", "minecraft:compass", "minecraft:book", "minecraft:eye_armor_trim_smithing_template"}; +static int global_item_ids[6] = {ITEM_BOOK, ITEM_PAPER, ITEM_MAP, ITEM_COMPASS, ITEM_BOOK, ITEM_EYE_ARMOR_TRIM_SMITHING_TEMPLATE}; + +static int precomputed_loot__0[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; +static int entry_to_item__0[5] = {0, 1, 2, 3, 0}; +static int entry_functions_count__0[5] = {1, 1, 0, 0, 1}; +static int entry_functions_index__0[5] = {0, 1, 2, 2, 2}; +static LootFunction loot_functions__0[3]; +static const LootPool stronghold_library_1_20__0 = { + .min_rolls = 2, + .max_rolls = 10, + .roll_count_function = roll_count_uniform, + .entry_count = 5, + .total_weight = 52, + .precomputed_loot = precomputed_loot__0, + .entry_to_item = entry_to_item__0, + .entry_functions_count = entry_functions_count__0, + .entry_functions_index = entry_functions_index__0, + .loot_functions = loot_functions__0, +}; +static int precomputed_loot__1[1] = {0}; +static int entry_to_item__1[1] = {5}; +static int entry_functions_count__1[1] = {0}; +static int entry_functions_index__1[1] = {0}; +static LootFunction loot_functions__1[0]; +static const LootPool stronghold_library_1_20__1 = { + .min_rolls = 1, + .max_rolls = 1, + .roll_count_function = roll_count_constant, + .entry_count = 1, + .total_weight = 1, + .precomputed_loot = precomputed_loot__1, + .entry_to_item = entry_to_item__1, + .entry_functions_count = entry_functions_count__1, + .entry_functions_index = entry_functions_index__1, + .loot_functions = loot_functions__1, +}; + +static LootPool loot_pools[2] = {stronghold_library_1_20__0, stronghold_library_1_20__1}; +static LootTableContext context = { + .version = MC_1_20, + .item_count = 6, + .item_names = item_names, + .global_item_ids = global_item_ids, + .unresolved_subtable_count = 0, + .subtable_count = 0, + .subtable_pool_offset = NULL, + .subtable_pool_count = NULL, + .pool_count = 2, + .loot_pools = loot_pools, +}; + +static void create_loot_functions() { + LootPool* loot_pool__0 = &(context.loot_pools[0]); + create_set_count(&(loot_pool__0->loot_functions[0]), 1, 3); + create_set_count(&(loot_pool__0->loot_functions[1]), 2, 7); + create_enchant_with_levels(&(loot_pool__0->loot_functions[2]), MC_1_20, "minecraft:book", get_item_type("minecraft:book"), 30, 30, 1); + LootPool* loot_pool__1 = &(context.loot_pools[1]); +} + +LootTableContext* init_stronghold_library_1_20() { + if (!initialised) { + create_loot_functions(); + initialised = 1; + } + return &context; +} diff --git a/loot/loot_tables/stronghold_library_1_20.h b/loot/loot_tables/stronghold_library_1_20.h new file mode 100644 index 0000000..d1bad12 --- /dev/null +++ b/loot/loot_tables/stronghold_library_1_20.h @@ -0,0 +1,9 @@ +// this file is automatically generated, do not edit! +#ifndef STRONGHOLD_LIBRARY_1_20_H +#define STRONGHOLD_LIBRARY_1_20_H + +#include "../loot_table_context.h" + +LootTableContext* init_stronghold_library_1_20(); + +#endif //STRONGHOLD_LIBRARY_1_20_H diff --git a/makefile b/makefile deleted file mode 100644 index 6c34d05..0000000 --- a/makefile +++ /dev/null @@ -1,232 +0,0 @@ -#CC = gcc -#AR = ar -ARFLAGS = cr -override LDFLAGS = -lm -override CFLAGS += -Wall -Wextra -fwrapv - -ifeq ($(OS),Windows_NT) - override CFLAGS += -D_WIN32 - CC = gcc - RM = del -else - override LDFLAGS += -pthread - #RM = rm -endif - -.PHONY : all debug release native libcubiomes clean - -all: release - -debug: CFLAGS += -DDEBUG -O0 -ggdb3 -debug: libcubiomes -release: CFLAGS += -O3 -release: libcubiomes -native: CFLAGS += -O3 -march=native -ffast-math -native: libcubiomes - -ifneq ($(OS),Windows_NT) -release: CFLAGS += -fPIC -#debug: CFLAGS += -fsanitize=undefined -endif - - -libcubiomes: noise.o terrainnoise.o biomes.o layers.o biomenoise.o generator.o finders.o util.o quadbase.o items.o loot_functions.o loot_table_context.o loot_table_parser.o loot_tables.o cjson.o bastion_bridge_1_16_1.o bastion_bridge_1_16_5.o bastion_bridge_1_20.o bastion_other_1_16_1.o bastion_other_1_16_5.o bastion_other_1_20.o bastion_other_1_21_1.o bastion_other_1_21_9.o buried_treasure_1_13.o buried_treasure_1_18.o buried_treasure_1_21_11.o desert_pyramid_1_13.o desert_pyramid_1_20.o desert_pyramid_1_21_6.o desert_pyramid_1_21_9.o desert_pyramid_1_21_11.o end_city_treasure_1_13.o end_city_treasure_1_20.o end_city_treasure_1_21_9.o end_city_treasure_1_21_11.o igloo_chest_1_13.o jungle_temple_1_13.o jungle_temple_1_14.o jungle_temple_1_20.o jungle_temple_1_21_6.o jungle_temple_1_21_9.o jungle_temple_1_21_11.o jungle_temple_dispenser_1_13.o nether_bridge_1_13.o nether_bridge_1_20.o nether_bridge_1_21_9.o pillager_outpost_1_14.o pillager_outpost_1_19_2.o pillager_outpost_1_20.o pillager_outpost_1_21_11.o ruined_portal_1_16_1.o ruined_portal_1_21_5.o shipwreck_map_1_13.o shipwreck_map_1_18.o shipwreck_map_1_20.o shipwreck_map_1_21_11.o shipwreck_supply_1_13.o shipwreck_supply_1_14.o shipwreck_supply_1_17.o shipwreck_supply_1_20.o shipwreck_supply_1_21_11.o shipwreck_treasure_1_13.o shipwreck_treasure_1_20.o shipwreck_treasure_1_21_11.o - $(AR) $(ARFLAGS) libcubiomes.a $^ - -finders.o: finders.c finders.h - $(CC) -c $(CFLAGS) $< - -generator.o: generator.c generator.h - $(CC) -c $(CFLAGS) $< - -biomenoise.o: biomenoise.c - $(CC) -c $(CFLAGS) $< - -biometree.o: biometree.c - $(CC) -c $(CFLAGS) $< - -layers.o: layers.c layers.h - $(CC) -c $(CFLAGS) $< - -biomes.o: biomes.c biomes.h - $(CC) -c $(CFLAGS) $< - -noise.o: noise.c noise.h - $(CC) -c $(CFLAGS) $< - -terrainnoise.o: terrainnoise.c terrainnoise.h - $(CC) -c $(CFLAGS) $< - -util.o: util.c util.h - $(CC) -c $(CFLAGS) $< - -quadbase.o: quadbase.c quadbase.h - $(CC) -c $(CFLAGS) $< - -items.o: loot/items.c loot/items.h - $(CC) -c $(CFLAGS) $< - -loot_functions.o: loot/loot_functions.c loot/loot_functions.h - $(CC) -c $(CFLAGS) $< - -loot_table_context.o: loot/loot_table_context.c loot/loot_table_context.h - $(CC) -c $(CFLAGS) $< - -loot_table_parser.o: loot/loot_table_parser.c - $(CC) -c $(CFLAGS) $< - -loot_tables.o: loot/loot_tables.c loot/loot_tables.h - $(CC) -c $(CFLAGS) $< - -bastion_bridge_1_16_1.o: loot/loot_tables/bastion_bridge_1_16_1.c loot/loot_tables/bastion_bridge_1_16_1.h - $(CC) -c $(CFLAGS) $< - -bastion_bridge_1_16_5.o: loot/loot_tables/bastion_bridge_1_16_5.c loot/loot_tables/bastion_bridge_1_16_5.h - $(CC) -c $(CFLAGS) $< - -bastion_bridge_1_20.o: loot/loot_tables/bastion_bridge_1_20.c loot/loot_tables/bastion_bridge_1_20.h - $(CC) -c $(CFLAGS) $< - -bastion_other_1_16_1.o: loot/loot_tables/bastion_other_1_16_1.c loot/loot_tables/bastion_other_1_16_1.h - $(CC) -c $(CFLAGS) $< - -bastion_other_1_16_5.o: loot/loot_tables/bastion_other_1_16_5.c loot/loot_tables/bastion_other_1_16_5.h - $(CC) -c $(CFLAGS) $< - -bastion_other_1_20.o: loot/loot_tables/bastion_other_1_20.c loot/loot_tables/bastion_other_1_20.h - $(CC) -c $(CFLAGS) $< - -bastion_other_1_21_1.o: loot/loot_tables/bastion_other_1_21_1.c loot/loot_tables/bastion_other_1_21_1.h - $(CC) -c $(CFLAGS) $< - -bastion_other_1_21_9.o: loot/loot_tables/bastion_other_1_21_9.c loot/loot_tables/bastion_other_1_21_9.h - $(CC) -c $(CFLAGS) $< - -buried_treasure_1_13.o: loot/loot_tables/buried_treasure_1_13.c loot/loot_tables/buried_treasure_1_13.h - $(CC) -c $(CFLAGS) $< - -buried_treasure_1_18.o: loot/loot_tables/buried_treasure_1_18.c loot/loot_tables/buried_treasure_1_18.h - $(CC) -c $(CFLAGS) $< - -buried_treasure_1_21_11.o: loot/loot_tables/buried_treasure_1_21_11.c loot/loot_tables/buried_treasure_1_21_11.h - $(CC) -c $(CFLAGS) $< - -desert_pyramid_1_13.o: loot/loot_tables/desert_pyramid_1_13.c loot/loot_tables/desert_pyramid_1_13.h - $(CC) -c $(CFLAGS) $< - -desert_pyramid_1_20.o: loot/loot_tables/desert_pyramid_1_20.c loot/loot_tables/desert_pyramid_1_20.h - $(CC) -c $(CFLAGS) $< - -desert_pyramid_1_21_6.o: loot/loot_tables/desert_pyramid_1_21_6.c loot/loot_tables/desert_pyramid_1_21_6.h - $(CC) -c $(CFLAGS) $< - -desert_pyramid_1_21_9.o: loot/loot_tables/desert_pyramid_1_21_9.c loot/loot_tables/desert_pyramid_1_21_9.h - $(CC) -c $(CFLAGS) $< - -desert_pyramid_1_21_11.o: loot/loot_tables/desert_pyramid_1_21_11.c loot/loot_tables/desert_pyramid_1_21_11.h - $(CC) -c $(CFLAGS) $< - -end_city_treasure_1_13.o: loot/loot_tables/end_city_treasure_1_13.c loot/loot_tables/end_city_treasure_1_13.h - $(CC) -c $(CFLAGS) $< - -end_city_treasure_1_20.o: loot/loot_tables/end_city_treasure_1_20.c loot/loot_tables/end_city_treasure_1_20.h - $(CC) -c $(CFLAGS) $< - -end_city_treasure_1_21_9.o: loot/loot_tables/end_city_treasure_1_21_9.c loot/loot_tables/end_city_treasure_1_21_9.h - $(CC) -c $(CFLAGS) $< - -end_city_treasure_1_21_11.o: loot/loot_tables/end_city_treasure_1_21_11.c loot/loot_tables/end_city_treasure_1_21_11.h - $(CC) -c $(CFLAGS) $< - -igloo_chest_1_13.o: loot/loot_tables/igloo_chest_1_13.c loot/loot_tables/igloo_chest_1_13.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_13.o: loot/loot_tables/jungle_temple_1_13.c loot/loot_tables/jungle_temple_1_13.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_14.o: loot/loot_tables/jungle_temple_1_14.c loot/loot_tables/jungle_temple_1_14.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_20.o: loot/loot_tables/jungle_temple_1_20.c loot/loot_tables/jungle_temple_1_20.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_21_6.o: loot/loot_tables/jungle_temple_1_21_6.c loot/loot_tables/jungle_temple_1_21_6.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_21_9.o: loot/loot_tables/jungle_temple_1_21_9.c loot/loot_tables/jungle_temple_1_21_9.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_1_21_11.o: loot/loot_tables/jungle_temple_1_21_11.c loot/loot_tables/jungle_temple_1_21_11.h - $(CC) -c $(CFLAGS) $< - -jungle_temple_dispenser_1_13.o: loot/loot_tables/jungle_temple_dispenser_1_13.c loot/loot_tables/jungle_temple_dispenser_1_13.h - $(CC) -c $(CFLAGS) $< - -nether_bridge_1_13.o: loot/loot_tables/nether_bridge_1_13.c loot/loot_tables/nether_bridge_1_13.h - $(CC) -c $(CFLAGS) $< - -nether_bridge_1_20.o: loot/loot_tables/nether_bridge_1_20.c loot/loot_tables/nether_bridge_1_20.h - $(CC) -c $(CFLAGS) $< - -nether_bridge_1_21_9.o: loot/loot_tables/nether_bridge_1_21_9.c loot/loot_tables/nether_bridge_1_21_9.h - $(CC) -c $(CFLAGS) $< - -pillager_outpost_1_14.o: loot/loot_tables/pillager_outpost_1_14.c loot/loot_tables/pillager_outpost_1_14.h - $(CC) -c $(CFLAGS) $< - -pillager_outpost_1_19_2.o: loot/loot_tables/pillager_outpost_1_19_2.c loot/loot_tables/pillager_outpost_1_19_2.h - $(CC) -c $(CFLAGS) $< - -pillager_outpost_1_20.o: loot/loot_tables/pillager_outpost_1_20.c loot/loot_tables/pillager_outpost_1_20.h - $(CC) -c $(CFLAGS) $< - -pillager_outpost_1_21_11.o: loot/loot_tables/pillager_outpost_1_21_11.c loot/loot_tables/pillager_outpost_1_21_11.h - $(CC) -c $(CFLAGS) $< - -ruined_portal_1_16_1.o: loot/loot_tables/ruined_portal_1_16_1.c loot/loot_tables/ruined_portal_1_16_1.h - $(CC) -c $(CFLAGS) $< - -ruined_portal_1_21_5.o: loot/loot_tables/ruined_portal_1_21_5.c loot/loot_tables/ruined_portal_1_21_5.h - $(CC) -c $(CFLAGS) $< - -shipwreck_map_1_13.o: loot/loot_tables/shipwreck_map_1_13.c loot/loot_tables/shipwreck_map_1_13.h - $(CC) -c $(CFLAGS) $< - -shipwreck_map_1_18.o: loot/loot_tables/shipwreck_map_1_18.c loot/loot_tables/shipwreck_map_1_18.h - $(CC) -c $(CFLAGS) $< - -shipwreck_map_1_20.o: loot/loot_tables/shipwreck_map_1_20.c loot/loot_tables/shipwreck_map_1_20.h - $(CC) -c $(CFLAGS) $< - -shipwreck_map_1_21_11.o: loot/loot_tables/shipwreck_map_1_21_11.c loot/loot_tables/shipwreck_map_1_21_11.h - $(CC) -c $(CFLAGS) $< - -shipwreck_supply_1_13.o: loot/loot_tables/shipwreck_supply_1_13.c loot/loot_tables/shipwreck_supply_1_13.h - $(CC) -c $(CFLAGS) $< - -shipwreck_supply_1_14.o: loot/loot_tables/shipwreck_supply_1_14.c loot/loot_tables/shipwreck_supply_1_14.h - $(CC) -c $(CFLAGS) $< - -shipwreck_supply_1_17.o: loot/loot_tables/shipwreck_supply_1_17.c loot/loot_tables/shipwreck_supply_1_17.h - $(CC) -c $(CFLAGS) $< - -shipwreck_supply_1_20.o: loot/loot_tables/shipwreck_supply_1_20.c loot/loot_tables/shipwreck_supply_1_20.h - $(CC) -c $(CFLAGS) $< - -shipwreck_supply_1_21_11.o: loot/loot_tables/shipwreck_supply_1_21_11.c loot/loot_tables/shipwreck_supply_1_21_11.h - $(CC) -c $(CFLAGS) $< - -shipwreck_treasure_1_13.o: loot/loot_tables/shipwreck_treasure_1_13.c loot/loot_tables/shipwreck_treasure_1_13.h - $(CC) -c $(CFLAGS) $< - -shipwreck_treasure_1_20.o: loot/loot_tables/shipwreck_treasure_1_20.c loot/loot_tables/shipwreck_treasure_1_20.h - $(CC) -c $(CFLAGS) $< - -shipwreck_treasure_1_21_11.o: loot/loot_tables/shipwreck_treasure_1_21_11.c loot/loot_tables/shipwreck_treasure_1_21_11.h - $(CC) -c $(CFLAGS) $< - -cjson.o: loot/cjson/cJSON.c loot/cjson/cJSON.h - $(CC) -c $(CFLAGS) $< -o $@ - -clean: - $(RM) *.o *.a diff --git a/terrainnoise.c b/terrainnoise.c index 492737b..b2a0ce5 100644 --- a/terrainnoise.c +++ b/terrainnoise.c @@ -514,7 +514,7 @@ int generateColumn(int x, int z, int blocks[384], const double ds00[48 + 1], con void generateRegion(TerrainNoise *params, int chunkX, int chunkZ, int chunkW, int chunkH, int (*blocks)[384], int* ys, int flag) { const int cellWidth = 1 << 2; - const int blocksH = chunkH << 4; + const int blockH = chunkH << 4; const int chunkCellsW = (chunkW << 2) + 1; const int chunkCellsH = (chunkH << 2) + 1; @@ -560,7 +560,7 @@ void generateRegion(TerrainNoise *params, int chunkX, int chunkZ, int chunkW, in const int x = minX + relX; for (int relZ = 0; relZ < cellWidth; ++relZ) { const int z = minZ + relZ; - idx = (relBlockX + relX) * blocksH + (relBlockZ + relZ); + idx = (relBlockX + relX) * blockH + (relBlockZ + relZ); int y = generateColumn(x, z, blocks[idx], ds00, ds01, ds10, ds11, flag); if (ys) { ys[idx] = y; diff --git a/terrainnoise.h b/terrainnoise.h index d22c7bd..fac0b78 100644 --- a/terrainnoise.h +++ b/terrainnoise.h @@ -257,7 +257,7 @@ int generateColumn(int x, int z, int blocks[384], const double ds00[48 + 1], con /** * Generate a region of terrain using memoisation to prevent recalculating noise columns. * One can use int (*blocks)[384] = malloc(blockW * blockH * sizeof(*blocks)); to allocate the - * array. Similarly, the blocks can then be accessed using blocks[relX * blocksH + relZ][y]. + * array. Similarly, the blocks can then be accessed using blocks[relX * blockH + relZ][y]. * Here blockH = chunkH << 4, relX ranges over [0, chunkW << 4), relZ ranges over [0, chunkH << 4) * and y ranges over [0, 384). Similarly (if flag is true), ys are written to like relX * blockH + * relZ.