Skip to content
Open
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
22 changes: 17 additions & 5 deletions src/main/kotlin/com/steelextractor/extractors/Blocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import net.minecraft.resources.RegistryOps
import net.minecraft.server.MinecraftServer
import net.minecraft.world.level.EmptyBlockGetter
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.FireBlock
import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.properties.BlockStateProperties
Expand Down Expand Up @@ -556,7 +557,9 @@ class Blocks : SteelExtractor.Extractor {

val blocksJson = JsonArray()


val fireBlock = net.minecraft.world.level.block.Blocks.FIRE as FireBlock
val igniteOddsMethod = fireBlock.javaClass.getDeclaredMethod("getIgniteOdds", BlockState::class.java).apply { isAccessible = true }
val burnOddsMethod = fireBlock.javaClass.getDeclaredMethod("getBurnOdds", BlockState::class.java).apply { isAccessible = true }
for (block in BuiltInRegistries.BLOCK) {
val blockJson = JsonObject()
blockJson.addProperty("id", BuiltInRegistries.BLOCK.getId(block))
Expand All @@ -575,6 +578,7 @@ class Blocks : SteelExtractor.Extractor {
"explosionResistance",
getPrivateFieldValue<Float>(behaviourProps, "explosionResistance")
)

behaviourJson.addProperty(
"isRandomlyTicking",
getPrivateFieldValue<Boolean>(behaviourProps, "isRandomlyTicking")
Expand Down Expand Up @@ -606,10 +610,7 @@ class Blocks : SteelExtractor.Extractor {
behaviourJson.addProperty("maxVerticalOffset", getProtectedFloatMethodValue(block, "getMaxVerticalOffset"))

behaviourJson.addProperty("destroyTime", getPrivateFieldValue<Float>(behaviourProps, "destroyTime"))
behaviourJson.addProperty(
"explosionResistance",
getPrivateFieldValue<Float>(behaviourProps, "explosionResistance")
)
Comment thread
stuffpicklesays marked this conversation as resolved.

behaviourJson.addProperty("ignitedByLava", getPrivateFieldValue<Boolean>(behaviourProps, "ignitedByLava"))

behaviourJson.addProperty("liquid", getPrivateFieldValue<Boolean>(behaviourProps, "liquid"))
Expand Down Expand Up @@ -660,6 +661,17 @@ class Blocks : SteelExtractor.Extractor {
},
)


val defaultState = block.defaultBlockState()

val spreadChance = igniteOddsMethod.invoke(fireBlock, defaultState) as Int
val burnChance = burnOddsMethod.invoke(fireBlock, defaultState) as Int
val flammabilityJson = JsonObject().apply {
addProperty("spread_chance", spreadChance)
addProperty("burn_chance", burnChance)
}
blockJson.add("flammability", flammabilityJson)

// Only add if there are actual differences
if (behaviourJson.size() > 0) {
blockJson.add("behavior_properties", behaviourJson)
Expand Down