mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-08 22:57:31 -04:00
strip down block and item generator more
Improves performance and reduces file size
This commit is contained in:
parent
302f495999
commit
4fcbd7675d
@ -7,10 +7,8 @@ import de.bixilon.pixlyzer.generator.generators.VoxelShapeGenerator.serialize
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getClass
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.getGetter
|
||||
import de.bixilon.pixlyzer.util.ReflectionUtil.variable
|
||||
import de.bixilon.pixlyzer.util.RegistryUtil
|
||||
import de.bixilon.pixlyzer.util.Util.compound
|
||||
import de.bixilon.pixlyzer.util.Util.of
|
||||
import de.bixilon.pixlyzer.util.Util.realName
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
@ -18,7 +16,6 @@ import net.minecraft.block.Blocks
|
||||
import net.minecraft.block.FluidBlock
|
||||
import net.minecraft.client.color.block.BlockColors
|
||||
import net.minecraft.fluid.Fluid
|
||||
import net.minecraft.particle.ParticleEffect
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
@ -71,7 +68,10 @@ object BlockGenerator : Generator(
|
||||
blockData["has_dynamic_shape"] = block.hasDynamicBounds()
|
||||
}
|
||||
|
||||
blockData["class"] = block::class.java.realName
|
||||
val className = block::class.java.realName
|
||||
if (className != "Block") {
|
||||
blockData["class"] = className
|
||||
}
|
||||
blockData["sound_group"] = SoundGroupGenerator.getId(block.soundGroup)
|
||||
|
||||
if (block is FluidBlock) {
|
||||
@ -88,17 +88,6 @@ object BlockGenerator : Generator(
|
||||
|
||||
block.putOffsetType(blockData)
|
||||
|
||||
if (block::class.java.of("CampfireBlock")) {
|
||||
block.variable<Boolean>("emitsParticles")?.let {
|
||||
blockData["lava_particles"] = it
|
||||
}
|
||||
}
|
||||
if (block::class.java.of("TorchBlock")) {
|
||||
block.variable<ParticleEffect>("particle")?.type?.let {
|
||||
blockData["flame_particle"] = ParticleGenerator.REGISTRY.getRawId(it)
|
||||
}
|
||||
}
|
||||
|
||||
val hasColorProperties = (TINT_PROPERTIES_METHOD?.invoke(DEFAULT_BLOCK_COLORS, block) as Set<*>?)?.size?.let { it > 0 } ?: let {
|
||||
val blockColorProviderList = BLOCK_COLORS_PROVIDERS_ID_LIST!!.get(DEFAULT_BLOCK_COLORS)
|
||||
ID_LIST_GET_METHOD.invoke(blockColorProviderList, BlockGenerator.REGISTRY.getRawId(block)) != null
|
||||
@ -149,14 +138,16 @@ object BlockGenerator : Generator(
|
||||
stateData["luminance"] = state.luminance
|
||||
}
|
||||
if (state.hasRandomTicks()) {
|
||||
stateData["is_randomly_ticking"] = state.hasRandomTicks()
|
||||
stateData["is_randomly_ticking"] = true
|
||||
}
|
||||
if (state.hasSidedTransparency()) {
|
||||
stateData["has_side_transparency"] = state.hasSidedTransparency()
|
||||
stateData["has_side_transparency"] = true
|
||||
}
|
||||
|
||||
REQUIRES_CORRECT_TOOL_FOR_DROP_FIELDS?.let {
|
||||
stateData["requires_tool"] = it.getBoolean(state)
|
||||
if (it.getBoolean(state)) {
|
||||
stateData["requires_tool"] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,13 +33,25 @@ object ItemGenerator : Generator(
|
||||
val resourceLocation = REGISTRY.getId(item)
|
||||
val itemData = compound()
|
||||
itemData["id"] = REGISTRY.getRawId(item)
|
||||
itemData["rarity"] = item.getRarity(ItemStack.EMPTY).ordinal
|
||||
itemData["max_stack_size"] = item.maxCount
|
||||
itemData["max_damage"] = item.maxDamage
|
||||
IS_FIRE_RESISTANT_FIELD?.let {
|
||||
itemData["is_fire_resistant"] = it.getBoolean(item)
|
||||
item.getRarity(ItemStack.EMPTY).ordinal.let {
|
||||
if (it != 0) {
|
||||
itemData["rarity"] = it
|
||||
}
|
||||
}
|
||||
if (item.maxCount != 64) {
|
||||
itemData["max_stack_size"] = item.maxCount
|
||||
}
|
||||
if (item.maxDamage > 0) {
|
||||
itemData["max_damage"] = item.maxDamage
|
||||
}
|
||||
IS_FIRE_RESISTANT_FIELD?.let {
|
||||
if (it.getBoolean(item)) {
|
||||
itemData["is_fire_resistant"] = true
|
||||
}
|
||||
}
|
||||
if (!item.isNetworkSynced) {
|
||||
itemData["is_complex"] = item.isNetworkSynced
|
||||
}
|
||||
itemData["is_complex"] = item.isNetworkSynced
|
||||
item.getTranslationKey()?.let {
|
||||
itemData["translation_key"] = it
|
||||
}
|
||||
@ -219,8 +231,10 @@ object ItemGenerator : Generator(
|
||||
}
|
||||
|
||||
|
||||
itemData["class"] = item::class.java.realName
|
||||
|
||||
val className = item::class.java.realName
|
||||
if (className != "Item") {
|
||||
itemData["class"] = className
|
||||
}
|
||||
|
||||
data[resourceLocation.toString()] = itemData
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user