Extractor: minimize everything

- blocks.json 8.3MB -> 4.1MB
- items.json 988KB -> 548KB
- packets.json 6.9kb -> 4.2kb
- particles.json 3.5kb -> 1.6kb
- recipies.json 376kb -> 264kb
- screens.json 731b -> 315b
- sounds.json 72.2kb -> 42.2kb
- synced_registeries.json 143.3kb -> 87.6kb
- tags.json 335.4kb -> 165.8kb
This commit is contained in:
Snowiiii 2024-11-27 00:12:11 +01:00
parent 0cc693e4b2
commit 796341be05
33 changed files with 161 additions and 437073 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,256 +1 @@
{
"serverbound": {
"handshake": {
"intention": 0
},
"status": {
"status_request": 0,
"ping_request": 1
},
"login": {
"hello": 0,
"key": 1,
"custom_query_answer": 2,
"login_acknowledged": 3,
"cookie_response": 4
},
"config": {
"client_information": 0,
"cookie_response": 1,
"custom_payload": 2,
"finish_configuration": 3,
"keep_alive": 4,
"pong": 5,
"resource_pack": 6,
"select_known_packs": 7
},
"play": {
"accept_teleportation": 0,
"block_entity_tag_query": 1,
"bundle_item_selected": 2,
"change_difficulty": 3,
"chat_ack": 4,
"chat_command": 5,
"chat_command_signed": 6,
"chat": 7,
"chat_session_update": 8,
"chunk_batch_received": 9,
"client_command": 10,
"client_tick_end": 11,
"client_information": 12,
"command_suggestion": 13,
"configuration_acknowledged": 14,
"container_button_click": 15,
"container_click": 16,
"container_close": 17,
"container_slot_state_changed": 18,
"cookie_response": 19,
"custom_payload": 20,
"debug_sample_subscription": 21,
"edit_book": 22,
"entity_tag_query": 23,
"interact": 24,
"jigsaw_generate": 25,
"keep_alive": 26,
"lock_difficulty": 27,
"move_player_pos": 28,
"move_player_pos_rot": 29,
"move_player_rot": 30,
"move_player_status_only": 31,
"move_vehicle": 32,
"paddle_boat": 33,
"pick_item": 34,
"ping_request": 35,
"place_recipe": 36,
"player_abilities": 37,
"player_action": 38,
"player_command": 39,
"player_input": 40,
"pong": 41,
"recipe_book_change_settings": 42,
"recipe_book_seen_recipe": 43,
"rename_item": 44,
"resource_pack": 45,
"seen_advancements": 46,
"select_trade": 47,
"set_beacon": 48,
"set_carried_item": 49,
"set_command_block": 50,
"set_command_minecart": 51,
"set_creative_mode_slot": 52,
"set_jigsaw_block": 53,
"set_structure_block": 54,
"sign_update": 55,
"swing": 56,
"teleport_to_entity": 57,
"use_item_on": 58,
"use_item": 59
}
},
"clientbound": {
"status": {
"status_response": 0,
"pong_response": 1
},
"login": {
"login_disconnect": 0,
"hello": 1,
"login_finished": 2,
"login_compression": 3,
"custom_query": 4,
"cookie_request": 5
},
"config": {
"cookie_request": 0,
"custom_payload": 1,
"disconnect": 2,
"finish_configuration": 3,
"keep_alive": 4,
"ping": 5,
"reset_chat": 6,
"registry_data": 7,
"resource_pack_pop": 8,
"resource_pack_push": 9,
"store_cookie": 10,
"transfer": 11,
"update_enabled_features": 12,
"update_tags": 13,
"select_known_packs": 14,
"custom_report_details": 15,
"server_links": 16
},
"play": {
"bundle_delimiter": 0,
"add_entity": 1,
"add_experience_orb": 2,
"animate": 3,
"award_stats": 4,
"block_changed_ack": 5,
"block_destruction": 6,
"block_entity_data": 7,
"block_event": 8,
"block_update": 9,
"boss_event": 10,
"change_difficulty": 11,
"chunk_batch_finished": 12,
"chunk_batch_start": 13,
"chunks_biomes": 14,
"clear_titles": 15,
"command_suggestions": 16,
"commands": 17,
"container_close": 18,
"container_set_content": 19,
"container_set_data": 20,
"container_set_slot": 21,
"cookie_request": 22,
"cooldown": 23,
"custom_chat_completions": 24,
"custom_payload": 25,
"damage_event": 26,
"debug_sample": 27,
"delete_chat": 28,
"disconnect": 29,
"disguised_chat": 30,
"entity_event": 31,
"entity_position_sync": 32,
"explode": 33,
"forget_level_chunk": 34,
"game_event": 35,
"horse_screen_open": 36,
"hurt_animation": 37,
"initialize_border": 38,
"keep_alive": 39,
"level_chunk_with_light": 40,
"level_event": 41,
"level_particles": 42,
"light_update": 43,
"login": 44,
"map_item_data": 45,
"merchant_offers": 46,
"move_entity_pos": 47,
"move_entity_pos_rot": 48,
"move_minecart_along_track": 49,
"move_entity_rot": 50,
"move_vehicle": 51,
"open_book": 52,
"open_screen": 53,
"open_sign_editor": 54,
"ping": 55,
"pong_response": 56,
"place_ghost_recipe": 57,
"player_abilities": 58,
"player_chat": 59,
"player_combat_end": 60,
"player_combat_enter": 61,
"player_combat_kill": 62,
"player_info_remove": 63,
"player_info_update": 64,
"player_look_at": 65,
"player_position": 66,
"player_rotation": 67,
"recipe_book_add": 68,
"recipe_book_remove": 69,
"recipe_book_settings": 70,
"remove_entities": 71,
"remove_mob_effect": 72,
"reset_score": 73,
"resource_pack_pop": 74,
"resource_pack_push": 75,
"respawn": 76,
"rotate_head": 77,
"section_blocks_update": 78,
"select_advancements_tab": 79,
"server_data": 80,
"set_action_bar_text": 81,
"set_border_center": 82,
"set_border_lerp_size": 83,
"set_border_size": 84,
"set_border_warning_delay": 85,
"set_border_warning_distance": 86,
"set_camera": 87,
"set_chunk_cache_center": 88,
"set_chunk_cache_radius": 89,
"set_cursor_item": 90,
"set_default_spawn_position": 91,
"set_display_objective": 92,
"set_entity_data": 93,
"set_entity_link": 94,
"set_entity_motion": 95,
"set_equipment": 96,
"set_experience": 97,
"set_health": 98,
"set_held_slot": 99,
"set_objective": 100,
"set_passengers": 101,
"set_player_inventory": 102,
"set_player_team": 103,
"set_score": 104,
"set_simulation_distance": 105,
"set_subtitle_text": 106,
"set_time": 107,
"set_title_text": 108,
"set_titles_animation": 109,
"sound_entity": 110,
"sound": 111,
"start_configuration": 112,
"stop_sound": 113,
"store_cookie": 114,
"system_chat": 115,
"tab_list": 116,
"tag_query": 117,
"take_item_entity": 118,
"teleport_entity": 119,
"ticking_state": 120,
"ticking_step": 121,
"transfer": 122,
"update_advancements": 123,
"update_attributes": 124,
"update_mob_effect": 125,
"update_recipes": 126,
"update_tags": 127,
"projectile_power": 128,
"custom_report_details": 129,
"server_links": 130
}
}
}
{"serverbound":{"handshake":["intention"],"status":["status_request","ping_request"],"login":["hello","key","custom_query_answer","login_acknowledged","cookie_response"],"config":["client_information","cookie_response","custom_payload","finish_configuration","keep_alive","pong","resource_pack","select_known_packs"],"play":["accept_teleportation","block_entity_tag_query","bundle_item_selected","change_difficulty","chat_ack","chat_command","chat_command_signed","chat","chat_session_update","chunk_batch_received","client_command","client_tick_end","client_information","command_suggestion","configuration_acknowledged","container_button_click","container_click","container_close","container_slot_state_changed","cookie_response","custom_payload","debug_sample_subscription","edit_book","entity_tag_query","interact","jigsaw_generate","keep_alive","lock_difficulty","move_player_pos","move_player_pos_rot","move_player_rot","move_player_status_only","move_vehicle","paddle_boat","pick_item","ping_request","place_recipe","player_abilities","player_action","player_command","player_input","pong","recipe_book_change_settings","recipe_book_seen_recipe","rename_item","resource_pack","seen_advancements","select_trade","set_beacon","set_carried_item","set_command_block","set_command_minecart","set_creative_mode_slot","set_jigsaw_block","set_structure_block","sign_update","swing","teleport_to_entity","use_item_on","use_item"]},"clientbound":{"status":["status_response","pong_response"],"login":["login_disconnect","hello","login_finished","login_compression","custom_query","cookie_request"],"config":["cookie_request","custom_payload","disconnect","finish_configuration","keep_alive","ping","reset_chat","registry_data","resource_pack_pop","resource_pack_push","store_cookie","transfer","update_enabled_features","update_tags","select_known_packs","custom_report_details","server_links"],"play":["bundle_delimiter","add_entity","add_experience_orb","animate","award_stats","block_changed_ack","block_destruction","block_entity_data","block_event","block_update","boss_event","change_difficulty","chunk_batch_finished","chunk_batch_start","chunks_biomes","clear_titles","command_suggestions","commands","container_close","container_set_content","container_set_data","container_set_slot","cookie_request","cooldown","custom_chat_completions","custom_payload","damage_event","debug_sample","delete_chat","disconnect","disguised_chat","entity_event","entity_position_sync","explode","forget_level_chunk","game_event","horse_screen_open","hurt_animation","initialize_border","keep_alive","level_chunk_with_light","level_event","level_particles","light_update","login","map_item_data","merchant_offers","move_entity_pos","move_entity_pos_rot","move_minecart_along_track","move_entity_rot","move_vehicle","open_book","open_screen","open_sign_editor","ping","pong_response","place_ghost_recipe","player_abilities","player_chat","player_combat_end","player_combat_enter","player_combat_kill","player_info_remove","player_info_update","player_look_at","player_position","player_rotation","recipe_book_add","recipe_book_remove","recipe_book_settings","remove_entities","remove_mob_effect","reset_score","resource_pack_pop","resource_pack_push","respawn","rotate_head","section_blocks_update","select_advancements_tab","server_data","set_action_bar_text","set_border_center","set_border_lerp_size","set_border_size","set_border_warning_delay","set_border_warning_distance","set_camera","set_chunk_cache_center","set_chunk_cache_radius","set_cursor_item","set_default_spawn_position","set_display_objective","set_entity_data","set_entity_link","set_entity_motion","set_equipment","set_experience","set_health","set_held_slot","set_objective","set_passengers","set_player_inventory","set_player_team","set_score","set_simulation_distance","set_subtitle_text","set_time","set_title_text","set_titles_animation","sound_entity","sound","start_configuration","stop_sound","store_cookie","system_chat","tab_list","tag_query","take_item_entity","teleport_entity","ticking_state","ticking_step","transfer","update_advancements","update_attributes","update_mob_effect","update_recipes","update_tags","projectile_power","custom_report_details","server_links"]}}

