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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ processResources {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
vendor = JvmVendorSpec.ADOPTIUM
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
86 changes: 53 additions & 33 deletions src/main/kotlin/com/steelextractor/SteelExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ import java.nio.file.Path
import java.nio.file.Paths
import java.util.concurrent.CompletableFuture
import kotlin.random.Random
import kotlin.system.exitProcess
import kotlin.system.measureTimeMillis

object SteelExtractor : ModInitializer {
private val logger = LoggerFactory.getLogger("steel-extractor")

/** Set to false to skip chunk generation and chunk stage hash extraction. */
private const val ENABLE_CHUNK_EXTRACTION = true
private val ENABLE_CHUNK_EXTRACTION = envFlag("STEEL_EXTRACTOR_ENABLE_CHUNK_EXTRACTION")

/** Set to false to skip storing per-chunk block data in memory and writing binary dump files. */
private const val ENABLE_BINARY_DUMP = true
private val ENABLE_BINARY_DUMP = envFlag("STEEL_EXTRACTOR_ENABLE_BINARY_DUMP")

/** Sampling parameters: place random CLUSTER_SIZE x CLUSTER_SIZE clusters within a SAMPLE_HALF_RANGE*2 x SAMPLE_HALF_RANGE*2 area. */
const val CHUNK_SAMPLE_SEED: Long = 123456
Expand Down Expand Up @@ -195,37 +196,47 @@ object SteelExtractor : ModInitializer {
val test2 = BuiltInRegistries.FLUID.byId(2)
logger.info(test2.toString())

val immediateExtractors = arrayOf(
Blocks(),
BlockEntities(),
Items(),
ParticleTypeRegistryExtractor(),
VillagerTypeRegistryExtractor(),
VillagerProfessionRegistryExtractor(),
Packets(),
MenuTypes(),
Entities(),
EntityEvents(),
Fluids(),
GameRulesExtractor(),
Classes(),
Attributes(),
MobEffects(),
Potions(),
SoundTypes(),
SoundEvents(),
MultiNoiseBiomeParameters(),
BiomeHashes(),
LevelEvents(),
Tags(),
StructureStarts(),
Strippables(),
Weathering(),
CandleCakes(),
Waxables(),
PoiTypesExtractor(),
GameEvents(),
)
// Build immediate extractors list conditionally. To disable a particular extractor,
// set the environment variable STEEL_EXTRACTOR_DISABLE_<NAME>=1 (or true/yes).
// Example: STEEL_EXTRACTOR_DISABLE_BLOCKS=1
val immediateExtractors = mutableListOf<Extractor>()
fun addUnlessDisabled(name: String, supplier: () -> Extractor) {
if (envFlag("STEEL_EXTRACTOR_DISABLE_$name")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does by default it return true ? to have all feature enable by default (and personally also like have the possibility to enable it with cli with arg)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if the env var doesn't exist it will add it to the list so assuming you don't do anything, they all get used. And CLI is a bit trickier and might be harder with CI. Also get's annoying if you want to disable a majority of the extractors.

logger.info("Extractor $name disabled via STEEL_EXTRACTOR_DISABLE_$name")
} else {
immediateExtractors.add(supplier())
}
}

addUnlessDisabled("BLOCKS") { Blocks() }
addUnlessDisabled("BLOCK_ENTITIES") { BlockEntities() }
addUnlessDisabled("ITEMS") { Items() }
addUnlessDisabled("PARTICLE_TYPES") { ParticleTypeRegistryExtractor() }
addUnlessDisabled("VILLAGER_TYPES") { VillagerTypeRegistryExtractor() }
addUnlessDisabled("VILLAGER_PROFESSIONS") { VillagerProfessionRegistryExtractor() }
addUnlessDisabled("PACKETS") { Packets() }
addUnlessDisabled("MENU_TYPES") { MenuTypes() }
addUnlessDisabled("ENTITIES") { Entities() }
addUnlessDisabled("ENTITY_EVENTS") { EntityEvents() }
addUnlessDisabled("FLUIDS") { Fluids() }
addUnlessDisabled("GAME_RULES") { GameRulesExtractor() }
addUnlessDisabled("CLASSES") { Classes() }
addUnlessDisabled("ATTRIBUTES") { Attributes() }
addUnlessDisabled("MOB_EFFECTS") { MobEffects() }
addUnlessDisabled("POTIONS") { Potions() }
addUnlessDisabled("SOUND_TYPES") { SoundTypes() }
addUnlessDisabled("SOUND_EVENTS") { SoundEvents() }
addUnlessDisabled("MULTI_NOISE_BIOME_PARAMETERS") { MultiNoiseBiomeParameters() }
addUnlessDisabled("BIOME_HASHES") { BiomeHashes() }
addUnlessDisabled("LEVEL_EVENTS") { LevelEvents() }
addUnlessDisabled("TAGS") { Tags() }
addUnlessDisabled("STRUCTURE_STARTS") { StructureStarts() }
addUnlessDisabled("STRIPPABLES") { Strippables() }
addUnlessDisabled("WEATHERING") { Weathering() }
addUnlessDisabled("CANDLE_CAKES") { CandleCakes() }
addUnlessDisabled("WAXABLES") { Waxables() }
addUnlessDisabled("POI_TYPES") { PoiTypesExtractor() }
addUnlessDisabled("GAME_EVENTS") { GameEvents() }


val chunkStageExtractor = ChunkStageHashes()
Expand Down Expand Up @@ -302,6 +313,11 @@ object SteelExtractor : ModInitializer {

if (!ENABLE_CHUNK_EXTRACTION) {
logger.info("All extractors complete! (chunk extraction skipped)")
if (envFlag("STEEL_EXTRACTOR_EXIT_ON_COMPLETE")) {
logger.info("Exiting because STEEL_EXTRACTOR_EXIT_ON_COMPLETE is enabled")
ServerLifecycleEvents.SERVER_STOPPING.invoker().onServerStopping(server);
server.halt(false); // false means to do a graceful shutdown
}
}
})

Expand Down Expand Up @@ -568,6 +584,10 @@ object SteelExtractor : ModInitializer {
}
}
logger.info("All extractors complete!")
if (envFlag("STEEL_EXTRACTOR_EXIT_ON_COMPLETE")) {
logger.info("Exiting because STEEL_EXTRACTOR_EXIT_ON_COMPLETE is enabled")
exitProcess(0);
}
}
}
}
Expand Down
Loading