Second commit
This commit is contained in:
parent
d064b83831
commit
ca7e6c2d79
18 changed files with 799 additions and 682 deletions
|
|
@ -13,7 +13,7 @@ cimport _cubiomes as cb
|
|||
|
||||
from libc.stdlib cimport malloc, free
|
||||
from libc.string cimport memcpy
|
||||
from libc.stdint cimport uint64_t, uint32_t, int16_t, uint8_t
|
||||
from libc.stdint cimport uint64_t, int64_t, uint32_t, int16_t, uint8_t
|
||||
from cpython.array cimport array, clone
|
||||
import array as _array_module
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ cdef class Generator:
|
|||
|
||||
# ── core methods ──────────────────────────────────────────────────────────
|
||||
|
||||
def apply_seed(self, int dim, uint64_t seed):
|
||||
def apply_seed(self, int dim, long long seed):
|
||||
"""Bind a world seed and dimension to the generator.
|
||||
|
||||
Must be called before any biome generation.
|
||||
|
|
@ -100,7 +100,7 @@ cdef class Generator:
|
|||
* ``DIM_END = +1``
|
||||
seed (int): 64-bit world seed.
|
||||
"""
|
||||
cb.applySeed(self._g, dim, seed)
|
||||
cb.applySeed(self._g, dim, <uint64_t>seed)
|
||||
|
||||
def get_biome_at(self, int x, int y, int z, int scale=4) -> int:
|
||||
"""Get the biome ID at a single position.
|
||||
|
|
@ -274,7 +274,7 @@ cdef class Generator:
|
|||
return result
|
||||
|
||||
def check_for_biomes(self, int x, int z, int sx, int sz,
|
||||
int scale, int dim, uint64_t seed,
|
||||
int scale, int dim, long long seed,
|
||||
BiomeFilter biome_filter,
|
||||
int y=0, int sy=1):
|
||||
"""Test whether a region satisfies a biome filter.
|
||||
|
|
@ -304,7 +304,7 @@ cdef class Generator:
|
|||
r.y = y
|
||||
r.sy = sy
|
||||
return cb.checkForBiomes(
|
||||
self._g, NULL, r, dim, seed, &biome_filter._bf, NULL)
|
||||
self._g, NULL, r, dim, <uint64_t>seed, &biome_filter._bf, NULL)
|
||||
|
||||
|
||||
# ─── BiomeFilter ─────────────────────────────────────────────────────────────
|
||||
|
|
@ -384,9 +384,9 @@ cdef class StrongholdIterator:
|
|||
cdef bint _has_current
|
||||
cdef bint _has_more
|
||||
|
||||
def __cinit__(self, Generator gen, uint64_t seed48):
|
||||
def __cinit__(self, Generator gen, long long seed48):
|
||||
self._gen = gen
|
||||
cb.initFirstStronghold(&self._sh, gen.mc, seed48)
|
||||
cb.initFirstStronghold(&self._sh, gen.mc, <uint64_t>seed48)
|
||||
cdef int remaining = cb.nextStronghold(
|
||||
&self._sh, gen._g if gen is not None else NULL)
|
||||
self._has_current = True
|
||||
|
|
@ -512,7 +512,7 @@ def get_structure_config(int struct_type, int mc):
|
|||
}
|
||||
|
||||
|
||||
def get_structure_pos(int struct_type, int mc, uint64_t seed,
|
||||
def get_structure_pos(int struct_type, int mc, long long seed,
|
||||
int reg_x, int reg_z):
|
||||
"""Find the block position of a structure attempt in a region.
|
||||
|
||||
|
|
@ -532,7 +532,7 @@ def get_structure_pos(int struct_type, int mc, uint64_t seed,
|
|||
if no valid attempt exists in this region.
|
||||
"""
|
||||
cdef cb.Pos pos
|
||||
if not cb.getStructurePos(struct_type, mc, seed, reg_x, reg_z, &pos):
|
||||
if not cb.getStructurePos(struct_type, mc, <uint64_t>seed, reg_x, reg_z, &pos):
|
||||
return None
|
||||
return (pos.x, pos.z)
|
||||
|
||||
|
|
@ -573,7 +573,7 @@ def is_viable_feature_biome(int mc, int struct_type, int biome_id) -> bool:
|
|||
return bool(cb.isViableFeatureBiome(mc, struct_type, biome_id))
|
||||
|
||||
|
||||
def get_variant(int struct_type, int mc, uint64_t seed,
|
||||
def get_variant(int struct_type, int mc, long long seed,
|
||||
int block_x, int block_z, int biome_id=-1):
|
||||
"""Retrieve variant information (rotation, size, flags) for a structure.
|
||||
|
||||
|
|
@ -590,13 +590,13 @@ def get_variant(int struct_type, int mc, uint64_t seed,
|
|||
StructureVariant | None
|
||||
"""
|
||||
cdef StructureVariant sv = StructureVariant.__new__(StructureVariant)
|
||||
if not cb.getVariant(&sv._sv, struct_type, mc, seed,
|
||||
if not cb.getVariant(&sv._sv, struct_type, mc, <uint64_t>seed,
|
||||
block_x, block_z, biome_id):
|
||||
return None
|
||||
return sv
|
||||
|
||||
|
||||
def iter_strongholds(Generator gen, uint64_t seed48):
|
||||
def iter_strongholds(Generator gen, long long seed48):
|
||||
"""Return an iterator that yields stronghold positions in order.
|
||||
|
||||
Each value is an accurate ``(x, z)`` block coordinate pair obtained
|
||||
|
|
@ -620,7 +620,7 @@ def iter_strongholds(Generator gen, uint64_t seed48):
|
|||
return StrongholdIterator(gen, seed48)
|
||||
|
||||
|
||||
def init_first_stronghold(int mc, uint64_t seed48):
|
||||
def init_first_stronghold(int mc, long long seed48):
|
||||
"""Return the approximate position of the first stronghold (no biome check).
|
||||
|
||||
This is faster than :func:`iter_strongholds` but accurate only to ±112
|
||||
|
|
@ -634,11 +634,11 @@ def init_first_stronghold(int mc, uint64_t seed48):
|
|||
tuple[int, int]: Approximate ``(x, z)`` block coordinates.
|
||||
"""
|
||||
cdef cb.StrongholdIter sh
|
||||
cdef cb.Pos pos = cb.initFirstStronghold(&sh, mc, seed48)
|
||||
cdef cb.Pos pos = cb.initFirstStronghold(&sh, mc, <uint64_t>seed48)
|
||||
return (pos.x, pos.z)
|
||||
|
||||
|
||||
def get_mineshafts(int mc, uint64_t seed,
|
||||
def get_mineshafts(int mc, long long seed,
|
||||
int chunk_x, int chunk_z,
|
||||
int chunk_w, int chunk_h,
|
||||
int max_count=1024):
|
||||
|
|
@ -658,7 +658,7 @@ def get_mineshafts(int mc, uint64_t seed,
|
|||
if out is NULL:
|
||||
raise MemoryError()
|
||||
cdef int n = cb.getMineshafts(
|
||||
mc, seed, chunk_x, chunk_z, chunk_w, chunk_h, out, max_count)
|
||||
mc, <uint64_t>seed, chunk_x, chunk_z, chunk_w, chunk_h, out, max_count)
|
||||
result = [(out[i].x, out[i].z) for i in range(n)]
|
||||
free(out)
|
||||
return result
|
||||
|
|
@ -686,7 +686,7 @@ def setup_biome_filter(int mc,
|
|||
return BiomeFilter(mc, required, excluded, match_any, flags)
|
||||
|
||||
|
||||
def is_slime_chunk(uint64_t seed, int chunk_x, int chunk_z) -> bool:
|
||||
def is_slime_chunk(long long seed, int chunk_x, int chunk_z) -> bool:
|
||||
"""Return True if the given chunk spawns slimes at any light level.
|
||||
|
||||
Args:
|
||||
|
|
@ -696,10 +696,10 @@ def is_slime_chunk(uint64_t seed, int chunk_x, int chunk_z) -> bool:
|
|||
Returns:
|
||||
bool
|
||||
"""
|
||||
return bool(cb.isSlimeChunk(seed, chunk_x, chunk_z))
|
||||
return bool(cb.isSlimeChunk(<uint64_t>seed, chunk_x, chunk_z))
|
||||
|
||||
|
||||
def get_shadow(uint64_t seed) -> int:
|
||||
def get_shadow(long long seed) -> int:
|
||||
"""Compute the shadow seed for a given world seed.
|
||||
|
||||
The shadow seed produces mirrored structure positions.
|
||||
|
|
@ -710,10 +710,10 @@ def get_shadow(uint64_t seed) -> int:
|
|||
Returns:
|
||||
int: Shadow seed.
|
||||
"""
|
||||
return cb.getShadow(seed)
|
||||
return cb.getShadow(<uint64_t>seed)
|
||||
|
||||
|
||||
def move_structure(uint64_t base_seed, int reg_x, int reg_z) -> int:
|
||||
def move_structure(long long base_seed, int reg_x, int reg_z) -> int:
|
||||
"""Translate a base seed so that structures shift by ``(reg_x, reg_z)`` regions.
|
||||
|
||||
Useful for finding quad-witch-hut or quad-monument base seeds.
|
||||
|
|
@ -725,10 +725,10 @@ def move_structure(uint64_t base_seed, int reg_x, int reg_z) -> int:
|
|||
Returns:
|
||||
int: Translated seed (lower 48 bits).
|
||||
"""
|
||||
return cb.moveStructure(base_seed, reg_x, reg_z)
|
||||
return cb.moveStructure(<uint64_t>base_seed, reg_x, reg_z)
|
||||
|
||||
|
||||
def chunk_generate_rnd(uint64_t world_seed,
|
||||
def chunk_generate_rnd(long long world_seed,
|
||||
int chunk_x, int chunk_z) -> int:
|
||||
"""Compute the chunk-generation random seed used for caves/structures.
|
||||
|
||||
|
|
@ -739,10 +739,10 @@ def chunk_generate_rnd(uint64_t world_seed,
|
|||
Returns:
|
||||
int: 64-bit random seed.
|
||||
"""
|
||||
return cb.chunkGenerateRnd(world_seed, chunk_x, chunk_z)
|
||||
return cb.chunkGenerateRnd(<uint64_t>world_seed, chunk_x, chunk_z)
|
||||
|
||||
|
||||
def get_population_seed(int mc, uint64_t world_seed,
|
||||
def get_population_seed(int mc, long long world_seed,
|
||||
int x, int z) -> int:
|
||||
"""Return the population seed for a given chunk (block) position.
|
||||
|
||||
|
|
@ -754,7 +754,7 @@ def get_population_seed(int mc, uint64_t world_seed,
|
|||
Returns:
|
||||
int: 64-bit population seed.
|
||||
"""
|
||||
return cb.getPopulationSeed(mc, world_seed, x, z)
|
||||
return cb.getPopulationSeed(mc, <uint64_t>world_seed, x, z)
|
||||
|
||||
|
||||
# ─── Biome property helpers ───────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue