ef8193c
Branches > main > ef8193c > files
Keep track of registry ids
Commit: ef8193c1cba9576b77450ec9cd9d1136c705a697
Parent: 6b87d85
2 changed files:
src/net/bowmap/network/packets/registry.clj view file
@@ -6,9 +6,9 @@ ; Not in love with this... (defn registry-packets []- (for [[id m] (partition 2 reg/registries)]+ (for [[registry-id entries] reg/registries] {::pk/id ::clientbound/registry-data- ::reg/id id- ::reg/entries (for [[entry-id data] m]- {::reg/entry-id entry-id- ::reg/entry-data data})}))+ ::reg/id registry-id+ ::reg/entries (for [[value] (sort-by val (req! reg/registry-values->ids registry-id))]+ {::reg/entry-id value+ ::reg/entry-data (entries value)})}))src/net/bowmap/network/registry.clj view file
@@ -1,18 +1,16 @@ (ns net.bowmap.network.registry (:require+ [clojure.set :as set] [net.bowmap.network.chunk :as chunk])) (def null-sound {:sound_id "bowmap:null"}) -;; Some way to keep track of order of these things and make that clear...-;; Probably a map of id -> order?-;; So maybe this needs to be a macro or something idk (let [damage-types ["cactus" "campfire" "cramming" "dragon_breath" "drown" "dry_out" "ender_pearl" "fall" "out_of_world" "fly_into_wall" "freeze" "generic" "generic_kill" "hot_floor" "in_fire" "in_wall" "lava" "lightning_bolt" "magic" "on_fire" "outside_border" "stalagmite" "starve" "sweet_berry_bush" "wither" "spear"]] - (def registries ["worldgen/biome" {"plains" {:has_precipitation false+ (def registries {"worldgen/biome" {"plains" {:has_precipitation false :temperature 1.0 :temperature_modifier "none" :downfall 1.0@@ -193,12 +191,7 @@ :hurt_sound null-sound :pant_sound null-sound :step_sound null-sound- :whine_sound null-sound}}}]))+ :whine_sound null-sound}}}})) -;; Make a map of ids -> order-; This probably has to be per-client since different clients could have different registries-; Actually, that is silly :p-; Make it a global registry and build it from the above data.-#_(defn registry-id- "Function to get the ordered numerical id from a given registry id"- [id])+(def registry-ids->values (update-vals registries #(zipmap (range) (keys %))))+(def registry-values->ids (update-vals registry-ids->values set/map-invert))