Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
implementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ org.gradle.parallel=true
org.gradle.configuration-cache=false
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=26.2
loader_version=0.19.3
loom_version=1.16-SNAPSHOT
minecraft_version=26.3
loader_version=0.19.5
loom_version=1.18-SNAPSHOT
fabric_kotlin_version=1.13.12+kotlin.2.4.0
# Mod Properties
mod_version=1.0.0
maven_group=com.steelextractor
archives_base_name=steel-extractor
# Dependencies
fabric_version=0.152.0+26.2
fabric_api_version=0.161.0+26.3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/com/steelextractor/mixin/AxeItemAccessor.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.steelextractor.BiomeCacheReset;
import net.minecraft.world.level.biome.BiomeResolver;
import net.minecraft.world.level.biome.Climate;
import net.minecraft.world.level.biome.MultiNoiseBiomeSource;
import net.minecraft.world.level.chunk.ChunkAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -18,9 +16,7 @@ public abstract class ChunkAccessBiomeCacheMixin {
* its R-tree warm-start within the chunk, but not across chunk boundaries.
*/
@Inject(method = "fillBiomesFromNoise", at = @At("HEAD"))
private void resetBiomeCacheForChunk(BiomeResolver biomeResolver, Climate.Sampler sampler, CallbackInfo ci) {
if (biomeResolver instanceof MultiNoiseBiomeSource) {
BiomeCacheReset.markNeeded();
}
private void resetBiomeCacheForChunk(BiomeResolver biomeResolver, CallbackInfo ci) {
BiomeCacheReset.markNeeded();
}
}
4 changes: 1 addition & 3 deletions src/main/java/com/steelextractor/mixin/ChunkStepMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
public class ChunkStepMixin {

private static final Set<ChunkStatus> IMMEDIATE_HASH_STAGES = Set.of(
ChunkStatus.NOISE,
ChunkStatus.SURFACE,
ChunkStatus.CARVERS
ChunkStatus.TERRAIN
);

@Shadow
Expand Down
105 changes: 64 additions & 41 deletions src/main/kotlin/com/steelextractor/SteelExtractor.kt

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions src/main/kotlin/com/steelextractor/extractors/BiomeHashes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.Level
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator
import net.minecraft.world.level.levelgen.RandomState
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext
import org.slf4j.LoggerFactory
import java.security.MessageDigest

Expand Down Expand Up @@ -69,13 +70,13 @@ class BiomeHashes : SteelExtractor.Extractor {
val noiseRegistry = server.registryAccess().lookupOrThrow(Registries.NOISE)

val randomState = if (chunkGenerator is NoiseBasedChunkGenerator) {
RandomState.create(chunkGenerator.generatorSettings().value(), noiseRegistry, SEED)
RandomState.create(noiseRegistry, SEED, chunkGenerator.generatorSettings().value())
} else {
logger.warn("Chunk generator for $name is not NoiseBasedChunkGenerator, using level's RandomState")
level.chunkSource.randomState()
}

val climateSampler = randomState.sampler()
val climateSampler = randomState.createClimateSampler(SamplerContext.EMPTY_UNCACHED)

val hashesArray = JsonArray()

Expand Down Expand Up @@ -110,6 +111,16 @@ class BiomeHashes : SteelExtractor.Extractor {
minSectionY: Int,
maxSectionY: Int
): String {
val biomeResolver = biomeSource.createResolverForChunk(
climateSampler,
chunkX * 4,
minSectionY * 4,
chunkZ * 4,
4,
(maxSectionY - minSectionY + 1) * 4,
4
)

// Step 1: Sample biomes in generation order (X outer, Y middle, Z inner)
// to match vanilla/Steel world generation cache behavior.
val biomes = HashMap<BiomeKey, String>()
Expand All @@ -122,7 +133,7 @@ class BiomeHashes : SteelExtractor.Extractor {
val quartY = sectionY * 4 + y
val quartZ = chunkZ * 4 + z

val biome = biomeSource.getNoiseBiome(quartX, quartY, quartZ, climateSampler)
val biome = biomeResolver.getNoiseBiome(quartX, quartY, quartZ)
val biomeName = biome.unwrapKey()
.map { it.identifier().toString() }
.orElse("unknown")
Expand Down
24 changes: 15 additions & 9 deletions src/main/kotlin/com/steelextractor/extractors/BlockEntities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.google.gson.JsonObject
import com.steelextractor.SteelExtractor
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.server.MinecraftServer
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.entity.BlockEntityType

class BlockEntities : SteelExtractor.Extractor {
override fun fileName(): String {
Expand All @@ -14,22 +16,26 @@ class BlockEntities : SteelExtractor.Extractor {

override fun extract(server: MinecraftServer): JsonElement {
val topLevelJson = JsonObject()
val validBlocksField = BlockEntityType::class.java.getDeclaredField("validBlocks")
validBlocksField.isAccessible = true

val blockEntitiesJson = JsonArray()
for (blockEntity in BuiltInRegistries.BLOCK_ENTITY_TYPE) {
val blockEntityJson = JsonObject()
blockEntityJson.addProperty(
"name",
BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(blockEntity)!!.path,
)
val key = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(blockEntity)
?: error("Block entity type has no key: $blockEntity")
blockEntityJson.addProperty("id", BuiltInRegistries.BLOCK_ENTITY_TYPE.getId(blockEntity))
blockEntityJson.addProperty("name", key.path)

@Suppress("UNCHECKED_CAST")
val validBlocks = validBlocksField.get(blockEntity) as Set<Block>
val validBlocksJson = JsonArray()
for (block in BuiltInRegistries.BLOCK) {
if (blockEntity.isValid(block.defaultBlockState())) {
validBlocksJson.add(BuiltInRegistries.BLOCK.getKey(block).path)
}
}
validBlocks
.map { BuiltInRegistries.BLOCK.getKey(it)!!.path }
.sorted()
.forEach { validBlocksJson.add(it) }
blockEntityJson.add("valid_blocks", validBlocksJson)

blockEntitiesJson.add(blockEntityJson)
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/steelextractor/extractors/Blocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.properties.NoteBlockInstrument
import net.minecraft.world.level.block.state.properties.Property
import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.material.PushReaction
import net.minecraft.world.level.material.FlowingFluid
import net.minecraft.world.level.storage.loot.LootTable
import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.shapes.CollisionContext
Expand Down Expand Up @@ -418,7 +419,7 @@ class Blocks : SteelExtractor.Extractor {
return StateFluidProperties(
BuiltInRegistries.FLUID.getKey(fluidState.type).path,
fluidState.amount,
fluidState.getOptionalValue(BlockStateProperties.FALLING).orElse(false),
fluidState.hasProperty(FlowingFluid.FALLING) && fluidState.getValue(FlowingFluid.FALLING),
)
}

Expand Down Expand Up @@ -600,6 +601,7 @@ class Blocks : SteelExtractor.Extractor {
behaviourJson.addProperty("friction", getPrivateFieldValue<Float>(behaviourProps, "friction"))
behaviourJson.addProperty("speedFactor", getPrivateFieldValue<Float>(behaviourProps, "speedFactor"))
behaviourJson.addProperty("jumpFactor", getPrivateFieldValue<Float>(behaviourProps, "jumpFactor"))
behaviourJson.addProperty("bounceRestitution", getPrivateFieldValue<Float>(behaviourProps, "bounceRestitution"))
behaviourJson.addProperty("dynamicShape", getPrivateFieldValue<Boolean>(behaviourProps, "dynamicShape"))
behaviourJson.addProperty("offsetType", getOffsetType(block).name)
behaviourJson.addProperty("maxHorizontalOffset", getProtectedFloatMethodValue(block, "getMaxHorizontalOffset"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class MapDecorationTypeRegistryExtractor : SteelExtractor.Extractor {
return extractBuiltInRegistry(BuiltInRegistries.MAP_DECORATION_TYPE) { type: MapDecorationType, json ->
json.addProperty("asset_id", type.assetId().toString())
json.addProperty("show_on_item_frame", type.showOnItemFrame())
json.addProperty("map_color", type.mapColor())
json.addProperty("exploration_map_element", type.explorationMapElement())
json.addProperty("track_count", type.trackCount())
}
}
Expand Down Expand Up @@ -168,4 +166,4 @@ class StatTypeRegistryExtractor : SteelExtractor.Extractor {
override fun extract(server: MinecraftServer): JsonElement {
return extractBuiltInRegistry(BuiltInRegistries.STAT_TYPE) { _: StatType<*>, _ -> }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ChunkStageHashes : SteelExtractor.Extractor {
json.addProperty("num_chunks", SteelExtractor.NUM_SAMPLE_CHUNKS)
json.addProperty("chunk_generation_order", "x_z_ascending")
json.addProperty("feature_hash_capture", "after_all_tracked_features_ready")
json.addProperty("biome_tie_breaker", "vanilla_rtree_chunk_local_cache")
json.addProperty("hashset_iteration_order", "insertion_order")
json.addProperty("biome_tie_breaker", "vanilla_thread_local_rtree")
json.addProperty("hashset_iteration_order", "vanilla")
json.addProperty("light_hash_capture", "after_all_tracked_light_ready_pending_tasks_drained_and_light_engine_idle")
json.addProperty("light_dependency_radius", SteelExtractor.LIGHT_DEPENDENCY_RADIUS)
json.addProperty("light_feature_dependency_capture", "after_tracked_features_before_light_x_z_ascending")
Expand Down
30 changes: 9 additions & 21 deletions src/main/kotlin/com/steelextractor/extractors/DataComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,21 @@ import com.steelextractor.SteelExtractor
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.server.MinecraftServer

/** Extracts the numeric Vanilla data-component registry used by item patches. */
class DataComponents : SteelExtractor.Extractor {
override fun fileName(): String {
return "steel-registry/build_assets/data_components.json"
}
override fun fileName(): String = "steel-registry/build_assets/data_components.json"

override fun extract(server: MinecraftServer): JsonElement {
val components = JsonArray()

for (component in BuiltInRegistries.DATA_COMPONENT_TYPE) {
val key = BuiltInRegistries.DATA_COMPONENT_TYPE.getKey(component)
?: error("Built-in data component type has no key: $component")
val componentJson = JsonObject()
componentJson.addProperty(
"id",
BuiltInRegistries.DATA_COMPONENT_TYPE.getId(component)
)
componentJson.addProperty("key", key.toString())
componentJson.addProperty("persistent", !component.isTransient)
componentJson.addProperty(
"ignore_swap_animation",
component.ignoreSwapAnimation()
)
components.add(componentJson)
val value = JsonObject()
value.addProperty("id", BuiltInRegistries.DATA_COMPONENT_TYPE.getId(component))
value.addProperty("key", BuiltInRegistries.DATA_COMPONENT_TYPE.getKey(component).toString())
value.addProperty("persistent", !component.isTransient())
value.addProperty("ignore_swap_animation", component.ignoreSwapAnimation())
components.add(value)
}

val output = JsonObject()
output.add("components", components)
return output
return JsonObject().apply { add("components", components) }
}
}
Loading
Loading