View File

@ -1,113 +1 @@
{
"minecraft:angry_villager": 0,
"minecraft:block": 1,
"minecraft:block_marker": 2,
"minecraft:bubble": 3,
"minecraft:cloud": 4,
"minecraft:crit": 5,
"minecraft:damage_indicator": 6,
"minecraft:dragon_breath": 7,
"minecraft:dripping_lava": 8,
"minecraft:falling_lava": 9,
"minecraft:landing_lava": 10,
"minecraft:dripping_water": 11,
"minecraft:falling_water": 12,
"minecraft:dust": 13,
"minecraft:dust_color_transition": 14,
"minecraft:effect": 15,
"minecraft:elder_guardian": 16,
"minecraft:enchanted_hit": 17,
"minecraft:enchant": 18,
"minecraft:end_rod": 19,
"minecraft:entity_effect": 20,
"minecraft:explosion_emitter": 21,
"minecraft:explosion": 22,
"minecraft:gust": 23,
"minecraft:small_gust": 24,
"minecraft:gust_emitter_large": 25,
"minecraft:gust_emitter_small": 26,
"minecraft:sonic_boom": 27,
"minecraft:falling_dust": 28,
"minecraft:firework": 29,
"minecraft:fishing": 30,
"minecraft:flame": 31,
"minecraft:infested": 32,
"minecraft:cherry_leaves": 33,
"minecraft:sculk_soul": 34,
"minecraft:sculk_charge": 35,
"minecraft:sculk_charge_pop": 36,
"minecraft:soul_fire_flame": 37,
"minecraft:soul": 38,
"minecraft:flash": 39,
"minecraft:happy_villager": 40,
"minecraft:composter": 41,
"minecraft:heart": 42,
"minecraft:instant_effect": 43,
"minecraft:item": 44,
"minecraft:vibration": 45,
"minecraft:trail": 46,
"minecraft:item_slime": 47,
"minecraft:item_cobweb": 48,
"minecraft:item_snowball": 49,
"minecraft:large_smoke": 50,
"minecraft:lava": 51,
"minecraft:mycelium": 52,
"minecraft:note": 53,
"minecraft:poof": 54,
"minecraft:portal": 55,
"minecraft:rain": 56,
"minecraft:smoke": 57,
"minecraft:white_smoke": 58,
"minecraft:sneeze": 59,
"minecraft:spit": 60,
"minecraft:squid_ink": 61,
"minecraft:sweep_attack": 62,
"minecraft:totem_of_undying": 63,
"minecraft:underwater": 64,
"minecraft:splash": 65,
"minecraft:witch": 66,
"minecraft:bubble_pop": 67,
"minecraft:current_down": 68,
"minecraft:bubble_column_up": 69,
"minecraft:nautilus": 70,
"minecraft:dolphin": 71,
"minecraft:campfire_cosy_smoke": 72,
"minecraft:campfire_signal_smoke": 73,
"minecraft:dripping_honey": 74,
"minecraft:falling_honey": 75,
"minecraft:landing_honey": 76,
"minecraft:falling_nectar": 77,
"minecraft:falling_spore_blossom": 78,
"minecraft:ash": 79,
"minecraft:crimson_spore": 80,
"minecraft:warped_spore": 81,
"minecraft:spore_blossom_air": 82,
"minecraft:dripping_obsidian_tear": 83,
"minecraft:falling_obsidian_tear": 84,
"minecraft:landing_obsidian_tear": 85,
"minecraft:reverse_portal": 86,
"minecraft:white_ash": 87,
"minecraft:small_flame": 88,
"minecraft:snowflake": 89,
"minecraft:dripping_dripstone_lava": 90,
"minecraft:falling_dripstone_lava": 91,
"minecraft:dripping_dripstone_water": 92,
"minecraft:falling_dripstone_water": 93,
"minecraft:glow_squid_ink": 94,
"minecraft:glow": 95,
"minecraft:wax_on": 96,
"minecraft:wax_off": 97,
"minecraft:electric_spark": 98,
"minecraft:scrape": 99,
"minecraft:shriek": 100,
"minecraft:egg_crack": 101,
"minecraft:dust_plume": 102,
"minecraft:trial_spawner_detection": 103,
"minecraft:trial_spawner_detection_ominous": 104,
"minecraft:vault_connection": 105,
"minecraft:dust_pillar": 106,
"minecraft:ominous_spawning": 107,
"minecraft:raid_omen": 108,
"minecraft:trial_omen": 109,
"minecraft:block_crumble": 110
}
["angry_villager","block","block_marker","bubble","cloud","crit","damage_indicator","dragon_breath","dripping_lava","falling_lava","landing_lava","dripping_water","falling_water","dust","dust_color_transition","effect","elder_guardian","enchanted_hit","enchant","end_rod","entity_effect","explosion_emitter","explosion","gust","small_gust","gust_emitter_large","gust_emitter_small","sonic_boom","falling_dust","firework","fishing","flame","infested","cherry_leaves","sculk_soul","sculk_charge","sculk_charge_pop","soul_fire_flame","soul","flash","happy_villager","composter","heart","instant_effect","item","vibration","trail","item_slime","item_cobweb","item_snowball","large_smoke","lava","mycelium","note","poof","portal","rain","smoke","white_smoke","sneeze","spit","squid_ink","sweep_attack","totem_of_undying","underwater","splash","witch","bubble_pop","current_down","bubble_column_up","nautilus","dolphin","campfire_cosy_smoke","campfire_signal_smoke","dripping_honey","falling_honey","landing_honey","falling_nectar","falling_spore_blossom","ash","crimson_spore","warped_spore","spore_blossom_air","dripping_obsidian_tear","falling_obsidian_tear","landing_obsidian_tear","reverse_portal","white_ash","small_flame","snowflake","dripping_dripstone_lava","falling_dripstone_lava","dripping_dripstone_water","falling_dripstone_water","glow_squid_ink","glow","wax_on","wax_off","electric_spark","scrape","shriek","egg_crack","dust_plume","trial_spawner_detection","trial_spawner_detection_ominous","vault_connection","dust_pillar","ominous_spawning","raid_omen","trial_omen","block_crumble"]

