c88c7b3
Branches > facts > c88c7b3 > files / src / net / bowmap / protocol / packet / clientbound.clj
Move tags to registry.clj
Commit: c88c7b34c7df6dc086f2156397c771b3cc34dfd6
Parent: 4094297
3 changed files:
src/net/bowmap/protocol/handle.clj view file
@@ -2,13 +2,13 @@ (:require [net.bowmap.protocol.chunk :as chunk] [net.bowmap.protocol.client :as client]+ [net.bowmap.protocol.entity :as entity] [net.bowmap.protocol.packet :as pk] [net.bowmap.protocol.packet.clientbound :as clientbound] [net.bowmap.protocol.packet.registry :as registry] [net.bowmap.protocol.packet.serverbound :as serverbound] [net.bowmap.protocol.registry :as reg] [net.bowmap.protocol.state :as state]- [net.bowmap.protocol.entity :as entity] [net.bowmap.server.gamemode :as gamemode] [net.bowmap.server.player :as player] [net.bowmap.server.position :as position]@@ -52,42 +52,10 @@ :id "core" :version "26.2"}]}]}) -; TODO how to update state here?-; Yield facts from this as well and send 'em in!-; Or well, this can be retried so just use the dosync-(defmethod handle-packet ::serverbound/known-packs [client _]- ; TODO move these tags to the registries namespace- {:packets (conj (vec (registry/registry-packets))- {::pk/id ::clientbound/update-tags- :tagged-registries [{:registry "minecraft:block"- :tags [{:tag-name "bowmap:infiniburn"- :entries []}]}]}-- {::pk/id ::clientbound/update-tags- :tagged-registries [{:registry "minecraft:damage_type"- :tags [{:tag-name "minecraft:is_fire"- :entries []}- {:tag-name "minecraft:is_explosion"- :entries []}- {:tag-name "minecraft:bypasses_shield"- :entries []}]}]}-- {::pk/id ::clientbound/update-tags- :tagged-registries [{:registry "minecraft:banner_pattern"- :tags [{:tag-name "minecraft:pattern_item/bordure_indented" :entries []}- {:tag-name "minecraft:pattern_item/creeper" :entries []}- {:tag-name "minecraft:pattern_item/field_masoned" :entries []}- {:tag-name "minecraft:pattern_item/flow" :entries []}- {:tag-name "minecraft:pattern_item/flower" :entries []}- {:tag-name "minecraft:pattern_item/globe" :entries []}- {:tag-name "minecraft:pattern_item/guster" :entries []}- {:tag-name "minecraft:pattern_item/mojang" :entries []}- {:tag-name "minecraft:pattern_item/piglin" :entries []}- {:tag-name "minecraft:pattern_item/skull" :entries []}]}]}-+(defmethod handle-packet ::serverbound/known-packs [_ _]+ {:packets (conj (registry/registry-and-tag-packets) {::pk/id ::clientbound/finish-config})}) - ; May want this "world" elsewhere, or have some programmatic code to generate it, or implement anvil and go from there? (defn- build-chunk-packets [] (let [pk {::pk/id ::clientbound/chunk-data-and-update-lightsrc/net/bowmap/protocol/packet/registry.clj view file
@@ -12,3 +12,16 @@ ::reg/entries (for [[value] (sort-by val (req! reg/registry-values->ids registry-id))] {::reg/entry-id value ::reg/entry-data (entries value)})}))++(defn tag-packets []+ (for [[registry tags] reg/tags]+ {::pk/id ::clientbound/update-tags+ :tagged-registries [{:registry registry+ :tags (for [tag-name tags]+ {:tag-name tag-name+ ; Tags currently don't support values other than empty+ :entries []})}]}))++(defn registry-and-tag-packets []+ (into (vec (registry-packets))+ (tag-packets)))src/net/bowmap/protocol/registry.clj view file
@@ -193,6 +193,24 @@ :step_sound null-sound :whine_sound null-sound}}}})) +(def tags+ ; Tags don't currently support values cause I haven't needed them+ ; They'd otherwise be {:tag [values]}+ {"block" ["bowmap:infiniburn"]+ "damage_type" ["is_fire"+ "is_explosion"+ "bypasses_shield"]+ "banner_pattern" ["pattern_item/bordure_indented"+ "pattern_item/creeper"+ "pattern_item/field_masoned"+ "pattern_item/flow"+ "pattern_item/flower"+ "pattern_item/globe"+ "pattern_item/guster"+ "pattern_item/mojang"+ "pattern_item/piglin"+ "pattern_item/skull"]})+ (def registry-ids->values (update-vals registries #(zipmap (range) (keys %)))) (def registry-values->ids (update-vals registry-ids->values set/map-invert))