mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-27 05:59:53 -04:00
port for 21w14a down to 1.15
This commit is contained in:
parent
547e3331c5
commit
02e842a370
4
pom.xml
4
pom.xml
@ -15,7 +15,9 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.code.style>official</kotlin.code.style>
|
<kotlin.code.style>official</kotlin.code.style>
|
||||||
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||||
<minecraft.version>21w13a</minecraft.version>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<minecraft.version>21w14a</minecraft.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -7,9 +7,8 @@ import de.bixilon.pixlyzer.util.ReflectionUtil.setFinalField
|
|||||||
import net.minecraft.client.network.OtherClientPlayerEntity
|
import net.minecraft.client.network.OtherClientPlayerEntity
|
||||||
import net.minecraft.entity.Entity
|
import net.minecraft.entity.Entity
|
||||||
import net.minecraft.entity.EntityType
|
import net.minecraft.entity.EntityType
|
||||||
import net.minecraft.entity.EyeOfEnderEntity
|
import net.minecraft.entity.boss.WitherEntity
|
||||||
import net.minecraft.entity.decoration.ItemFrameEntity
|
import net.minecraft.entity.decoration.ItemFrameEntity
|
||||||
import net.minecraft.entity.projectile.thrown.*
|
|
||||||
import net.minecraft.scoreboard.Scoreboard
|
import net.minecraft.scoreboard.Scoreboard
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
import net.minecraft.world.border.WorldBorder
|
import net.minecraft.world.border.WorldBorder
|
||||||
@ -19,6 +18,12 @@ import java.util.*
|
|||||||
|
|
||||||
|
|
||||||
object EntitySpawner {
|
object EntitySpawner {
|
||||||
|
private val EGG_ENTITY_CLASS = getClass("net.minecraft.entity.thrown.ThrownEggEntity", "net.minecraft.entity.projectile.thrown.EggEntity")!!
|
||||||
|
private val SNOWBAL_ENTITY_CLASS = getClass("net.minecraft.entity.thrown.SnowballEntity", "net.minecraft.entity.projectile.thrown.SnowballEntity")!!
|
||||||
|
private val ENDER_PEARL_ENTITY_CLASS = getClass("net.minecraft.entity.thrown.ThrownEnderpearlEntity", "net.minecraft.entity.projectile.thrown.EnderPearlEntity")!!
|
||||||
|
private val EYE_OF_ENDER_ENTITY_CLASS = getClass("net.minecraft.entity.EnderEyeEntity", "net.minecraft.entity.EyeOfEnderEntity", "net.minecraft.entity.projectile.thrown.EyeOfEnderEntity")!!
|
||||||
|
private val EXPERIENCE_BOTTLE_ENTITY_CLASS = getClass("net.minecraft.entity.thrown.ThrownExperienceBottleEntity", "net.minecraft.entity.projectile.thrown.ExperienceBottleEntity")!!
|
||||||
|
private val POTION_ENTITY_ENTITY_CLASS = getClass("net.minecraft.entity.thrown.ThrownPotionEntity", "net.minecraft.entity.projectile.thrown.PotionEntity")!!
|
||||||
|
|
||||||
fun summonEntity(entityType: EntityType<*>): Entity {
|
fun summonEntity(entityType: EntityType<*>): Entity {
|
||||||
when (entityType) {
|
when (entityType) {
|
||||||
@ -28,6 +33,7 @@ object EntitySpawner {
|
|||||||
EntityType.ITEM_FRAME -> return OBJENSIS.newInstance(ItemFrameEntity::class.java) as Entity
|
EntityType.ITEM_FRAME -> return OBJENSIS.newInstance(ItemFrameEntity::class.java) as Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val entity = try {
|
val entity = try {
|
||||||
ENTITY_CREATE_METHOD?.invoke(FACTORY_FIELD.get(entityType), entityType, CLIENT_LEVEL) as Entity?
|
ENTITY_CREATE_METHOD?.invoke(FACTORY_FIELD.get(entityType), entityType, CLIENT_LEVEL) as Entity?
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
@ -42,12 +48,13 @@ object EntitySpawner {
|
|||||||
|
|
||||||
// ToDo: This crashes in 21w13a?
|
// ToDo: This crashes in 21w13a?
|
||||||
when (entityType) {
|
when (entityType) {
|
||||||
EntityType.EGG -> return OBJENSIS.newInstance(EggEntity::class.java) as Entity
|
EntityType.EGG -> return OBJENSIS.newInstance(EGG_ENTITY_CLASS) as Entity
|
||||||
EntityType.SNOWBALL -> return OBJENSIS.newInstance(SnowballEntity::class.java) as Entity
|
EntityType.SNOWBALL -> return OBJENSIS.newInstance(SNOWBAL_ENTITY_CLASS) as Entity
|
||||||
EntityType.ENDER_PEARL -> return OBJENSIS.newInstance(EnderPearlEntity::class.java) as Entity
|
EntityType.ENDER_PEARL -> return OBJENSIS.newInstance(ENDER_PEARL_ENTITY_CLASS) as Entity
|
||||||
EntityType.EYE_OF_ENDER -> return OBJENSIS.newInstance(EyeOfEnderEntity::class.java) as Entity
|
EntityType.EYE_OF_ENDER -> return OBJENSIS.newInstance(EYE_OF_ENDER_ENTITY_CLASS) as Entity
|
||||||
EntityType.EXPERIENCE_BOTTLE -> return OBJENSIS.newInstance(ExperienceBottleEntity::class.java) as Entity
|
EntityType.EXPERIENCE_BOTTLE -> return OBJENSIS.newInstance(EXPERIENCE_BOTTLE_ENTITY_CLASS) as Entity
|
||||||
EntityType.POTION -> return OBJENSIS.newInstance(PotionEntity::class.java) as Entity
|
EntityType.POTION -> return OBJENSIS.newInstance(POTION_ENTITY_ENTITY_CLASS) as Entity
|
||||||
|
EntityType.WITHER -> return OBJENSIS.newInstance(WitherEntity::class.java) as Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
TODO("Entity type: $entityType")
|
TODO("Entity type: $entityType")
|
||||||
@ -55,7 +62,7 @@ object EntitySpawner {
|
|||||||
|
|
||||||
|
|
||||||
private val LIGHTNING_BOLT_CLASS = getClass("net.minecraft.entity.LightningEntity")!!
|
private val LIGHTNING_BOLT_CLASS = getClass("net.minecraft.entity.LightningEntity")!!
|
||||||
private val FISHING_HOOK_CLASS = getClass("net.minecraft.entity.projectile.FishingBobberEntity")!!
|
private val FISHING_HOOK_CLASS = getClass("net.minecraft.entity.FishingBobberEntity", "net.minecraft.entity.projectile.FishingBobberEntity")!!
|
||||||
|
|
||||||
private val levelClass = getClass("net.minecraft.client.world.ClientWorld")
|
private val levelClass = getClass("net.minecraft.client.world.ClientWorld")
|
||||||
|
|
||||||
|
@ -3,8 +3,11 @@ package de.bixilon.pixlyzer
|
|||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.pixlyzer.generator.Generators
|
import de.bixilon.pixlyzer.generator.Generators
|
||||||
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getClass
|
||||||
import de.bixilon.pixlyzer.util.Util
|
import de.bixilon.pixlyzer.util.Util
|
||||||
|
import net.minecraft.Bootstrap
|
||||||
import net.minecraft.MinecraftVersion
|
import net.minecraft.MinecraftVersion
|
||||||
|
import net.minecraft.SharedConstants
|
||||||
import net.minecraft.util.registry.Registry
|
import net.minecraft.util.registry.Registry
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
@ -57,9 +60,14 @@ object PixLyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println("Loading classes...")
|
println("Loading classes...")
|
||||||
val classesLoadStartTime = System.currentTimeMillis()
|
val classesLoadStartTime = System.currentTimeMillis()
|
||||||
|
|
||||||
|
initializeGameVersionMethod?.invoke(null)
|
||||||
|
|
||||||
|
Bootstrap.initialize()
|
||||||
|
|
||||||
Util.forceClassInit(Registry::class.java)
|
Util.forceClassInit(Registry::class.java)
|
||||||
|
|
||||||
println("Class loading done in ${System.currentTimeMillis() - classesLoadStartTime}ms")
|
println("Class loading done in ${System.currentTimeMillis() - classesLoadStartTime}ms")
|
||||||
@ -157,4 +165,10 @@ object PixLyzer {
|
|||||||
minFileWriter.close()
|
minFileWriter.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val initializeGameVersionMethod = try {
|
||||||
|
getClass(SharedConstants::class.java.simpleName)?.getDeclaredMethod("method_36208")
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,17 +63,31 @@ object BiomeGenerator : Generator(
|
|||||||
(BACKGROUND_MUSIC_SPECIAL_EFFECTS_FIELD?.get(it) as Optional<Any>?)?.ifPresent {
|
(BACKGROUND_MUSIC_SPECIAL_EFFECTS_FIELD?.get(it) as Optional<Any>?)?.ifPresent {
|
||||||
biomeData.addProperty("background_music", Registry.SOUND_EVENT.getRawId(MUSIC_CLASS_EVENT_FIELD!!.get(it) as SoundEvent))
|
biomeData.addProperty("background_music", Registry.SOUND_EVENT.getRawId(MUSIC_CLASS_EVENT_FIELD!!.get(it) as SoundEvent))
|
||||||
}
|
}
|
||||||
} ?: let {
|
}
|
||||||
|
|
||||||
|
if (!biomeData.has("foliage_color_override")) {
|
||||||
// calculate color overrider
|
// calculate color overrider
|
||||||
try {
|
try {
|
||||||
biomeData.addProperty("foliage_color_override", FOLIAGE_COLOR_OVERRIDE_METHOD!!.invoke(biome) as Int)
|
biomeData.addProperty("foliage_color_override", FOLIAGE_COLOR_AT_METHOD_METHOD!!.invoke(biome, null) as Int)
|
||||||
} catch (exception: NullPointerException) {
|
} catch (exception: NullPointerException) {
|
||||||
|
try {
|
||||||
|
biomeData.addProperty("foliage_color_override", FOLIAGE_COLOR_METHOD!!.invoke(biome) as Int)
|
||||||
|
} catch (exception: NullPointerException) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
biomeData["foliage_color_override"]?.let {
|
||||||
|
if (it.asInt == 0) {
|
||||||
|
biomeData.remove("foliage_color_override")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!biomeData.has("grass_color_modifier")) {
|
||||||
try {
|
try {
|
||||||
biomeData.addProperty("grass_color_modifier", GRASS_COLOR_OVERRIDE_METHOD!!.invoke(biome) as Int)
|
biomeData.addProperty("grass_color_modifier", GRASS_COLOR_OVERRIDE_METHOD!!.invoke(biome, null) as Int)
|
||||||
} catch (exception: NullPointerException) {
|
} catch (exception: NullPointerException) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!biomeData.has("sky_color")) {
|
||||||
BIOME_SKY_COLOR_FIELD?.getInt(biome)?.let {
|
BIOME_SKY_COLOR_FIELD?.getInt(biome)?.let {
|
||||||
biomeData.addProperty("sky_color", it)
|
biomeData.addProperty("sky_color", it)
|
||||||
} ?: let {
|
} ?: let {
|
||||||
@ -85,11 +99,17 @@ object BiomeGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val FOLIAGE_COLOR_OVERRIDE_METHOD = try {
|
private val FOLIAGE_COLOR_AT_METHOD_METHOD = try {
|
||||||
Biome::class.java.getMethod("getFoliageColorAt", BlockPos::class.java)
|
Biome::class.java.getMethod("getFoliageColorAt", BlockPos::class.java)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val FOLIAGE_COLOR_METHOD = try {
|
||||||
|
Biome::class.java.getMethod("getFoliageColor")
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
private val GRASS_COLOR_OVERRIDE_METHOD = try {
|
private val GRASS_COLOR_OVERRIDE_METHOD = try {
|
||||||
Biome::class.java.getMethod("getGrassColorAt", BlockPos::class.java)
|
Biome::class.java.getMethod("getGrassColorAt", BlockPos::class.java)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
@ -126,7 +146,7 @@ object BiomeGenerator : Generator(
|
|||||||
private val BIOME_SKY_COLOR_FIELD = getField(Biome::class.java, "skyColor")
|
private val BIOME_SKY_COLOR_FIELD = getField(Biome::class.java, "skyColor")
|
||||||
|
|
||||||
|
|
||||||
private val MUSIC_CLASS_EVENT_FIELD = getField(getClass("net.minecraft.sound.MusicSound"), "sound")
|
private val MUSIC_CLASS_EVENT_FIELD = getField(getClass("net.minecraft.sound.MusicSound"), "sound", "event")
|
||||||
|
|
||||||
private fun getBiomes(): Set<Triple<Identifier, Int, Biome>> {
|
private fun getBiomes(): Set<Triple<Identifier, Int, Biome>> {
|
||||||
val biomes = getField(getClass("net.minecraft.util.registry.BuiltinRegistries", "net.minecraft.data.BuiltinRegistries", Registry::class.java.name)!!, "BIOME")!!.get(null) as Registry<Biome>
|
val biomes = getField(getClass("net.minecraft.util.registry.BuiltinRegistries", "net.minecraft.data.BuiltinRegistries", Registry::class.java.name)!!, "BIOME")!!.get(null) as Registry<Biome>
|
||||||
|
@ -13,7 +13,6 @@ import net.minecraft.block.Blocks
|
|||||||
import net.minecraft.block.FluidBlock
|
import net.minecraft.block.FluidBlock
|
||||||
import net.minecraft.client.color.block.BlockColors
|
import net.minecraft.client.color.block.BlockColors
|
||||||
import net.minecraft.fluid.Fluid
|
import net.minecraft.fluid.Fluid
|
||||||
import net.minecraft.util.collection.IdList
|
|
||||||
import net.minecraft.util.registry.Registry
|
import net.minecraft.util.registry.Registry
|
||||||
import net.minecraft.util.shape.VoxelShape
|
import net.minecraft.util.shape.VoxelShape
|
||||||
|
|
||||||
@ -134,8 +133,8 @@ object BlockGenerator : Generator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val hasColorProperties = (TINT_PROPERTIES_METHOD?.invoke(DEFAULT_BLOCK_COLORS, block) as Set<*>?)?.size?.let { it > 0 } ?: let {
|
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) as IdList<Any>
|
val blockColorProviderList = BLOCK_COLORS_PROVIDERS_ID_LIST!!.get(DEFAULT_BLOCK_COLORS)
|
||||||
blockColorProviderList.get(Registry.BLOCK.getRawId(block)) != null
|
ID_LIST_GET_METHOD.invoke(blockColorProviderList, Registry.BLOCK.getRawId(block)) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
val states = JsonObject()
|
val states = JsonObject()
|
||||||
@ -367,6 +366,10 @@ object BlockGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val ID_LIST_CLASS = getClass("net.minecraft.util.IdList", "net.minecraft.util.collection.IdList")!!
|
||||||
|
|
||||||
|
private val ID_LIST_GET_METHOD = ID_LIST_CLASS.getDeclaredMethod("get", Int::class.java)
|
||||||
|
|
||||||
private val BLOCK_COLORS_PROVIDERS_ID_LIST = getField(BlockColors::class.java, "providers")
|
private val BLOCK_COLORS_PROVIDERS_ID_LIST = getField(BlockColors::class.java, "providers")
|
||||||
|
|
||||||
private val TINT_PROPERTIES_METHOD = try {
|
private val TINT_PROPERTIES_METHOD = try {
|
||||||
@ -446,7 +449,8 @@ object BlockGenerator : Generator(
|
|||||||
LARGE_COLLISION_SHAPE_FIELD.isAccessible = true
|
LARGE_COLLISION_SHAPE_FIELD.isAccessible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private val BLOCK_STATE_REGISTRY: IdList<BlockState> = Block.STATE_IDS
|
private val BLOCK_STATE_REGISTRY: Iterable<BlockState> = Block::class.java.getDeclaredField("STATE_IDS").get(null) as Iterable<BlockState>
|
||||||
|
|
||||||
|
|
||||||
private val DEFAULT_BLOCK_COLORS = BlockColors.create()
|
private val DEFAULT_BLOCK_COLORS = BlockColors.create()
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@ object DimensionGenerator : Generator(
|
|||||||
private val AMBIENT_LIGHT_FIELD = getField(DIMENSION_TYPE_CLASS, "ambientLight")
|
private val AMBIENT_LIGHT_FIELD = getField(DIMENSION_TYPE_CLASS, "ambientLight")
|
||||||
|
|
||||||
|
|
||||||
private val RESOURCE_KEY_CLASS = getClass("net.minecraft.resources.ResourceKey")
|
private val RESOURCE_KEY_CLASS = getClass("net.minecraft.resources.ResourceKey", "net.minecraft.util.registry.RegistryKey")
|
||||||
|
|
||||||
private val RESOURCE_KEY_LOCATION_METHOD = RESOURCE_KEY_CLASS?.getDeclaredMethod("location")
|
private val RESOURCE_KEY_LOCATION_METHOD = getField(RESOURCE_KEY_CLASS, "value", "location")
|
||||||
|
|
||||||
private val DIMENSION_BIOME_ZOOMER_FIELD = getField(DimensionType::class.java, "biomeAccessType")
|
private val DIMENSION_BIOME_ZOOMER_FIELD = getField(DimensionType::class.java, "biomeAccessType")
|
||||||
|
|
||||||
@ -126,18 +126,6 @@ object DimensionGenerator : Generator(
|
|||||||
private fun getDimensions(): MutableSet<Triple<Identifier, Int?, DimensionType>> {
|
private fun getDimensions(): MutableSet<Triple<Identifier, Int?, DimensionType>> {
|
||||||
val types: MutableSet<Triple<Identifier, Int?, DimensionType>> = mutableSetOf()
|
val types: MutableSet<Triple<Identifier, Int?, DimensionType>> = mutableSetOf()
|
||||||
|
|
||||||
val dimensionRegistry = getField(Registry::class.java, "DIMENSION")
|
|
||||||
|
|
||||||
dimensionRegistry?.get(null)?.let {
|
|
||||||
check(it is Registry<*>)
|
|
||||||
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
|
||||||
val dimensionTypeGetIdMethod = DimensionType::class.java.getDeclaredMethod("getRawId")
|
|
||||||
for (entry in it) {
|
|
||||||
check(entry is DimensionType)
|
|
||||||
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, dimensionTypeGetIdMethod.invoke(entry) as Int, entry))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (types.isEmpty()) {
|
if (types.isEmpty()) {
|
||||||
for (field in DimensionType::class.java.declaredFields) {
|
for (field in DimensionType::class.java.declaredFields) {
|
||||||
@ -149,23 +137,37 @@ object DimensionGenerator : Generator(
|
|||||||
}
|
}
|
||||||
field.isAccessible = true
|
field.isAccessible = true
|
||||||
val resourceLocation = when (field.name) {
|
val resourceLocation = when (field.name) {
|
||||||
"OVERWORLD", "OVERLORD" -> Identifier("overworld")
|
"OVERWORLD", "OVERLORD", "field_25407" -> Identifier("overworld")
|
||||||
"OVERWORLD_CAVES" -> Identifier("overworld_caves")
|
"OVERWORLD_CAVES" -> Identifier("overworld_caves")
|
||||||
"THE_NETHER" -> Identifier("the_nether")
|
"THE_NETHER", "_NETHER" -> Identifier("the_nether")
|
||||||
"THE_END" -> Identifier("the_end")
|
"THE_END", "_END" -> Identifier("the_end")
|
||||||
else -> TODO("Can not find dimension ${field.name}")
|
else -> TODO("Can not find dimension ${field.name}")
|
||||||
}
|
}
|
||||||
types.add(Triple(resourceLocation, null, field.get(null) as DimensionType))
|
types.add(Triple(resourceLocation, null, field.get(null) as DimensionType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (types.isEmpty()) {
|
if (types.isEmpty()) {
|
||||||
val field = getField(DimensionType::class.java, "BUILTIN") ?: return types
|
val field = getField(DimensionType::class.java, "field_24759", "BUILTIN") ?: return types
|
||||||
|
|
||||||
for ((resourceLocation, dimension) in field.get(null) as Map<Any, DimensionType>) {
|
for ((resourceKey, dimension) in field.get(null) as Map<Any, DimensionType>) {
|
||||||
types.add(Triple(RESOURCE_KEY_LOCATION_METHOD!!.invoke(resourceLocation) as Identifier, null, dimension))
|
types.add(Triple(RESOURCE_KEY_LOCATION_METHOD!!.get(resourceKey) as Identifier, null, dimension))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (types.isEmpty()) {
|
||||||
|
val dimensionRegistry = getField(Registry::class.java, "DIMENSION")
|
||||||
|
|
||||||
|
dimensionRegistry?.get(null)?.let {
|
||||||
|
check(it is Registry<*>)
|
||||||
|
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
||||||
|
val dimensionTypeGetIdMethod = DimensionType::class.java.getDeclaredMethod("getRawId")
|
||||||
|
for (entry in it) {
|
||||||
|
check(entry is DimensionType)
|
||||||
|
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, dimensionTypeGetIdMethod.invoke(entry) as Int, entry))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return types
|
return types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ object EntityGenerator : Generator(
|
|||||||
ENTITY_TYPE_FIRE_IMMUNE_FIELD?.getBoolean(entityType)?.let {
|
ENTITY_TYPE_FIRE_IMMUNE_FIELD?.getBoolean(entityType)?.let {
|
||||||
entityData.addProperty("is_fire_immune", it)
|
entityData.addProperty("is_fire_immune", it)
|
||||||
}
|
}
|
||||||
|
|
||||||
CAN_SPAWN_FAR_AWAY_FROM_PLAYER_METHOD?.invoke(entityType)?.let {
|
CAN_SPAWN_FAR_AWAY_FROM_PLAYER_METHOD?.invoke(entityType)?.let {
|
||||||
entityData.addProperty("can_spawn_far_from_player", it as Boolean)
|
entityData.addProperty("can_spawn_far_from_player", it as Boolean)
|
||||||
}
|
}
|
||||||
@ -161,6 +162,8 @@ object EntityGenerator : Generator(
|
|||||||
private fun correctClassName(className: String): String {
|
private fun correctClassName(className: String): String {
|
||||||
return when (className) {
|
return when (className) {
|
||||||
"AgableMob" -> "AgeableMob"
|
"AgableMob" -> "AgeableMob"
|
||||||
|
"class_4985" -> "StriderEntity"
|
||||||
|
"class_4836" -> "PiglinEntity"
|
||||||
else -> className
|
else -> className
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,7 +199,7 @@ object EntityGenerator : Generator(
|
|||||||
|
|
||||||
private val ENTITY_TYPE_FIRE_IMMUNE_FIELD = getField(EntityType::class.java, "fireImmune")
|
private val ENTITY_TYPE_FIRE_IMMUNE_FIELD = getField(EntityType::class.java, "fireImmune")
|
||||||
|
|
||||||
private val ATTRIBUTE_CLASS = getClass("net.minecraft.world.entity.ai.attributes.Attributes", "net.minecraft.world.entity.monster.SharedMonsterAttributes", "net.minecraft.entity.attribute.EntityAttributes")!!
|
private val ATTRIBUTE_CLASS = getClass("net.minecraft.entity.attribute.Attributes", "net.minecraft.world.entity.ai.attributes.Attributes", "net.minecraft.world.entity.monster.SharedMonsterAttributes", "net.minecraft.entity.attribute.EntityAttributes")!!
|
||||||
|
|
||||||
private val ATTRIBUTE_MAP: Map<String, EntityAttribute> = getAttributes()
|
private val ATTRIBUTE_MAP: Map<String, EntityAttribute> = getAttributes()
|
||||||
|
|
||||||
@ -258,7 +261,7 @@ object EntityGenerator : Generator(
|
|||||||
ret[it.invoke(attribute) as String] = attribute
|
ret[it.invoke(attribute) as String] = attribute
|
||||||
} ?: let {
|
} ?: let {
|
||||||
val registry = attributeRegistryField!!.get(null) as Registry<*>
|
val registry = attributeRegistryField!!.get(null) as Registry<*>
|
||||||
val method = attributeRegistryField.type.getMethod("getKey", Object::class.java)
|
val method = attributeRegistryField.type.getMethod("getId", Object::class.java)
|
||||||
var key = method.invoke(registry, attribute)
|
var key = method.invoke(registry, attribute)
|
||||||
if (key is Optional<*>) {
|
if (key is Optional<*>) {
|
||||||
key = key.get()
|
key = key.get()
|
||||||
|
@ -13,7 +13,9 @@ object MaterialGenerator : Generator(
|
|||||||
override fun generate() {
|
override fun generate() {
|
||||||
for ((resourceLocation, material) in MATERIALS) {
|
for ((resourceLocation, material) in MATERIALS) {
|
||||||
val materialData = JsonObject()
|
val materialData = JsonObject()
|
||||||
materialData.addProperty("color", material.color.color)
|
val color = MATERIAL_GET_COLOR_METHOD.invoke(material)
|
||||||
|
val colorColor = color::class.java.getDeclaredField("color").getInt(color)
|
||||||
|
materialData.addProperty("color", colorColor)
|
||||||
materialData.addProperty("push_reaction", material.pistonBehavior.name.toLowerCase())
|
materialData.addProperty("push_reaction", material.pistonBehavior.name.toLowerCase())
|
||||||
materialData.addProperty("blocks_motion", material.blocksMovement())
|
materialData.addProperty("blocks_motion", material.blocksMovement())
|
||||||
materialData.addProperty("flammable", material.isBurnable)
|
materialData.addProperty("flammable", material.isBurnable)
|
||||||
@ -27,6 +29,9 @@ object MaterialGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val MATERIAL_GET_COLOR_METHOD = Material::class.java.getDeclaredMethod("getColor")
|
||||||
|
|
||||||
|
|
||||||
private fun getMaterials(): HashBiMap<Identifier, Material> {
|
private fun getMaterials(): HashBiMap<Identifier, Material> {
|
||||||
val materials: HashBiMap<Identifier, Material> = HashBiMap.create()
|
val materials: HashBiMap<Identifier, Material> = HashBiMap.create()
|
||||||
for (field in Material::class.java.declaredFields) {
|
for (field in Material::class.java.declaredFields) {
|
||||||
|
@ -2,16 +2,18 @@ package de.bixilon.pixlyzer.generator.generators
|
|||||||
|
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.pixlyzer.generator.Generator
|
import de.bixilon.pixlyzer.generator.Generator
|
||||||
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||||
|
import net.minecraft.entity.decoration.painting.PaintingMotive
|
||||||
import net.minecraft.util.registry.Registry
|
import net.minecraft.util.registry.Registry
|
||||||
|
|
||||||
object MotiveGenerator : Generator(
|
object MotiveGenerator : Generator(
|
||||||
"motives"
|
"motives"
|
||||||
) {
|
) {
|
||||||
override fun generate() {
|
override fun generate() {
|
||||||
for (motive in Registry.PAINTING_MOTIVE) {
|
for (motive in MOTIVE_REGISTRY) {
|
||||||
val resourceIdentifier = Registry.PAINTING_MOTIVE.getId(motive)
|
val resourceIdentifier = MOTIVE_REGISTRY.getId(motive)
|
||||||
val motiveData = JsonObject()
|
val motiveData = JsonObject()
|
||||||
motiveData.addProperty("id", Registry.PAINTING_MOTIVE.getRawId(motive))
|
motiveData.addProperty("id", MOTIVE_REGISTRY.getRawId(motive))
|
||||||
|
|
||||||
motiveData.addProperty("width", motive.width)
|
motiveData.addProperty("width", motive.width)
|
||||||
motiveData.addProperty("height", motive.height)
|
motiveData.addProperty("height", motive.height)
|
||||||
@ -19,4 +21,6 @@ object MotiveGenerator : Generator(
|
|||||||
data.add(resourceIdentifier.toString(), motiveData)
|
data.add(resourceIdentifier.toString(), motiveData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val MOTIVE_REGISTRY = getField(Registry::class.java, "PAINTING_MOTIVE", "MOTIVE")!!.get(null) as Registry<PaintingMotive>
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ package de.bixilon.pixlyzer.generator.generators
|
|||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.pixlyzer.generator.Generator
|
import de.bixilon.pixlyzer.generator.Generator
|
||||||
import de.bixilon.pixlyzer.util.ReflectionUtil
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getClass
|
||||||
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||||
import net.minecraft.block.Block
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.block.BlockState
|
import net.minecraft.block.BlockState
|
||||||
import net.minecraft.util.registry.Registry
|
import net.minecraft.util.registry.Registry
|
||||||
import net.minecraft.world.poi.PointOfInterestType
|
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
object PointOfInterestGenerator : Generator(
|
object PointOfInterestGenerator : Generator(
|
||||||
@ -18,16 +18,16 @@ object PointOfInterestGenerator : Generator(
|
|||||||
throw IllegalArgumentException("Not available in this version yet!")
|
throw IllegalArgumentException("Not available in this version yet!")
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pointOfInterestType in Registry.POINT_OF_INTEREST_TYPE) {
|
for (pointOfInterestType in POINT_OF_INTEREST_REGISTRY) {
|
||||||
val resourceIdentifier = Registry.POINT_OF_INTEREST_TYPE.getId(pointOfInterestType)
|
val resourceIdentifier = POINT_OF_INTEREST_REGISTRY.getId(pointOfInterestType)!!
|
||||||
val pointOfInterestData = JsonObject()
|
val pointOfInterestData = JsonObject()
|
||||||
pointOfInterestData.addProperty("id", Registry.POINT_OF_INTEREST_TYPE.getRawId(pointOfInterestType))
|
pointOfInterestData.addProperty("id", POINT_OF_INTEREST_REGISTRY.getRawId(pointOfInterestType))
|
||||||
pointOfInterestData.addProperty("ticket_count", pointOfInterestType.ticketCount)
|
// ToDo: pointOfInterestData.addProperty("ticket_count", pointOfInterestType.ticketCount)
|
||||||
SEARCH_DISTANCE_METHOD?.invoke(pointOfInterestType)?.let {
|
SEARCH_DISTANCE_METHOD?.invoke(pointOfInterestType)?.let {
|
||||||
pointOfInterestData.addProperty("search_distance", it as Int)
|
pointOfInterestData.addProperty("search_distance", it as Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
(POINT_OF_INTEREST_MATCHING_STATES_FIELD.get(pointOfInterestType) as Set<BlockState>).let {
|
(POINT_OF_INTEREST_MATCHING_STATES_FIELD?.get(pointOfInterestType) as Set<BlockState>?)?.let {
|
||||||
val states = JsonArray()
|
val states = JsonArray()
|
||||||
for (state in it) {
|
for (state in it) {
|
||||||
states.add(Block.getRawIdFromState(state))
|
states.add(Block.getRawIdFromState(state))
|
||||||
@ -39,22 +39,21 @@ object PointOfInterestGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val POINT_OF_INTEREST_REGISTRY = ReflectionUtil.getField(Registry::class.java, "POINT_OF_INTEREST_TYPE")?.get(null) as Registry<Any>?
|
|
||||||
|
|
||||||
private val POINT_OF_INTEREST_MATCHING_STATES_FIELD = PointOfInterestType::class.java.getDeclaredField("blockStates")
|
val POINT_OF_INTEREST_REGISTRY = getField(Registry::class.java, "POINT_OF_INTEREST_TYPE")?.get(null) as Registry<Any>?
|
||||||
|
|
||||||
private val SEARCH_DISTANCE_METHOD: Method?
|
val POINT_OF_INTEREST_CLASS = getClass("net.minecraft.world.poi.PointOfInterestType", "net.minecraft.village.PointOfInterestType")
|
||||||
|
|
||||||
init {
|
private val POINT_OF_INTEREST_MATCHING_STATES_FIELD = getField(POINT_OF_INTEREST_CLASS, "blockStates")
|
||||||
POINT_OF_INTEREST_MATCHING_STATES_FIELD.isAccessible = true
|
|
||||||
SEARCH_DISTANCE_METHOD = try {
|
private val SEARCH_DISTANCE_METHOD: Method? = try {
|
||||||
PointOfInterestType::class.java.getDeclaredMethod("method_21648")
|
POINT_OF_INTEREST_CLASS?.getDeclaredMethod("method_21648")
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
try {
|
||||||
|
POINT_OF_INTEREST_CLASS?.getDeclaredMethod("getSearchDistance")
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
try {
|
null
|
||||||
PointOfInterestType::class.java.getDeclaredMethod("getSearchDistance")
|
|
||||||
} catch (exception: Exception) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package de.bixilon.pixlyzer.generator.generators
|
|||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.pixlyzer.generator.Generator
|
import de.bixilon.pixlyzer.generator.Generator
|
||||||
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getField
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance
|
import net.minecraft.entity.effect.StatusEffectInstance
|
||||||
|
import net.minecraft.potion.Potion
|
||||||
import net.minecraft.util.registry.Registry
|
import net.minecraft.util.registry.Registry
|
||||||
|
|
||||||
object PotionGenerator : Generator(
|
object PotionGenerator : Generator(
|
||||||
@ -16,7 +18,9 @@ object PotionGenerator : Generator(
|
|||||||
|
|
||||||
potionData.addProperty("id", Registry.POTION.getRawId(potion))
|
potionData.addProperty("id", Registry.POTION.getRawId(potion))
|
||||||
|
|
||||||
potionData.addProperty("name", potion.finishTranslationKey(""))
|
(POTION_NAME_FIELD.get(potion) as String?)?.let {
|
||||||
|
potionData.addProperty("name", it)
|
||||||
|
}
|
||||||
|
|
||||||
val effects = JsonArray()
|
val effects = JsonArray()
|
||||||
|
|
||||||
@ -31,6 +35,8 @@ object PotionGenerator : Generator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val POTION_NAME_FIELD = getField(Potion::class.java, "baseName", "name")!!
|
||||||
|
|
||||||
|
|
||||||
private fun StatusEffectInstance.serialize(): JsonObject {
|
private fun StatusEffectInstance.serialize(): JsonObject {
|
||||||
val mobEffect = JsonObject()
|
val mobEffect = JsonObject()
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"PROJECTILE_FLAGS": "ABSTRACT_ARROW_FLAGS",
|
"PROJECTILE_FLAGS": "ABSTRACT_ARROW_FLAGS",
|
||||||
"PIERCE_LEVEL": "ABSTRACT_ARROW_PIERCE_LEVEL",
|
"PIERCE_LEVEL": "ABSTRACT_ARROW_PIERCE_LEVEL",
|
||||||
|
"OPTIONAL_UUID": "ABSTRACT_ARROW_OWNER_UUID",
|
||||||
"field_7580": "ABSTRACT_ARROW_OWNER_UUID"
|
"field_7580": "ABSTRACT_ARROW_OWNER_UUID"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -98,7 +99,8 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"LOYALTY": "THROWN_TRIDENT_LOYALTY_LEVEL",
|
"LOYALTY": "THROWN_TRIDENT_LOYALTY_LEVEL",
|
||||||
"ENCHANTED": "THROWN_TRIDENT_FOIL",
|
"ENCHANTED": "THROWN_TRIDENT_FOIL",
|
||||||
"ID_FOIL": "THROWN_TRIDENT_FOIL"
|
"ID_FOIL": "THROWN_TRIDENT_FOIL",
|
||||||
|
"field_21514": "THROWN_TRIDENT_FOIL"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"BoatEntity": {
|
"BoatEntity": {
|
||||||
@ -317,6 +319,7 @@
|
|||||||
"COLLAR_COLOR": "WOLF_COLLAR_COLOR",
|
"COLLAR_COLOR": "WOLF_COLLAR_COLOR",
|
||||||
"DATA_REMAINING_ANGER_TIME": "WOLF_ANGER_TIME",
|
"DATA_REMAINING_ANGER_TIME": "WOLF_ANGER_TIME",
|
||||||
"ANGER_TIME": "WOLF_ANGER_TIME",
|
"ANGER_TIME": "WOLF_ANGER_TIME",
|
||||||
|
"field_25373": "WOLF_ANGER_TIME",
|
||||||
"WOLF_HEALTH": "WOLF_HEALTH"
|
"WOLF_HEALTH": "WOLF_HEALTH"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -355,7 +358,8 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"CARRIED_BLOCK": "ENDERMAN_CARRIED_BLOCK",
|
"CARRIED_BLOCK": "ENDERMAN_CARRIED_BLOCK",
|
||||||
"ANGRY": "ENDERMAN_IS_SCREAMING",
|
"ANGRY": "ENDERMAN_IS_SCREAMING",
|
||||||
"PROVOKED": "ENDERMAN_IS_STARRING"
|
"PROVOKED": "ENDERMAN_IS_STARRING",
|
||||||
|
"field_20618": "ENDERMAN_IS_STARRING"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SpellcastingIllagerEntity": {
|
"SpellcastingIllagerEntity": {
|
||||||
@ -476,8 +480,10 @@
|
|||||||
},
|
},
|
||||||
"BeeEntity": {
|
"BeeEntity": {
|
||||||
"data": {
|
"data": {
|
||||||
|
"multipleByteTracker": "BEE_FLAGS",
|
||||||
"STATUS_TRACKER": "BEE_FLAGS",
|
"STATUS_TRACKER": "BEE_FLAGS",
|
||||||
"ANGER": "BEE_REMAINING_ANGER_TIME"
|
"ANGER": "BEE_REMAINING_ANGER_TIME",
|
||||||
|
"anger": "BEE_REMAINING_ANGER_TIME"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"HoglinEntity": {
|
"HoglinEntity": {
|
||||||
@ -494,9 +500,15 @@
|
|||||||
"PiglinEntity": {
|
"PiglinEntity": {
|
||||||
"data": {
|
"data": {
|
||||||
"BABY": "PIGLIN_IS_BABY",
|
"BABY": "PIGLIN_IS_BABY",
|
||||||
|
"field_22377": "PIGLIN_IS_BABY",
|
||||||
"CHARGING": "PIGLIN_IS_CHARGING_CROSSBOW",
|
"CHARGING": "PIGLIN_IS_CHARGING_CROSSBOW",
|
||||||
|
"field_22378": "PIGLIN_IS_CHARGING_CROSSBOW",
|
||||||
"DANCING": "PIGLIN_IS_DANCING",
|
"DANCING": "PIGLIN_IS_DANCING",
|
||||||
"IMMUNE_TO_ZOMBIFICATION": "PIGLIN_IMMUNE_TO_ZOMBIFICATION"
|
"dancing": "PIGLIN_IS_DANCING",
|
||||||
|
"field_25164": "PIGLIN_IS_DANCING",
|
||||||
|
"IMMUNE_TO_ZOMBIFICATION": "PIGLIN_IMMUNE_TO_ZOMBIFICATION",
|
||||||
|
"field_22419": "PIGLIN_IMMUNE_TO_ZOMBIFICATION",
|
||||||
|
"OLD_IMMUNE_TO_ZOMBIFICATION": "PIGLIN_IMMUNE_TO_ZOMBIFICATION"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ZoglinEntity": {
|
"ZoglinEntity": {
|
||||||
@ -508,7 +520,10 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"BOOST_TIME": "STRIDER_TIME_TO_BOOST",
|
"BOOST_TIME": "STRIDER_TIME_TO_BOOST",
|
||||||
"COLD": "STRIDER_IS_SUFFOCATING",
|
"COLD": "STRIDER_IS_SUFFOCATING",
|
||||||
"SADDLED": "STRIDER_HAS_SADDLE"
|
"SADDLED": "STRIDER_HAS_SADDLE",
|
||||||
|
"field_23245": "STRIDER_TIME_TO_BOOST",
|
||||||
|
"field_23246": "STRIDER_IS_SUFFOCATING",
|
||||||
|
"field_23247": "STRIDER_HAS_SADDLE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AxolotlEntity": {
|
"AxolotlEntity": {
|
||||||
@ -525,6 +540,7 @@
|
|||||||
},
|
},
|
||||||
"SkeletonEntity": {
|
"SkeletonEntity": {
|
||||||
"data": {
|
"data": {
|
||||||
|
"field_28642": "SKELETON_STRAY_FREEZE_CONVERTING",
|
||||||
"CONVERTING": "SKELETON_STRAY_FREEZE_CONVERTING"
|
"CONVERTING": "SKELETON_STRAY_FREEZE_CONVERTING"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ for version in VERSION_MANIFEST["versions"]:
|
|||||||
versionStartTime = datetime.now()
|
versionStartTime = datetime.now()
|
||||||
print("Generating data for %s" % version["id"])
|
print("Generating data for %s" % version["id"])
|
||||||
# execute
|
# execute
|
||||||
if runAndWait("%s -classpath \"%s:%s:%s:%s\" de.bixilon.pixlyzer.PixLyzer \"%s\" \"%s\" \"%s\"" % (JAVA_PATH, ADDITIONAL_CLASSPATH, DATA_FOLDER + version["id"] + "_yarn/" + version["id"] + "-named.jar", DATA_FOLDER + version["id"] + "_yarn/" + version["id"] + "_server_mojang.jar", "target/classes", OUT_FOLDER + version["id"], HASH_FOLDER, ASSETS_HASH_INDEX_FILE)) != 0:
|
if runAndWait("%s -Xverify:none -classpath \"%s:%s:%s:%s\" de.bixilon.pixlyzer.PixLyzer \"%s\" \"%s\" \"%s\"" % (JAVA_PATH, ADDITIONAL_CLASSPATH, DATA_FOLDER + version["id"] + "_yarn/" + version["id"] + "-named.jar", DATA_FOLDER + version["id"] + "_yarn/" + version["id"] + "_server_mojang.jar", "target/classes", OUT_FOLDER + version["id"], HASH_FOLDER, ASSETS_HASH_INDEX_FILE)) != 0:
|
||||||
print("PixLyzer did not run successfully for %s" % version["id"])
|
print("PixLyzer did not run successfully for %s" % version["id"])
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user