add EntityMetadataLoop handling
This commit is contained in:
@@ -2,10 +2,11 @@ package v1_21_11
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/admin-else/strom/nbt"
|
"github.com/admin-else/strom/nbt"
|
||||||
"github.com/admin-else/strom/proto_base"
|
"github.com/admin-else/strom/proto_base"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"io"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ArmorTrimMaterial struct {
|
type ArmorTrimMaterial struct {
|
||||||
@@ -3016,7 +3017,7 @@ type SlotComponentType struct {
|
|||||||
Val string
|
Val string
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "item_model", 100: "cat/variant", 101: "cat/collar", 102: "sheep/color", 103: "shulker/color", 11: "lore", 12: "rarity", 13: "enchantments", 14: "can_place_on", 15: "can_break", 16: "attribute_modifiers", 17: "custom_model_data", 18: "tooltip_display", 19: "repair_cost", 2: "max_damage", 20: "creative_slot_lock", 21: "enchantment_glint_override", 22: "intangible_projectile", 23: "food", 24: "consumable", 25: "use_remainder", 26: "use_cooldown", 27: "damage_resistant", 28: "tool", 29: "weapon", 3: "damage", 30: "attack_range", 31: "enchantable", 32: "equippable", 33: "repairable", 34: "glider", 35: "tooltip_style", 36: "death_protection", 37: "blocks_attacks", 38: "piercing_weapon", 39: "kinetic_weapon", 4: "unbreakable", 40: "swing_animation", 41: "stored_enchantments", 42: "dyed_color", 43: "map_color", 44: "map_id", 45: "map_decorations", 46: "map_post_processing", 47: "charged_projectiles", 48: "bundle_contents", 49: "potion_contents", 5: "use_effects", 50: "potion_duration_scale", 51: "suspicious_stew_effects", 52: "writable_book_content", 53: "written_book_content", 54: "trim", 55: "debug_stick_state", 56: "entity_data", 57: "bucket_entity_data", 58: "block_entity_data", 59: "instrument", 6: "custom_name", 60: "provides_trim_material", 61: "ominous_bottle_amplifier", 62: "jukebox_playable", 63: "provides_banner_patterns", 64: "recipes", 65: "lodestone_tracker", 66: "firework_explosion", 67: "fireworks", 68: "profile", 69: "note_block_sound", 7: "minimum_attack_charge", 70: "banner_patterns", 71: "base_color", 72: "pot_decorations", 73: "container", 74: "block_state", 75: "bees", 76: "lock", 77: "container_loot", 78: "break_sound", 79: "villager/variant", 8: "damage_type", 80: "wolf/variant", 81: "wolf/sound_variant", 82: "wolf/collar", 83: "fox/variant", 84: "salmon/size", 85: "parrot/variant", 86: "tropical_fish/pattern", 87: "tropical_fish/base_color", 88: "tropical_fish/pattern_color", 89: "mooshroom/variant", 9: "item_name", 90: "rabbit/variant", 91: "pig/variant", 92: "cow/variant", 93: "chicken/variant", 94: "zomie_nautilus/variant", 95: "frog/variant", 96: "horse/variant", 97: "painting/variant", 98: "llama/variant", 99: "axolotl/variant"}
|
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "item_model", 100: "cat/variant", 101: "cat/collar", 102: "sheep/color", 103: "shulker/color", 11: "lore", 12: "rarity", 13: "enchantments", 14: "can_place_on", 15: "can_break", 16: "attribute_modifiers", 17: "custom_model_data", 18: "tooltip_display", 19: "repair_cost", 2: "max_damage", 20: "creative_slot_lock", 21: "enchantment_glint_override", 22: "intangible_projectile", 23: "food", 24: "consumable", 25: "use_remainder", 26: "use_cooldown", 27: "damage_resistant", 28: "tool", 29: "weapon", 3: "damage", 30: "attack_range", 31: "enchantable", 32: "equippable", 33: "repairable", 34: "glider", 35: "tooltip_style", 36: "death_protection", 37: "blocks_attacks", 38: "piercing_weapon", 39: "kinetic_weapon", 4: "unbreakable", 40: "swing_animation", 41: "stored_enchantments", 42: "dyed_color", 43: "map_color", 44: "map_id", 45: "map_decorations", 46: "map_post_processing", 47: "charged_projectiles", 48: "bundle_contents", 49: "potion_contents", 5: "use_effects", 50: "potion_duration_scale", 51: "suspicious_stew_effects", 52: "writable_book_content", 53: "written_book_content", 54: "trim", 55: "debug_stick_state", 56: "entity_data", 57: "bucket_entity_data", 58: "block_entity_data", 59: "instrument", 6: "custom_name", 60: "provides_trim_material", 61: "ominous_bottle_amplifier", 62: "jukebox_playable", 63: "provides_banner_patterns", 64: "recipes", 65: "lodestone_tracker", 66: "firework_explosion", 67: "fireworks", 68: "profile", 69: "note_block_sound", 7: "minimum_attack_charge", 70: "banner_patterns", 71: "base_color", 72: "pot_decorations", 73: "container", 74: "block_state", 75: "bees", 76: "lock", 77: "container_loot", 78: "break_sound", 79: "villager/variant", 8: "damage_type", 80: "wolf/variant", 81: "wolf/sound_variant", 82: "wolf/collar", 83: "fox/variant", 84: "salmon/size", 85: "parrot/variant", 86: "tropical_fish/pattern", 87: "tropical_fish/base_color", 88: "tropical_fish/pattern_color", 89: "mooshroom/variant", 9: "item_name", 90: "rabbit/variant", 91: "pig/variant", 92: "cow/variant", 93: "chicken/variant", 94: "zombie_nautilus/variant", 95: "frog/variant", 96: "horse/variant", 97: "painting/variant", 98: "llama/variant", 99: "axolotl/variant"}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
||||||
var SlotComponentTypeKey int32
|
var SlotComponentTypeKey int32
|
||||||
@@ -3031,7 +3032,7 @@ func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "item_model": 10, "cat/variant": 100, "cat/collar": 101, "sheep/color": 102, "shulker/color": 103, "lore": 11, "rarity": 12, "enchantments": 13, "can_place_on": 14, "can_break": 15, "attribute_modifiers": 16, "custom_model_data": 17, "tooltip_display": 18, "repair_cost": 19, "max_damage": 2, "creative_slot_lock": 20, "enchantment_glint_override": 21, "intangible_projectile": 22, "food": 23, "consumable": 24, "use_remainder": 25, "use_cooldown": 26, "damage_resistant": 27, "tool": 28, "weapon": 29, "damage": 3, "attack_range": 30, "enchantable": 31, "equippable": 32, "repairable": 33, "glider": 34, "tooltip_style": 35, "death_protection": 36, "blocks_attacks": 37, "piercing_weapon": 38, "kinetic_weapon": 39, "unbreakable": 4, "swing_animation": 40, "stored_enchantments": 41, "dyed_color": 42, "map_color": 43, "map_id": 44, "map_decorations": 45, "map_post_processing": 46, "charged_projectiles": 47, "bundle_contents": 48, "potion_contents": 49, "use_effects": 5, "potion_duration_scale": 50, "suspicious_stew_effects": 51, "writable_book_content": 52, "written_book_content": 53, "trim": 54, "debug_stick_state": 55, "entity_data": 56, "bucket_entity_data": 57, "block_entity_data": 58, "instrument": 59, "custom_name": 6, "provides_trim_material": 60, "ominous_bottle_amplifier": 61, "jukebox_playable": 62, "provides_banner_patterns": 63, "recipes": 64, "lodestone_tracker": 65, "firework_explosion": 66, "fireworks": 67, "profile": 68, "note_block_sound": 69, "minimum_attack_charge": 7, "banner_patterns": 70, "base_color": 71, "pot_decorations": 72, "container": 73, "block_state": 74, "bees": 75, "lock": 76, "container_loot": 77, "break_sound": 78, "villager/variant": 79, "damage_type": 8, "wolf/variant": 80, "wolf/sound_variant": 81, "wolf/collar": 82, "fox/variant": 83, "salmon/size": 84, "parrot/variant": 85, "tropical_fish/pattern": 86, "tropical_fish/base_color": 87, "tropical_fish/pattern_color": 88, "mooshroom/variant": 89, "item_name": 9, "rabbit/variant": 90, "pig/variant": 91, "cow/variant": 92, "chicken/variant": 93, "zomie_nautilus/variant": 94, "frog/variant": 95, "horse/variant": 96, "painting/variant": 97, "llama/variant": 98, "axolotl/variant": 99}
|
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "item_model": 10, "cat/variant": 100, "cat/collar": 101, "sheep/color": 102, "shulker/color": 103, "lore": 11, "rarity": 12, "enchantments": 13, "can_place_on": 14, "can_break": 15, "attribute_modifiers": 16, "custom_model_data": 17, "tooltip_display": 18, "repair_cost": 19, "max_damage": 2, "creative_slot_lock": 20, "enchantment_glint_override": 21, "intangible_projectile": 22, "food": 23, "consumable": 24, "use_remainder": 25, "use_cooldown": 26, "damage_resistant": 27, "tool": 28, "weapon": 29, "damage": 3, "attack_range": 30, "enchantable": 31, "equippable": 32, "repairable": 33, "glider": 34, "tooltip_style": 35, "death_protection": 36, "blocks_attacks": 37, "piercing_weapon": 38, "kinetic_weapon": 39, "unbreakable": 4, "swing_animation": 40, "stored_enchantments": 41, "dyed_color": 42, "map_color": 43, "map_id": 44, "map_decorations": 45, "map_post_processing": 46, "charged_projectiles": 47, "bundle_contents": 48, "potion_contents": 49, "use_effects": 5, "potion_duration_scale": 50, "suspicious_stew_effects": 51, "writable_book_content": 52, "written_book_content": 53, "trim": 54, "debug_stick_state": 55, "entity_data": 56, "bucket_entity_data": 57, "block_entity_data": 58, "instrument": 59, "custom_name": 6, "provides_trim_material": 60, "ominous_bottle_amplifier": 61, "jukebox_playable": 62, "provides_banner_patterns": 63, "recipes": 64, "lodestone_tracker": 65, "firework_explosion": 66, "fireworks": 67, "profile": 68, "note_block_sound": 69, "minimum_attack_charge": 7, "banner_patterns": 70, "base_color": 71, "pot_decorations": 72, "container": 73, "block_state": 74, "bees": 75, "lock": 76, "container_loot": 77, "break_sound": 78, "villager/variant": 79, "damage_type": 8, "wolf/variant": 80, "wolf/sound_variant": 81, "wolf/collar": 82, "fox/variant": 83, "salmon/size": 84, "parrot/variant": 85, "tropical_fish/pattern": 86, "tropical_fish/base_color": 87, "tropical_fish/pattern_color": 88, "mooshroom/variant": 89, "item_name": 9, "rabbit/variant": 90, "pig/variant": 91, "cow/variant": 92, "chicken/variant": 93, "zombie_nautilus/variant": 94, "frog/variant": 95, "horse/variant": 96, "painting/variant": 97, "llama/variant": 98, "axolotl/variant": 99}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
||||||
var vSlotComponentType int32
|
var vSlotComponentType int32
|
||||||
@@ -3497,15 +3498,44 @@ func (ret *CommandNode) Encode(w io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EntityMetadata struct {
|
type EntityMetadata struct {
|
||||||
Val proto_base.ToDo
|
Val map[byte]EntityMetadataEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
||||||
err = proto_base.ToDoError
|
ret.Val = make(map[uint8]EntityMetadataEntry)
|
||||||
|
var id uint8
|
||||||
|
for {
|
||||||
|
err = binary.Read(r, binary.BigEndian, &id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if id == 255 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var entry EntityMetadataEntry
|
||||||
|
err = entry.Decode(r)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret.Val[id] = entry
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
||||||
err = proto_base.ToDoError
|
for k, v := range ret.Val {
|
||||||
|
err = binary.Write(w, binary.BigEndian, k)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = v.Encode(w)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = binary.Write(w, binary.BigEndian, uint8(255))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1951,7 +1951,7 @@ type SlotComponentType struct {
|
|||||||
Val string
|
Val string
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "enchantments", 11: "can_place_on", 12: "can_break", 13: "attribute_modifiers", 14: "custom_model_data", 15: "tooltip_display", 16: "repair_cost", 17: "creative_slot_lock", 18: "enchantment_glint_override", 19: "intangible_projectile", 2: "max_damage", 20: "food", 21: "consumable", 22: "use_remainder", 23: "use_cooldown", 24: "damage_resistant", 25: "tool", 26: "weapon", 27: "enchantable", 28: "equippable", 29: "repairable", 3: "damage", 30: "glider", 31: "tooltip_style", 32: "death_protection", 33: "blocks_attacks", 34: "stored_enchantments", 35: "dyed_color", 36: "map_color", 37: "map_id", 38: "map_decorations", 39: "map_post_processing", 4: "unbreakable", 40: "potion_duration_scale", 41: "charged_projectiles", 42: "bundle_contents", 43: "potion_contents", 44: "suspicious_stew_effects", 45: "writable_book_content", 46: "written_book_content", 47: "trim", 48: "debug_stick_state", 49: "entity_data", 5: "custom_name", 50: "bucket_entity_data", 51: "block_entity_data", 52: "instrument", 53: "provides_trim_material", 54: "ominous_bottle_amplifier", 55: "jukebox_playable", 56: "provides_banner_patterns", 57: "recipes", 58: "lodestone_tracker", 59: "firework_explosion", 6: "item_name", 60: "fireworks", 61: "profile", 62: "note_block_sound", 63: "banner_patterns", 64: "base_color", 65: "pot_decorations", 66: "container", 67: "block_state", 68: "bees", 69: "lock", 7: "item_model", 70: "container_loot", 71: "break_sound", 72: "villager/variant", 73: "wolf/variant", 74: "wolf/sound_variant", 75: "wolf/collar", 76: "fox/variant", 77: "salmon/size", 78: "parrot/variant", 79: "tropical_fish/pattern", 8: "lore", 80: "tropical_fish/base_color", 81: "tropical_fish/pattern_color", 82: "mooshroom/variant", 83: "rabbit/variant", 84: "pig/variant", 85: "cow/variant", 86: "chicken/variant", 87: "frog/variant", 88: "horse/variant", 89: "painting/variant", 9: "rarity", 90: "llama/variant", 91: "axolotl/variant", 92: "cat/variant", 93: "cat/collar", 94: "sheep/color", 95: "shulker/color"}
|
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "enchantments", 11: "can_place_on", 12: "can_break", 13: "attribute_modifiers", 14: "custom_model_data", 15: "tooltip_display", 16: "repair_cost", 17: "creative_slot_lock", 18: "enchantment_glint_override", 19: "intangible_projectile", 2: "max_damage", 20: "food", 21: "consumable", 22: "use_remainder", 23: "use_cooldown", 24: "damage_resistant", 25: "tool", 26: "weapon", 27: "enchantable", 28: "equippable", 29: "repairable", 3: "damage", 30: "glider", 31: "tooltip_style", 32: "death_protection", 33: "blocks_attacks", 34: "stored_enchantments", 35: "dyed_color", 36: "map_color", 37: "map_id", 38: "map_decorations", 39: "map_post_processing", 4: "unbreakable", 40: "charged_projectiles", 41: "bundle_contents", 42: "potion_contents", 43: "potion_duration_scale", 44: "suspicious_stew_effects", 45: "writable_book_content", 46: "written_book_content", 47: "trim", 48: "debug_stick_state", 49: "entity_data", 5: "custom_name", 50: "bucket_entity_data", 51: "block_entity_data", 52: "instrument", 53: "provides_trim_material", 54: "ominous_bottle_amplifier", 55: "jukebox_playable", 56: "provides_banner_patterns", 57: "recipes", 58: "lodestone_tracker", 59: "firework_explosion", 6: "item_name", 60: "fireworks", 61: "profile", 62: "note_block_sound", 63: "banner_patterns", 64: "base_color", 65: "pot_decorations", 66: "container", 67: "block_state", 68: "bees", 69: "lock", 7: "item_model", 70: "container_loot", 71: "break_sound", 72: "villager/variant", 73: "wolf/variant", 74: "wolf/sound_variant", 75: "wolf/collar", 76: "fox/variant", 77: "salmon/size", 78: "parrot/variant", 79: "tropical_fish/pattern", 8: "lore", 80: "tropical_fish/base_color", 81: "tropical_fish/pattern_color", 82: "mooshroom/variant", 83: "rabbit/variant", 84: "pig/variant", 85: "cow/variant", 86: "chicken/variant", 87: "frog/variant", 88: "horse/variant", 89: "painting/variant", 9: "rarity", 90: "llama/variant", 91: "axolotl/variant", 92: "cat/variant", 93: "cat/collar", 94: "sheep/color", 95: "shulker/color"}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
||||||
var SlotComponentTypeKey int32
|
var SlotComponentTypeKey int32
|
||||||
@@ -1966,7 +1966,7 @@ func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "enchantments": 10, "can_place_on": 11, "can_break": 12, "attribute_modifiers": 13, "custom_model_data": 14, "tooltip_display": 15, "repair_cost": 16, "creative_slot_lock": 17, "enchantment_glint_override": 18, "intangible_projectile": 19, "max_damage": 2, "food": 20, "consumable": 21, "use_remainder": 22, "use_cooldown": 23, "damage_resistant": 24, "tool": 25, "weapon": 26, "enchantable": 27, "equippable": 28, "repairable": 29, "damage": 3, "glider": 30, "tooltip_style": 31, "death_protection": 32, "blocks_attacks": 33, "stored_enchantments": 34, "dyed_color": 35, "map_color": 36, "map_id": 37, "map_decorations": 38, "map_post_processing": 39, "unbreakable": 4, "potion_duration_scale": 40, "charged_projectiles": 41, "bundle_contents": 42, "potion_contents": 43, "suspicious_stew_effects": 44, "writable_book_content": 45, "written_book_content": 46, "trim": 47, "debug_stick_state": 48, "entity_data": 49, "custom_name": 5, "bucket_entity_data": 50, "block_entity_data": 51, "instrument": 52, "provides_trim_material": 53, "ominous_bottle_amplifier": 54, "jukebox_playable": 55, "provides_banner_patterns": 56, "recipes": 57, "lodestone_tracker": 58, "firework_explosion": 59, "item_name": 6, "fireworks": 60, "profile": 61, "note_block_sound": 62, "banner_patterns": 63, "base_color": 64, "pot_decorations": 65, "container": 66, "block_state": 67, "bees": 68, "lock": 69, "item_model": 7, "container_loot": 70, "break_sound": 71, "villager/variant": 72, "wolf/variant": 73, "wolf/sound_variant": 74, "wolf/collar": 75, "fox/variant": 76, "salmon/size": 77, "parrot/variant": 78, "tropical_fish/pattern": 79, "lore": 8, "tropical_fish/base_color": 80, "tropical_fish/pattern_color": 81, "mooshroom/variant": 82, "rabbit/variant": 83, "pig/variant": 84, "cow/variant": 85, "chicken/variant": 86, "frog/variant": 87, "horse/variant": 88, "painting/variant": 89, "rarity": 9, "llama/variant": 90, "axolotl/variant": 91, "cat/variant": 92, "cat/collar": 93, "sheep/color": 94, "shulker/color": 95}
|
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "enchantments": 10, "can_place_on": 11, "can_break": 12, "attribute_modifiers": 13, "custom_model_data": 14, "tooltip_display": 15, "repair_cost": 16, "creative_slot_lock": 17, "enchantment_glint_override": 18, "intangible_projectile": 19, "max_damage": 2, "food": 20, "consumable": 21, "use_remainder": 22, "use_cooldown": 23, "damage_resistant": 24, "tool": 25, "weapon": 26, "enchantable": 27, "equippable": 28, "repairable": 29, "damage": 3, "glider": 30, "tooltip_style": 31, "death_protection": 32, "blocks_attacks": 33, "stored_enchantments": 34, "dyed_color": 35, "map_color": 36, "map_id": 37, "map_decorations": 38, "map_post_processing": 39, "unbreakable": 4, "charged_projectiles": 40, "bundle_contents": 41, "potion_contents": 42, "potion_duration_scale": 43, "suspicious_stew_effects": 44, "writable_book_content": 45, "written_book_content": 46, "trim": 47, "debug_stick_state": 48, "entity_data": 49, "custom_name": 5, "bucket_entity_data": 50, "block_entity_data": 51, "instrument": 52, "provides_trim_material": 53, "ominous_bottle_amplifier": 54, "jukebox_playable": 55, "provides_banner_patterns": 56, "recipes": 57, "lodestone_tracker": 58, "firework_explosion": 59, "item_name": 6, "fireworks": 60, "profile": 61, "note_block_sound": 62, "banner_patterns": 63, "base_color": 64, "pot_decorations": 65, "container": 66, "block_state": 67, "bees": 68, "lock": 69, "item_model": 7, "container_loot": 70, "break_sound": 71, "villager/variant": 72, "wolf/variant": 73, "wolf/sound_variant": 74, "wolf/collar": 75, "fox/variant": 76, "salmon/size": 77, "parrot/variant": 78, "tropical_fish/pattern": 79, "lore": 8, "tropical_fish/base_color": 80, "tropical_fish/pattern_color": 81, "mooshroom/variant": 82, "rabbit/variant": 83, "pig/variant": 84, "cow/variant": 85, "chicken/variant": 86, "frog/variant": 87, "horse/variant": 88, "painting/variant": 89, "rarity": 9, "llama/variant": 90, "axolotl/variant": 91, "cat/variant": 92, "cat/collar": 93, "sheep/color": 94, "shulker/color": 95}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
||||||
var vSlotComponentType int32
|
var vSlotComponentType int32
|
||||||
@@ -2432,15 +2432,44 @@ func (ret *CommandNode) Encode(w io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EntityMetadata struct {
|
type EntityMetadata struct {
|
||||||
Val proto_base.ToDo
|
Val map[byte]EntityMetadataEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
||||||
err = proto_base.ToDoError
|
ret.Val = make(map[uint8]EntityMetadataEntry)
|
||||||
|
var id uint8
|
||||||
|
for {
|
||||||
|
err = binary.Read(r, binary.BigEndian, &id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if id == 255 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var entry EntityMetadataEntry
|
||||||
|
err = entry.Decode(r)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret.Val[id] = entry
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
||||||
err = proto_base.ToDoError
|
for k, v := range ret.Val {
|
||||||
|
err = binary.Write(w, binary.BigEndian, k)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = v.Encode(w)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = binary.Write(w, binary.BigEndian, uint8(255))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3786,6 +3815,43 @@ func (ret *Vec3i) Encode(w io.Writer) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Vec3i16 struct {
|
||||||
|
X int16
|
||||||
|
Y int16
|
||||||
|
Z int16
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ret *Vec3i16) Decode(r io.Reader) (err error) {
|
||||||
|
err = binary.Read(r, binary.BigEndian, &ret.X)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = binary.Read(r, binary.BigEndian, &ret.Y)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = binary.Read(r, binary.BigEndian, &ret.Z)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (ret *Vec3i16) Encode(w io.Writer) (err error) {
|
||||||
|
err = binary.Write(w, binary.BigEndian, ret.X)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = binary.Write(w, binary.BigEndian, ret.Y)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = binary.Write(w, binary.BigEndian, ret.Z)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
type Vec4f struct {
|
type Vec4f struct {
|
||||||
X float32
|
X float32
|
||||||
Y float32
|
Y float32
|
||||||
@@ -15115,9 +15181,7 @@ func (ret *PlayToClientPacketEntityUpdateAttributes) Encode(w io.Writer) (err er
|
|||||||
|
|
||||||
type PlayToClientPacketEntityVelocity struct {
|
type PlayToClientPacketEntityVelocity struct {
|
||||||
EntityId int32
|
EntityId int32
|
||||||
VelocityX int16
|
Velocity Vec3i16
|
||||||
VelocityY int16
|
|
||||||
VelocityZ int16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ret *PlayToClientPacketEntityVelocity) Decode(r io.Reader) (err error) {
|
func (ret *PlayToClientPacketEntityVelocity) Decode(r io.Reader) (err error) {
|
||||||
@@ -15125,15 +15189,7 @@ func (ret *PlayToClientPacketEntityVelocity) Decode(r io.Reader) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityX)
|
err = ret.Velocity.Decode(r)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityY)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityZ)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -15144,15 +15200,7 @@ func (ret *PlayToClientPacketEntityVelocity) Encode(w io.Writer) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityX)
|
err = ret.Velocity.Encode(w)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityY)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityZ)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -18871,9 +18919,7 @@ type PlayToClientPacketSpawnEntity struct {
|
|||||||
Yaw int8
|
Yaw int8
|
||||||
HeadPitch int8
|
HeadPitch int8
|
||||||
ObjectData int32
|
ObjectData int32
|
||||||
VelocityX int16
|
Velocity Vec3i16
|
||||||
VelocityY int16
|
|
||||||
VelocityZ int16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ret *PlayToClientPacketSpawnEntity) Decode(r io.Reader) (err error) {
|
func (ret *PlayToClientPacketSpawnEntity) Decode(r io.Reader) (err error) {
|
||||||
@@ -18917,15 +18963,7 @@ func (ret *PlayToClientPacketSpawnEntity) Decode(r io.Reader) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityX)
|
err = ret.Velocity.Decode(r)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityY)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Read(r, binary.BigEndian, &ret.VelocityZ)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -18972,15 +19010,7 @@ func (ret *PlayToClientPacketSpawnEntity) Encode(w io.Writer) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityX)
|
err = ret.Velocity.Encode(w)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityY)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = binary.Write(w, binary.BigEndian, ret.VelocityZ)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2885,7 +2885,7 @@ type SlotComponentType struct {
|
|||||||
Val string
|
Val string
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "enchantments", 11: "can_place_on", 12: "can_break", 13: "attribute_modifiers", 14: "custom_model_data", 15: "tooltip_display", 16: "repair_cost", 17: "creative_slot_lock", 18: "enchantment_glint_override", 19: "intangible_projectile", 2: "max_damage", 20: "food", 21: "consumable", 22: "use_remainder", 23: "use_cooldown", 24: "damage_resistant", 25: "tool", 26: "weapon", 27: "enchantable", 28: "equippable", 29: "repairable", 3: "damage", 30: "glider", 31: "tooltip_style", 32: "death_protection", 33: "blocks_attacks", 34: "stored_enchantments", 35: "dyed_color", 36: "map_color", 37: "map_id", 38: "map_decorations", 39: "map_post_processing", 4: "unbreakable", 40: "potion_duration_scale", 41: "charged_projectiles", 42: "bundle_contents", 43: "potion_contents", 44: "suspicious_stew_effects", 45: "writable_book_content", 46: "written_book_content", 47: "trim", 48: "debug_stick_state", 49: "entity_data", 5: "custom_name", 50: "bucket_entity_data", 51: "block_entity_data", 52: "instrument", 53: "provides_trim_material", 54: "ominous_bottle_amplifier", 55: "jukebox_playable", 56: "provides_banner_patterns", 57: "recipes", 58: "lodestone_tracker", 59: "firework_explosion", 6: "item_name", 60: "fireworks", 61: "profile", 62: "note_block_sound", 63: "banner_patterns", 64: "base_color", 65: "pot_decorations", 66: "container", 67: "block_state", 68: "bees", 69: "lock", 7: "item_model", 70: "container_loot", 71: "break_sound", 72: "villager/variant", 73: "wolf/variant", 74: "wolf/sound_variant", 75: "wolf/collar", 76: "fox/variant", 77: "salmon/size", 78: "parrot/variant", 79: "tropical_fish/pattern", 8: "lore", 80: "tropical_fish/base_color", 81: "tropical_fish/pattern_color", 82: "mooshroom/variant", 83: "rabbit/variant", 84: "pig/variant", 85: "cow/variant", 86: "chicken/variant", 87: "frog/variant", 88: "horse/variant", 89: "painting/variant", 9: "rarity", 90: "llama/variant", 91: "axolotl/variant", 92: "cat/variant", 93: "cat/collar", 94: "sheep/color", 95: "shulker/color"}
|
var SlotComponentTypeMap = map[int32]string{0: "custom_data", 1: "max_stack_size", 10: "enchantments", 11: "can_place_on", 12: "can_break", 13: "attribute_modifiers", 14: "custom_model_data", 15: "tooltip_display", 16: "repair_cost", 17: "creative_slot_lock", 18: "enchantment_glint_override", 19: "intangible_projectile", 2: "max_damage", 20: "food", 21: "consumable", 22: "use_remainder", 23: "use_cooldown", 24: "damage_resistant", 25: "tool", 26: "weapon", 27: "enchantable", 28: "equippable", 29: "repairable", 3: "damage", 30: "glider", 31: "tooltip_style", 32: "death_protection", 33: "blocks_attacks", 34: "stored_enchantments", 35: "dyed_color", 36: "map_color", 37: "map_id", 38: "map_decorations", 39: "map_post_processing", 4: "unbreakable", 40: "charged_projectiles", 41: "bundle_contents", 42: "potion_contents", 43: "potion_duration_scale", 44: "suspicious_stew_effects", 45: "writable_book_content", 46: "written_book_content", 47: "trim", 48: "debug_stick_state", 49: "entity_data", 5: "custom_name", 50: "bucket_entity_data", 51: "block_entity_data", 52: "instrument", 53: "provides_trim_material", 54: "ominous_bottle_amplifier", 55: "jukebox_playable", 56: "provides_banner_patterns", 57: "recipes", 58: "lodestone_tracker", 59: "firework_explosion", 6: "item_name", 60: "fireworks", 61: "profile", 62: "note_block_sound", 63: "banner_patterns", 64: "base_color", 65: "pot_decorations", 66: "container", 67: "block_state", 68: "bees", 69: "lock", 7: "item_model", 70: "container_loot", 71: "break_sound", 72: "villager/variant", 73: "wolf/variant", 74: "wolf/sound_variant", 75: "wolf/collar", 76: "fox/variant", 77: "salmon/size", 78: "parrot/variant", 79: "tropical_fish/pattern", 8: "lore", 80: "tropical_fish/base_color", 81: "tropical_fish/pattern_color", 82: "mooshroom/variant", 83: "rabbit/variant", 84: "pig/variant", 85: "cow/variant", 86: "chicken/variant", 87: "frog/variant", 88: "horse/variant", 89: "painting/variant", 9: "rarity", 90: "llama/variant", 91: "axolotl/variant", 92: "cat/variant", 93: "cat/collar", 94: "sheep/color", 95: "shulker/color"}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
||||||
var SlotComponentTypeKey int32
|
var SlotComponentTypeKey int32
|
||||||
@@ -2900,7 +2900,7 @@ func (ret *SlotComponentType) Decode(r io.Reader) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "enchantments": 10, "can_place_on": 11, "can_break": 12, "attribute_modifiers": 13, "custom_model_data": 14, "tooltip_display": 15, "repair_cost": 16, "creative_slot_lock": 17, "enchantment_glint_override": 18, "intangible_projectile": 19, "max_damage": 2, "food": 20, "consumable": 21, "use_remainder": 22, "use_cooldown": 23, "damage_resistant": 24, "tool": 25, "weapon": 26, "enchantable": 27, "equippable": 28, "repairable": 29, "damage": 3, "glider": 30, "tooltip_style": 31, "death_protection": 32, "blocks_attacks": 33, "stored_enchantments": 34, "dyed_color": 35, "map_color": 36, "map_id": 37, "map_decorations": 38, "map_post_processing": 39, "unbreakable": 4, "potion_duration_scale": 40, "charged_projectiles": 41, "bundle_contents": 42, "potion_contents": 43, "suspicious_stew_effects": 44, "writable_book_content": 45, "written_book_content": 46, "trim": 47, "debug_stick_state": 48, "entity_data": 49, "custom_name": 5, "bucket_entity_data": 50, "block_entity_data": 51, "instrument": 52, "provides_trim_material": 53, "ominous_bottle_amplifier": 54, "jukebox_playable": 55, "provides_banner_patterns": 56, "recipes": 57, "lodestone_tracker": 58, "firework_explosion": 59, "item_name": 6, "fireworks": 60, "profile": 61, "note_block_sound": 62, "banner_patterns": 63, "base_color": 64, "pot_decorations": 65, "container": 66, "block_state": 67, "bees": 68, "lock": 69, "item_model": 7, "container_loot": 70, "break_sound": 71, "villager/variant": 72, "wolf/variant": 73, "wolf/sound_variant": 74, "wolf/collar": 75, "fox/variant": 76, "salmon/size": 77, "parrot/variant": 78, "tropical_fish/pattern": 79, "lore": 8, "tropical_fish/base_color": 80, "tropical_fish/pattern_color": 81, "mooshroom/variant": 82, "rabbit/variant": 83, "pig/variant": 84, "cow/variant": 85, "chicken/variant": 86, "frog/variant": 87, "horse/variant": 88, "painting/variant": 89, "rarity": 9, "llama/variant": 90, "axolotl/variant": 91, "cat/variant": 92, "cat/collar": 93, "sheep/color": 94, "shulker/color": 95}
|
var SlotComponentTypeReverseMap = map[string]int32{"custom_data": 0, "max_stack_size": 1, "enchantments": 10, "can_place_on": 11, "can_break": 12, "attribute_modifiers": 13, "custom_model_data": 14, "tooltip_display": 15, "repair_cost": 16, "creative_slot_lock": 17, "enchantment_glint_override": 18, "intangible_projectile": 19, "max_damage": 2, "food": 20, "consumable": 21, "use_remainder": 22, "use_cooldown": 23, "damage_resistant": 24, "tool": 25, "weapon": 26, "enchantable": 27, "equippable": 28, "repairable": 29, "damage": 3, "glider": 30, "tooltip_style": 31, "death_protection": 32, "blocks_attacks": 33, "stored_enchantments": 34, "dyed_color": 35, "map_color": 36, "map_id": 37, "map_decorations": 38, "map_post_processing": 39, "unbreakable": 4, "charged_projectiles": 40, "bundle_contents": 41, "potion_contents": 42, "potion_duration_scale": 43, "suspicious_stew_effects": 44, "writable_book_content": 45, "written_book_content": 46, "trim": 47, "debug_stick_state": 48, "entity_data": 49, "custom_name": 5, "bucket_entity_data": 50, "block_entity_data": 51, "instrument": 52, "provides_trim_material": 53, "ominous_bottle_amplifier": 54, "jukebox_playable": 55, "provides_banner_patterns": 56, "recipes": 57, "lodestone_tracker": 58, "firework_explosion": 59, "item_name": 6, "fireworks": 60, "profile": 61, "note_block_sound": 62, "banner_patterns": 63, "base_color": 64, "pot_decorations": 65, "container": 66, "block_state": 67, "bees": 68, "lock": 69, "item_model": 7, "container_loot": 70, "break_sound": 71, "villager/variant": 72, "wolf/variant": 73, "wolf/sound_variant": 74, "wolf/collar": 75, "fox/variant": 76, "salmon/size": 77, "parrot/variant": 78, "tropical_fish/pattern": 79, "lore": 8, "tropical_fish/base_color": 80, "tropical_fish/pattern_color": 81, "mooshroom/variant": 82, "rabbit/variant": 83, "pig/variant": 84, "cow/variant": 85, "chicken/variant": 86, "frog/variant": 87, "horse/variant": 88, "painting/variant": 89, "rarity": 9, "llama/variant": 90, "axolotl/variant": 91, "cat/variant": 92, "cat/collar": 93, "sheep/color": 94, "shulker/color": 95}
|
||||||
|
|
||||||
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
func (ret *SlotComponentType) Encode(w io.Writer) (err error) {
|
||||||
var vSlotComponentType int32
|
var vSlotComponentType int32
|
||||||
@@ -3366,15 +3366,44 @@ func (ret *CommandNode) Encode(w io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EntityMetadata struct {
|
type EntityMetadata struct {
|
||||||
Val proto_base.ToDo
|
Val map[byte]EntityMetadataEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
func (ret *EntityMetadata) Decode(r io.Reader) (err error) {
|
||||||
err = proto_base.ToDoError
|
ret.Val = make(map[uint8]EntityMetadataEntry)
|
||||||
|
var id uint8
|
||||||
|
for {
|
||||||
|
err = binary.Read(r, binary.BigEndian, &id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if id == 255 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var entry EntityMetadataEntry
|
||||||
|
err = entry.Decode(r)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret.Val[id] = entry
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
func (ret *EntityMetadata) Encode(w io.Writer) (err error) {
|
||||||
err = proto_base.ToDoError
|
for k, v := range ret.Val {
|
||||||
|
err = binary.Write(w, binary.BigEndian, k)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = v.Encode(w)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = binary.Write(w, binary.BigEndian, uint8(255))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -561,6 +561,57 @@ func VoidDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s [
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EntityMetadataLoopDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s []ast.Stmt, err error) {
|
||||||
|
var data protodef.EntityMetadataLoop
|
||||||
|
err = mapstructure.Decode(dataRaw, &data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
innerType, err := g.VisitType(data.Type)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
assignVts := Assign121(varToSet, Call(Ident("make"), MapType(Ident("uint8"), innerType)))
|
||||||
|
idVar := VarStmt("id", Ident("uint8"))
|
||||||
|
|
||||||
|
decodeIdStatements, err := g.VisitDecoder(Ident("id"), "u8", name)
|
||||||
|
endCheck := If(Equals(Ident("id"), NumLit(data.EndVal)), NewBlockEllipsis(Break()))
|
||||||
|
declEntry := VarStmt("entry", innerType)
|
||||||
|
decodingEntryStmts, err := g.VisitDecoder(Ident("entry"), data.Type, name+"Inner")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assignEntry := Assign121(Index(varToSet, Ident("id")), Ident("entry"))
|
||||||
|
|
||||||
|
var loopStmts []ast.Stmt
|
||||||
|
loopStmts = append(loopStmts, decodeIdStatements...)
|
||||||
|
loopStmts = append(loopStmts, endCheck)
|
||||||
|
loopStmts = append(loopStmts, declEntry)
|
||||||
|
loopStmts = append(loopStmts, decodingEntryStmts...)
|
||||||
|
loopStmts = append(loopStmts, assignEntry)
|
||||||
|
|
||||||
|
s = Stmts(assignVts, idVar, ForStmt(nil, nil, nil, NewBlock(loopStmts)))
|
||||||
|
/*
|
||||||
|
vts = make(map[uint8]{{data.type}})
|
||||||
|
var id uint8
|
||||||
|
for {
|
||||||
|
err = binary.Read(r, binary.BigEndian, &id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if id == {{data.EndId}} {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var data {{type(data.type)}}
|
||||||
|
{{unpack(data.type)}}
|
||||||
|
vts[id] = data
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Generator) RegisterDecoderNatives() {
|
func (g *Generator) RegisterDecoderNatives() {
|
||||||
g.DecoderNatives = map[string]FunctionGeneratorFunc{
|
g.DecoderNatives = map[string]FunctionGeneratorFunc{
|
||||||
"container": ContainerDecoder,
|
"container": ContainerDecoder,
|
||||||
@@ -596,7 +647,7 @@ func (g *Generator) RegisterDecoderNatives() {
|
|||||||
|
|
||||||
"registryEntryHolder": RegistryEntryHolderDecoder,
|
"registryEntryHolder": RegistryEntryHolderDecoder,
|
||||||
"registryEntryHolderSet": ToDoDecoder, // RegistryEntryHolderSetDecoder
|
"registryEntryHolderSet": ToDoDecoder, // RegistryEntryHolderSetDecoder
|
||||||
"entityMetadataLoop": ToDoDecoder,
|
"entityMetadataLoop": EntityMetadataLoopDecoder,
|
||||||
"topBitSetTerminatedArray": ToDoDecoder,
|
"topBitSetTerminatedArray": ToDoDecoder,
|
||||||
"todo": ToDoDecoder,
|
"todo": ToDoDecoder,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,6 +356,46 @@ func VoidEncoder(_ *Generator, _ ast.Expr, _ any, _ string) (s []ast.Stmt, err e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EntityMetadataLoopEncoder(g *Generator, vts ast.Expr, dataRaw any, name string) (s []ast.Stmt, err error) {
|
||||||
|
var data protodef.EntityMetadataLoop
|
||||||
|
err = mapstructure.Decode(dataRaw, &data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
for k, v := range vts.Val {
|
||||||
|
WriteU8(w, uint8(k))
|
||||||
|
WriteData(w, v)
|
||||||
|
}
|
||||||
|
WriteU8(w, 0xFF)
|
||||||
|
*/
|
||||||
|
|
||||||
|
encodeid, err := g.VisitEncoder(Ident("k"), "u8", name)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
encodeV, err := g.VisitEncoder(Ident("v"), data.Type, name)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var innerstmts []ast.Stmt
|
||||||
|
innerstmts = append(innerstmts, encodeid...)
|
||||||
|
innerstmts = append(innerstmts, encodeV...)
|
||||||
|
|
||||||
|
forStmt := ForRangeKV(Ident("k"), Ident("v"), vts, NewBlock(innerstmts))
|
||||||
|
|
||||||
|
encodeEndId, err := g.VisitEncoder(Call(Ident("uint8"), NumLit(data.EndVal)), "u8", name)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s = append(s, forStmt)
|
||||||
|
s = append(s, encodeEndId...)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Generator) RegisterEncoderNatives() {
|
func (g *Generator) RegisterEncoderNatives() {
|
||||||
g.EncoderNatives = map[string]FunctionGeneratorFunc{
|
g.EncoderNatives = map[string]FunctionGeneratorFunc{
|
||||||
"container": ContainerEncoder,
|
"container": ContainerEncoder,
|
||||||
@@ -391,7 +431,7 @@ func (g *Generator) RegisterEncoderNatives() {
|
|||||||
|
|
||||||
"registryEntryHolder": RegistryEntryHolderEncoder,
|
"registryEntryHolder": RegistryEntryHolderEncoder,
|
||||||
"registryEntryHolderSet": ToDoEncoder,
|
"registryEntryHolderSet": ToDoEncoder,
|
||||||
"entityMetadataLoop": ToDoEncoder,
|
"entityMetadataLoop": EntityMetadataLoopEncoder,
|
||||||
"topBitSetTerminatedArray": ToDoEncoder,
|
"topBitSetTerminatedArray": ToDoEncoder,
|
||||||
"todo": ToDoEncoder,
|
"todo": ToDoEncoder,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,20 @@ func VoidType(_ *Generator, _ any) (e ast.Expr, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EntityMetadataLoopType(g *Generator, v any) (e ast.Expr, err error) {
|
||||||
|
var data protodef.EntityMetadataLoop
|
||||||
|
err = mapstructure.Decode(v, &data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
innerType, err := g.VisitType(data.Type)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
e = MapType(Ident("byte"), innerType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Generator) RegisterNatives() {
|
func (g *Generator) RegisterNatives() {
|
||||||
g.Natives = map[string]ExprGeneratorFunc{
|
g.Natives = map[string]ExprGeneratorFunc{
|
||||||
"container": VisitContainerType,
|
"container": VisitContainerType,
|
||||||
@@ -200,7 +214,7 @@ func (g *Generator) RegisterNatives() {
|
|||||||
"f64": MakeIdentVisitor("float64"),
|
"f64": MakeIdentVisitor("float64"),
|
||||||
"registryEntryHolder": MakeIdentVisitor("any"), // Go really fucking needs good tagged unions
|
"registryEntryHolder": MakeIdentVisitor("any"), // Go really fucking needs good tagged unions
|
||||||
"registryEntryHolderSet": MakeIdentVisitor("any"),
|
"registryEntryHolderSet": MakeIdentVisitor("any"),
|
||||||
"entityMetadataLoop": VisitToDoType,
|
"entityMetadataLoop": EntityMetadataLoopType,
|
||||||
"option": VisitOptionType,
|
"option": VisitOptionType,
|
||||||
"switch": MakeIdentVisitor("any"),
|
"switch": MakeIdentVisitor("any"),
|
||||||
"UUID": MakeSelectorVisitor("uuid", "UUID"),
|
"UUID": MakeSelectorVisitor("uuid", "UUID"),
|
||||||
|
|||||||
@@ -329,6 +329,12 @@ func NewBlockEllipsis(statements ...ast.Stmt) *ast.BlockStmt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Break() *ast.BranchStmt {
|
||||||
|
return &ast.BranchStmt{
|
||||||
|
Tok: token.BREAK,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//func MergeBlocks(blocks ...*ast.BlockStmt) *ast.BlockStmt {
|
//func MergeBlocks(blocks ...*ast.BlockStmt) *ast.BlockStmt {
|
||||||
// list := make([]ast.Stmt, 0)
|
// list := make([]ast.Stmt, 0)
|
||||||
// for _, block := range blocks {
|
// for _, block := range blocks {
|
||||||
@@ -382,7 +388,16 @@ func ForRange(K, X ast.Expr, block *ast.BlockStmt) *ast.RangeStmt {
|
|||||||
Tok: token.DEFINE, // ":=" token
|
Tok: token.DEFINE, // ":=" token
|
||||||
Body: block,
|
Body: block,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ForRangeKV(K, V, X ast.Expr, block *ast.BlockStmt) *ast.RangeStmt {
|
||||||
|
return &ast.RangeStmt{
|
||||||
|
Key: K,
|
||||||
|
Value: V,
|
||||||
|
X: X,
|
||||||
|
Tok: token.DEFINE,
|
||||||
|
Body: block,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Index(X, I ast.Expr) *ast.IndexExpr {
|
func Index(X, I ast.Expr) *ast.IndexExpr {
|
||||||
@@ -525,3 +540,12 @@ func Grouping(e ast.Expr) *ast.ParenExpr {
|
|||||||
X: e,
|
X: e,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ForStmt(init ast.Stmt, cond ast.Expr, post ast.Stmt, body *ast.BlockStmt) *ast.ForStmt {
|
||||||
|
return &ast.ForStmt{
|
||||||
|
Init: init,
|
||||||
|
Cond: cond,
|
||||||
|
Post: post,
|
||||||
|
Body: body,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,4 +64,9 @@ type (
|
|||||||
Flags []string
|
Flags []string
|
||||||
Type any
|
Type any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityMetadataLoop struct {
|
||||||
|
EndVal int
|
||||||
|
Type any
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user