File diff suppressed because one or more lines are too long

View File

@ -1,27 +1 @@
{
"minecraft:generic_9x1": 0,
"minecraft:generic_9x2": 1,
"minecraft:generic_9x3": 2,
"minecraft:generic_9x4": 3,
"minecraft:generic_9x5": 4,
"minecraft:generic_9x6": 5,
"minecraft:generic_3x3": 6,
"minecraft:crafter_3x3": 7,
"minecraft:anvil": 8,
"minecraft:beacon": 9,
"minecraft:blast_furnace": 10,
"minecraft:brewing_stand": 11,
"minecraft:crafting": 12,
"minecraft:enchantment": 13,
"minecraft:furnace": 14,
"minecraft:grindstone": 15,
"minecraft:hopper": 16,
"minecraft:lectern": 17,
"minecraft:loom": 18,
"minecraft:merchant": 19,
"minecraft:shulker_box": 20,
"minecraft:smithing": 21,
"minecraft:smoker": 22,
"minecraft:cartography_table": 23,
"minecraft:stonecutter": 24
}
["generic_9x1","generic_9x2","generic_9x3","generic_9x4","generic_9x5","generic_9x6","generic_3x3","crafter_3x3","anvil","beacon","blast_furnace","brewing_stand","crafting","enchantment","furnace","grindstone","hopper","lectern","loom","merchant","shulker_box","smithing","smoker","cartography_table","stonecutter"]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -42,7 +42,7 @@ class Extractor : ModInitializer {
return
}
val gson = GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().create()
val gson = GsonBuilder().disableHtmlEscaping().create()
ServerLifecycleEvents.SERVER_STARTED.register(ServerLifecycleEvents.ServerStarted { server: MinecraftServer ->
for (ext in extractors) {

View File

@ -27,7 +27,7 @@ class Blocks : Extractor.Extractor {
for (block in Registries.BLOCK) {
val blockJson = JsonObject()
blockJson.addProperty("id", Registries.BLOCK.getRawId(block))
blockJson.addProperty("name", Registries.BLOCK.getId(block).toString())
blockJson.addProperty("name", Registries.BLOCK.getId(block).path)
blockJson.addProperty("translation_key", block.translationKey)
blockJson.addProperty("hardness", block.hardness)
blockJson.addProperty("item_id", Registries.ITEM.getRawId(block.asItem()))
@ -88,23 +88,22 @@ class Blocks : Extractor.Extractor {
val blockEntitiesJson = JsonArray()
for (blockEntity in Registries.BLOCK_ENTITY_TYPE) {
val blockEntityJson = JsonObject()
blockEntityJson.addProperty("id", Registries.BLOCK_ENTITY_TYPE.getRawId(blockEntity))
blockEntityJson.addProperty("ident", Registries.BLOCK_ENTITY_TYPE.getId(blockEntity).toString())
blockEntityJson.addProperty("name", Registries.BLOCK_ENTITY_TYPE.getId(blockEntity)!!.path)
blockEntitiesJson.add(blockEntityJson)
blockEntitiesJson.add(Registries.BLOCK_ENTITY_TYPE.getId(blockEntity)!!.path)
}
val shapesJson = JsonArray()
for (shape in shapes.keys) {
val shapeJson = JsonObject()
shapeJson.addProperty("min_x", shape.minX)
shapeJson.addProperty("min_y", shape.minY)
shapeJson.addProperty("min_z", shape.minZ)
shapeJson.addProperty("max_x", shape.maxX)
shapeJson.addProperty("max_y", shape.maxY)
shapeJson.addProperty("max_z", shape.maxZ)
val min = JsonArray()
min.add(shape.minX)
min.add(shape.minY)
min.add(shape.minZ)
val max = JsonArray()
max.add(shape.maxX)
max.add(shape.maxY)
max.add(shape.maxZ)
shapeJson.add("min", min)
shapeJson.add("max", max)
shapesJson.add(shapeJson)
}

View File

@ -34,7 +34,7 @@ class Items : Extractor.Extractor {
).getOrThrow()
)
itemsJson.add(Registries.ITEM.getId(realItem).toString(), itemJson)
itemsJson.add(Registries.ITEM.getId(realItem).path, itemJson)
}
return itemsJson
}

View File

@ -1,5 +1,6 @@
package de.snowii.extractor.extractors
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import de.snowii.extractor.Extractor
@ -49,20 +50,20 @@ class Packets : Extractor.Extractor {
private fun serializeServerBound(
packets: Array<NetworkState.Factory<out ServerCrashSafePacketListener, out ByteBuf>>
): JsonObject {
val handshakeArray = JsonObject()
val statusArray = JsonObject()
val loginArray = JsonObject()
val configArray = JsonObject()
val playArray = JsonObject()
val handshakeArray = JsonArray()
val statusArray = JsonArray()
val loginArray = JsonArray()
val configArray = JsonArray()
val playArray = JsonArray()
for (factory in packets) {
factory.forEachPacketType { type: PacketType<*>, i: Int ->
factory.forEachPacketType { type: PacketType<*>, _: Int ->
when (factory.phase()!!) {
NetworkPhase.HANDSHAKING -> handshakeArray.addProperty(type.id().path, i)
NetworkPhase.PLAY -> playArray.addProperty(type.id().path, i)
NetworkPhase.STATUS -> statusArray.addProperty(type.id().path, i)
NetworkPhase.LOGIN -> loginArray.addProperty(type.id().path, i)
NetworkPhase.CONFIGURATION -> configArray.addProperty(type.id().path, i)
NetworkPhase.HANDSHAKING -> handshakeArray.add(type.id().path)
NetworkPhase.PLAY -> playArray.add(type.id().path)
NetworkPhase.STATUS -> statusArray.add(type.id().path)
NetworkPhase.LOGIN -> loginArray.add(type.id().path)
NetworkPhase.CONFIGURATION -> configArray.add(type.id().path)
}
}
}
@ -78,19 +79,19 @@ class Packets : Extractor.Extractor {
private fun serializeClientBound(
packets: Array<NetworkState.Factory<out ClientPacketListener, out PacketByteBuf>>
): JsonObject {
val statusArray = JsonObject()
val loginArray = JsonObject()
val configArray = JsonObject()
val playArray = JsonObject()
val statusArray = JsonArray()
val loginArray = JsonArray()
val configArray = JsonArray()
val playArray = JsonArray()
for (factory in packets) {
factory.forEachPacketType { type: PacketType<*>, i: Int ->
factory.forEachPacketType { type: PacketType<*>, _: Int ->
when (factory.phase()!!) {
NetworkPhase.HANDSHAKING -> error("Client bound Packet should have no handshake")
NetworkPhase.PLAY -> playArray.addProperty(type.id().path, i)
NetworkPhase.STATUS -> statusArray.addProperty(type.id().path, i)
NetworkPhase.LOGIN -> loginArray.addProperty(type.id().path, i)
NetworkPhase.CONFIGURATION -> configArray.addProperty(type.id().path, i)
NetworkPhase.PLAY -> playArray.add(type.id().path)
NetworkPhase.STATUS -> statusArray.add(type.id().path)
NetworkPhase.LOGIN -> loginArray.add(type.id().path)
NetworkPhase.CONFIGURATION -> configArray.add(type.id().path)
}
}
}

View File

@ -1,7 +1,7 @@
package de.snowii.extractor.extractors
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import de.snowii.extractor.Extractor
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
@ -13,11 +13,10 @@ class Particles : Extractor.Extractor {
}
override fun extract(server: MinecraftServer): JsonElement {
val particlesJson = JsonObject()
val particlesJson = JsonArray()
for (particle in Registries.PARTICLE_TYPE) {
particlesJson.addProperty(
Registries.PARTICLE_TYPE.getId(particle)!!.toString(),
Registries.PARTICLE_TYPE.getRawId(particle)
particlesJson.add(
Registries.PARTICLE_TYPE.getId(particle)!!.path,
)
}

View File

@ -1,7 +1,7 @@
package de.snowii.extractor.extractors
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import de.snowii.extractor.Extractor
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
@ -12,11 +12,10 @@ class Screens : Extractor.Extractor {
}
override fun extract(server: MinecraftServer): JsonElement {
val screensJson = JsonObject()
val screensJson = JsonArray()
for (screen in Registries.SCREEN_HANDLER) {
screensJson.addProperty(
Registries.SCREEN_HANDLER.getId(screen)!!.toString(),
Registries.SCREEN_HANDLER.getRawId(screen)
screensJson.add(
Registries.SCREEN_HANDLER.getId(screen)!!.path,
)
}

View File

@ -1,7 +1,7 @@
package de.snowii.extractor.extractors
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import de.snowii.extractor.Extractor
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
@ -13,11 +13,10 @@ class Sounds : Extractor.Extractor {
}
override fun extract(server: MinecraftServer): JsonElement {
val soundJson = JsonObject()
val soundJson = JsonArray()
for (sound in Registries.SOUND_EVENT) {
soundJson.addProperty(
Registries.SOUND_EVENT.getId(sound)!!.toString(),
Registries.SOUND_EVENT.getRawId(sound)
soundJson.add(
Registries.SOUND_EVENT.getId(sound)!!.path,
)
}

View File

@ -20,7 +20,7 @@ class SyncedRegistries : Extractor.Extractor {
val json = JsonObject()
registries.forEach { entry ->
json.add(
entry.key().value.toString(),
entry.key().value.path,
mapJson(entry, server.registryManager, server.combinedDynamicRegistries)
)
}
@ -37,7 +37,7 @@ class SyncedRegistries : Extractor.Extractor {
val json = JsonObject()
registry.streamEntries().forEach { entry ->
json.add(
entry.key.orElseThrow().value.toString(),
entry.key.orElseThrow().value.path,
codec.encodeStart(
combinedRegistries.combinedRegistryManager.getOps(JsonOps.INSTANCE),
entry.value()

View File

@ -20,15 +20,15 @@ class Tags : Extractor.Extractor {
for (tag in tags.entries) {
val tagGroupTagsJson = JsonObject()
tagGroupTagsJson.addProperty("name", tag.key.value.toString())
tagGroupTagsJson.addProperty("name", tag.key.value.path)
val tagValues =
tag.value.toRegistryTags(server.combinedDynamicRegistries.combinedRegistryManager.getOrThrow(tag.key))
for (value in tagValues.tags) {
val tagGroupTagsJsonArray = JsonArray()
for (tagVal in value.value) {
tagGroupTagsJsonArray.add(tagVal.key.orElseThrow().value.toString())
tagGroupTagsJsonArray.add(tagVal.key.orElseThrow().value.path)
}
tagGroupTagsJson.add(value.key.id.toString(), tagGroupTagsJsonArray)
tagGroupTagsJson.add(value.key.id.path, tagGroupTagsJsonArray)
}
tagsJson.add(tagGroupTagsJson)
}

View File

@ -20,40 +20,40 @@ pub use open_container::*;
#[repr(u8)]
pub enum WindowType {
// not used
Generic9x1 = screen!("minecraft:generic_9x1"),
Generic9x1 = screen!("generic_9x1"),
// not used
Generic9x2 = screen!("minecraft:generic_9x2"),
Generic9x2 = screen!("generic_9x2"),
// General-purpose 3-row inventory. Used by Chest, minecart with chest, ender chest, and barrel
Generic9x3 = screen!("minecraft:generic_9x3"),
Generic9x3 = screen!("generic_9x3"),
// not used
Generic9x4 = screen!("minecraft:generic_9x4"),
Generic9x4 = screen!("generic_9x4"),
// not used
Generic9x5 = screen!("minecraft:generic_9x5"),
Generic9x5 = screen!("generic_9x5"),
// Used by large chests
Generic9x6 = screen!("minecraft:generic_9x6"),
Generic9x6 = screen!("generic_9x6"),
// General-purpose 3-by-3 square inventory, used by Dispenser and Dropper
Generic3x3 = screen!("minecraft:generic_3x3"),
Generic3x3 = screen!("generic_3x3"),
// General-purpose 3-by-3 square inventory, used by the Crafter
Craft3x3 = screen!("minecraft:crafter_3x3"),
Anvil = screen!("minecraft:anvil"),
Beacon = screen!("minecraft:beacon"),
BlastFurnace = screen!("minecraft:blast_furnace"),
BrewingStand = screen!("minecraft:brewing_stand"),
CraftingTable = screen!("minecraft:crafting"),
EnchantmentTable = screen!("minecraft:enchantment"),
Furnace = screen!("minecraft:furnace"),
Grindstone = screen!("minecraft:grindstone"),
Craft3x3 = screen!("crafter_3x3"),
Anvil = screen!("anvil"),
Beacon = screen!("beacon"),
BlastFurnace = screen!("blast_furnace"),
BrewingStand = screen!("brewing_stand"),
CraftingTable = screen!("crafting"),
EnchantmentTable = screen!("enchantment"),
Furnace = screen!("furnace"),
Grindstone = screen!("grindstone"),
// Hopper or minecart with hopper
Hopper = screen!("minecraft:hopper"),
Lectern = screen!("minecraft:lectern"),
Loom = screen!("minecraft:loom"),
Hopper = screen!("hopper"),
Lectern = screen!("lectern"),
Loom = screen!("loom"),
// Villager, Wandering Trader
Merchant = screen!("minecraft:merchant"),
ShulkerBox = screen!("minecraft:shulker_box"),
SmithingTable = screen!("minecraft:smithing"),
Smoker = screen!("minecraft:smoker"),
CartographyTable = screen!("minecraft:cartography_table"),
Stonecutter = screen!("minecraft:stonecutter"),
Merchant = screen!("merchant"),
ShulkerBox = screen!("shulker_box"),
SmithingTable = screen!("smithing"),
Smoker = screen!("smoker"),
CartographyTable = screen!("cartography_table"),
Stonecutter = screen!("stonecutter"),
}
pub struct ContainerStruct<const SLOTS: usize>([Option<ItemStack>; SLOTS]);

View File

@ -6,8 +6,8 @@ use serde::Deserialize;
#[derive(Deserialize)]
pub struct Packets {
serverbound: HashMap<String, HashMap<String, u8>>,
clientbound: HashMap<String, HashMap<String, u8>>,
serverbound: HashMap<String, Vec<String>>,
clientbound: HashMap<String, Vec<String>>,
}
static PACKETS: LazyLock<Packets> = LazyLock::new(|| {
@ -24,7 +24,10 @@ pub(crate) fn packet_clientbound(item: TokenStream) -> proc_macro2::TokenStream
.get(packet_name_split[0])
.expect("Invalid Phase");
let id = phase
.get(packet_name_split[1])
.iter()
.enumerate()
.find(|s| s.1 == packet_name_split[1])
.map(|(i, _)| i)
.expect("Invalid Packet name");
quote! { #id }
}
@ -39,7 +42,10 @@ pub(crate) fn packet_serverbound(item: TokenStream) -> proc_macro2::TokenStream
.get(packet_name_split[0])
.expect("Invalid Phase");
let id = phase
.get(packet_name_split[1])
.iter()
.enumerate()
.find(|s| s.1 == packet_name_split[1])
.map(|(i, _)| i)
.expect("Invalid Packet name");
quote! { #id }
}

View File

@ -3,15 +3,19 @@ use std::{collections::HashMap, sync::LazyLock};
use proc_macro::TokenStream;
use quote::quote;
static SOUNDS: LazyLock<HashMap<String, u16>> = LazyLock::new(|| {
serde_json::from_str(include_str!("../../assets/particles.json"))
.expect("Could not parse particles.json registry.")
static PARTICLES: LazyLock<HashMap<String, u16>> = LazyLock::new(|| {
serde_json::from_str::<Vec<String>>(include_str!("../../assets/particles.json"))
.expect("Could not parse particles.json registry")
.into_iter()
.enumerate()
.map(|(i, s)| (s, i as u16))
.collect()
});
pub(crate) fn particle_impl(item: TokenStream) -> TokenStream {
let input_string = item.to_string();
let sound_name = input_string.trim_matches('"');
let particle_name = input_string.trim_matches('"');
let id = SOUNDS.get(sound_name).expect("Invalid particle");
let id = *PARTICLES.get(particle_name).expect("Invalid Particle");
quote! { #id }.into()
}

View File

@ -4,14 +4,18 @@ use proc_macro::TokenStream;
use quote::quote;
static SCREENS: LazyLock<HashMap<String, u8>> = LazyLock::new(|| {
serde_json::from_str(include_str!("../../assets/screens.json"))
serde_json::from_str::<Vec<String>>(include_str!("../../assets/screens.json"))
.expect("Could not parse screens.json registry.")
.into_iter()
.enumerate()
.map(|(i, s)| (s, i as u8))
.collect()
});
pub(crate) fn screen_impl(item: TokenStream) -> TokenStream {
let input_string = item.to_string();
let screen_name = input_string.trim_matches('"');
let id = SCREENS.get(screen_name).expect("Invalid screen");
let id = *SCREENS.get(screen_name).expect("Invalid Screen");
quote! { #id }.into()
}

View File

@ -4,14 +4,18 @@ use proc_macro::TokenStream;
use quote::quote;
static SOUNDS: LazyLock<HashMap<String, u16>> = LazyLock::new(|| {
serde_json::from_str(include_str!("../../assets/sounds.json"))
serde_json::from_str::<Vec<String>>(include_str!("../../assets/sounds.json"))
.expect("Could not parse sounds.json registry.")
.into_iter()
.enumerate()
.map(|(i, s)| (s, i as u16))
.collect()
});
pub(crate) fn sound_impl(item: TokenStream) -> TokenStream {
let input_string = item.to_string();
let sound_name = input_string.trim_matches('"');
let id = SOUNDS.get(sound_name).expect("Invalid sound");
let id = *SOUNDS.get(sound_name).expect("Invalid sound");
quote! { #id }.into()
}

View File

@ -47,29 +47,18 @@ pub struct Registry {
#[derive(Serialize, Deserialize)]
pub struct SyncedRegistry {
#[serde(rename = "minecraft:worldgen/biome")]
#[serde(rename = "worldgen/biome")]
biome: IndexMap<String, Biome>,
#[serde(rename = "minecraft:chat_type")]
chat_type: IndexMap<String, ChatType>,
#[serde(rename = "minecraft:trim_pattern")]
trim_pattern: IndexMap<String, TrimPattern>,
#[serde(rename = "minecraft:trim_material")]
trim_material: IndexMap<String, TrimMaterial>,
#[serde(rename = "minecraft:wolf_variant")]
wolf_variant: IndexMap<String, WolfVariant>,
#[serde(rename = "minecraft:painting_variant")]
painting_variant: IndexMap<String, Painting>,
#[serde(rename = "minecraft:dimension_type")]
dimension_type: IndexMap<String, Dimension>,
#[serde(rename = "minecraft:damage_type")]
damage_type: IndexMap<String, DamageType>,
#[serde(rename = "minecraft:banner_pattern")]
banner_pattern: IndexMap<String, BannerPattern>,
#[serde(rename = "minecraft:enchantment")]
enchantment: IndexMap<String, Enchantment>,
#[serde(rename = "minecraft:jukebox_song")]
jukebox_song: IndexMap<String, JukeboxSong>,
#[serde(rename = "minecraft:instrument")]
instrument: IndexMap<String, Instrument>,
}

View File

@ -8,31 +8,31 @@ use crate::IngredientType;
#[derive(Deserialize, Eq, PartialEq, Hash)]
pub enum TagCategory {
#[serde(rename = "minecraft:instrument")]
#[serde(rename = "instrument")]
Instrument,
#[serde(rename = "minecraft:worldgen/biome")]
#[serde(rename = "worldgen/biome")]
WorldGenBiome,
#[serde(rename = "minecraft:point_of_interest_type")]
#[serde(rename = "point_of_interest_type")]
PointOfInterest,
#[serde(rename = "minecraft:entity_type")]
#[serde(rename = "entity_type")]
Entity,
#[serde(rename = "minecraft:damage_type")]
#[serde(rename = "damage_type")]
DamageType,
#[serde(rename = "minecraft:banner_pattern")]
#[serde(rename = "banner_pattern")]
BannerPattern,
#[serde(rename = "minecraft:block")]
#[serde(rename = "block")]
Block,
#[serde(rename = "minecraft:fluid")]
#[serde(rename = "fluid")]
Fluid,
#[serde(rename = "minecraft:enchantment")]
#[serde(rename = "enchantment")]
Enchantment,
#[serde(rename = "minecraft:cat_variant")]
#[serde(rename = "cat_variant")]
Cat,
#[serde(rename = "minecraft:painting_variant")]
#[serde(rename = "painting_variant")]
Painting,
#[serde(rename = "minecraft:item")]
#[serde(rename = "item")]
Item,
#[serde(rename = "minecraft:game_event")]
#[serde(rename = "game_event")]
GameEvent,
}

View File

@ -85,9 +85,9 @@ pub fn get_block_by_item<'a>(item_id: u16) -> Option<&'a Block> {
#[expect(dead_code)]
#[derive(Deserialize, Clone, Debug)]
pub struct TopLevel {
pub blocks: Vec<Block>,
block_entity_types: Vec<String>,
shapes: Vec<Shape>,
block_entity_types: Vec<BlockEntityKind>,
pub blocks: Vec<Block>,
}
#[derive(Deserialize, Clone, Debug)]
pub struct Block {
@ -103,13 +103,6 @@ pub struct Block {
}
#[expect(dead_code)]
#[derive(Deserialize, Clone, Debug)]
struct BlockEntityKind {
id: u32,
ident: String,
name: String,
}
#[expect(dead_code)]
#[derive(Deserialize, Clone, Debug)]
pub struct Property {
name: String,
values: Vec<String>,
@ -128,10 +121,6 @@ pub struct State {
#[expect(dead_code)]
#[derive(Deserialize, Clone, Debug)]
struct Shape {
min_x: f64,
min_y: f64,
min_z: f64,
max_x: f64,
max_y: f64,
max_z: f64,
min: [f32; 3],
max: [f32; 3],
}

View File

@ -33,7 +33,7 @@ mod tests {
#[test]
fn does_exist() {
let result = BlockState::new("minecraft:dirt");
let result = BlockState::new("dirt");
assert!(result.is_some());
}
}

View File

@ -9,7 +9,7 @@ pub static ITEMS: LazyLock<HashMap<String, Item>> = LazyLock::new(|| {
});
pub fn get_item(name: &str) -> Option<&Item> {
ITEMS.get(name)
ITEMS.get(&name.replace("minecraft:", ""))
}
#[derive(Deserialize, Clone, Debug)]

View File

@ -25,10 +25,7 @@ pub fn generate_tree(
y: (chunk_relative_coordinates.y.add(y as i16)).into(),
z: z.add(dz as u8).into(),
};
tree_blocks.push((
block_coordinates,
BlockState::new("minecraft:oak_log").unwrap(),
));
tree_blocks.push((block_coordinates, BlockState::new("oak_log").unwrap()));
}
}
}
@ -43,10 +40,7 @@ pub fn generate_tree(
y: (chunk_relative_coordinates.y.add(y as i16)).into(),
z: z.add(dz as u8).into(),
};
tree_blocks.push((
block_coordinates,
BlockState::new("minecraft:oak_leaves").unwrap(),
));
tree_blocks.push((block_coordinates, BlockState::new("oak_leaves").unwrap()));
}
}
}

View File

@ -55,24 +55,15 @@ impl PerlinTerrainGenerator for PlainsTerrainGenerator {
let y = *at.y;
if y == -64 {
blocks.set_block(
coordinates,
BlockState::new("minecraft:bedrock").unwrap().state_id,
);
blocks.set_block(coordinates, BlockState::new("bedrock").unwrap().state_id);
} else if y >= -63 && y <= begin_stone_height {
blocks.set_block(
coordinates,
BlockState::new("minecraft:stone").unwrap().state_id,
);
blocks.set_block(coordinates, BlockState::new("stone").unwrap().state_id);
} else if y >= begin_stone_height && y < begin_dirt_height {
blocks.set_block(
coordinates,
BlockState::new("minecraft:dirt").unwrap().state_id,
);
blocks.set_block(coordinates, BlockState::new("dirt").unwrap().state_id);
} else if y == chunk_height - 2 {
blocks.set_block(
coordinates,
BlockState::new("minecraft:grass_block").unwrap().state_id,
BlockState::new("grass_block").unwrap().state_id,
);
} else if y == chunk_height - 1 {
// TODO: generate flowers and grass
@ -84,31 +75,29 @@ impl PerlinTerrainGenerator for PlainsTerrainGenerator {
0 => {
blocks.set_block(
coordinates,
BlockState::new("minecraft:dandelion").unwrap().state_id,
BlockState::new("dandelion").unwrap().state_id,
);
}
1 => {
blocks.set_block(
coordinates,
BlockState::new("minecraft:oxeye_daisy").unwrap().state_id,
BlockState::new("oxeye_daisy").unwrap().state_id,
);
}
2 => {
blocks.set_block(
coordinates,
BlockState::new("minecraft:cornflower").unwrap().state_id,
BlockState::new("cornflower").unwrap().state_id,
);
}
3 => {
blocks.set_block(
coordinates,
BlockState::new("minecraft:poppy").unwrap().state_id,
);
blocks
.set_block(coordinates, BlockState::new("poppy").unwrap().state_id);
}
_ => {
blocks.set_block(
coordinates,
BlockState::new("minecraft:azure_bluet").unwrap().state_id,
BlockState::new("azure_bluet").unwrap().state_id,
);
}
}
@ -116,7 +105,7 @@ impl PerlinTerrainGenerator for PlainsTerrainGenerator {
// TODO: Tall grass, Tall grass data called `half`, There is `upper` and `lower`
blocks.set_block(
coordinates,
BlockState::new("minecraft:short_grass").unwrap().state_id,
BlockState::new("short_grass").unwrap().state_id,
);
}
}

View File

@ -42,9 +42,9 @@ impl TerrainGenerator for SuperflatTerrainGenerator {
// TODO allow specifying which blocks should be at which height in the config.
fn generate_block(&self, at: BlockCoordinates, _: Biome) -> BlockState {
match *at.y {
-64 => BlockState::new("minecraft:bedrock").unwrap(),
-63..=-62 => BlockState::new("minecraft:dirt").unwrap(),
-61 => BlockState::new("minecraft:grass_block").unwrap(),
-64 => BlockState::new("bedrock").unwrap(),
-63..=-62 => BlockState::new("dirt").unwrap(),
-61 => BlockState::new("grass_block").unwrap(),
_ => BlockState::AIR,
}
}

View File

@ -113,7 +113,7 @@ pub async fn spawn_sweep_particle(attacker_entity: &Entity, world: &World, pos:
0.0,
0.0,
0,
VarInt(i32::from(particle!("minecraft:sweep_attack"))), // sweep
VarInt(i32::from(particle!("sweep_attack"))), // sweep
&[],
))
.await;
@ -124,7 +124,7 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
AttackType::Knockback => {
world
.play_sound(
sound!("minecraft:entity.player.attack.knockback"),
sound!("entity.player.attack.knockback"),
SoundCategory::Players,
pos,
)
@ -133,7 +133,7 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
AttackType::Critical => {
world
.play_sound(
sound!("minecraft:entity.player.attack.crit"),
sound!("entity.player.attack.crit"),
SoundCategory::Players,
pos,
)
@ -142,7 +142,7 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
AttackType::Sweeping => {
world
.play_sound(
sound!("minecraft:entity.player.attack.sweep"),
sound!("entity.player.attack.sweep"),
SoundCategory::Players,
pos,
)
@ -151,7 +151,7 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
AttackType::Strong => {
world
.play_sound(
sound!("minecraft:entity.player.attack.strong"),
sound!("entity.player.attack.strong"),
SoundCategory::Players,
pos,
)
@ -160,7 +160,7 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
AttackType::Weak => {
world
.play_sound(
sound!("minecraft:entity.player.attack.weak"),
sound!("entity.player.attack.weak"),
SoundCategory::Players,
pos,
)

View File

@ -368,7 +368,7 @@ impl Player {
{
world
.play_sound(
sound!("minecraft:entity.player.attack.nodamage"),
sound!("entity.player.attack.nodamage"),
SoundCategory::Players,
&pos,
)
@ -377,11 +377,7 @@ impl Player {
}
world
.play_sound(
sound!("minecraft:entity.player.hurt"),
SoundCategory::Players,
&pos,
)
.play_sound(sound!("entity.player.hurt"), SoundCategory::Players, &pos)
.await;
let attack_type = AttackType::new(self, attack_cooldown_progress).await;