@@ -858,24 +858,24 @@ func (s *Session) RemoveAllDebugShapes() {
858858
859859// SendDebugShapes sends any pending additions/removals of debug shapes to the player. Shapes should be sent
860860// every tick to allow for batching and time-efficient updates.
861- func (s * Session ) SendDebugShapes () {
861+ func (s * Session ) SendDebugShapes (dim world. Dimension ) {
862862 s .debugShapesMu .Lock ()
863863 defer s .debugShapesMu .Unlock ()
864864
865865 if len (s .debugShapesAdd ) == 0 && len (s .debugShapesRemove ) == 0 {
866866 return
867867 }
868868
869- shapes := make ([]packet .DebugDrawerShape , 0 , len (s .debugShapesAdd )+ len (s .debugShapesRemove ))
869+ shapes := make ([]protocol .DebugDrawerShape , 0 , len (s .debugShapesAdd )+ len (s .debugShapesRemove ))
870870loop:
871871 for {
872872 select {
873873 case shape := <- s .debugShapesAdd :
874874 s .debugShapes [shape .ShapeID ()] = shape
875- shapes = append (shapes , s .debugShapeToProtocol (shape ))
875+ shapes = append (shapes , s .debugShapeToProtocol (shape , dim ))
876876 case id := <- s .debugShapesRemove :
877877 delete (s .debugShapes , id )
878- shapes = append (shapes , packet .DebugDrawerShape {NetworkID : uint64 (id )})
878+ shapes = append (shapes , protocol .DebugDrawerShape {NetworkID : uint64 (id ), DimensionID : s . dimensionID ( dim )})
879879 default :
880880 break loop
881881 }
@@ -885,46 +885,51 @@ loop:
885885
886886// debugShapeToProtocol converts a debug shape to its protocol representation. It also provides defaults
887887// for some fields such as colour, scale and other per-shape properties.
888- func (s * Session ) debugShapeToProtocol (shape debug.Shape ) packet.DebugDrawerShape {
889- ps := packet.DebugDrawerShape {NetworkID : uint64 (shape .ShapeID ())}
888+ func (s * Session ) debugShapeToProtocol (shape debug.Shape , dim world.Dimension ) protocol.DebugDrawerShape {
889+ ps := protocol.DebugDrawerShape {
890+ NetworkID : uint64 (shape .ShapeID ()),
891+ DimensionID : s .dimensionID (dim ),
892+ }
890893 white := color.RGBA {R : 255 , G : 255 , B : 255 , A : 255 }
891894 switch shape := shape .(type ) {
892895 case * debug.Arrow :
893- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeArrow ))
896+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeArrow ))
894897 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
895898 ps .Location = protocol .Option (vec64To32 (shape .Position ))
896- ps .LineEndLocation = protocol .Option (vec64To32 (shape .EndPosition ))
897- ps .ArrowHeadLength = protocol .Option (valueOrDefault (float32 (shape .HeadLength ), 1 ))
898- ps .ArrowHeadRadius = protocol .Option (valueOrDefault (float32 (shape .HeadRadius ), 0.5 ))
899- ps .Segments = protocol .Option (valueOrDefault (uint8 (shape .HeadSegments ), 4 ))
899+ ps .ExtraShapeData = & protocol.ArrowShape {
900+ ArrowEndLocation : protocol .Option (vec64To32 (shape .EndPosition )),
901+ ArrowHeadLength : protocol .Option (valueOrDefault (float32 (shape .HeadLength ), 1 )),
902+ ArrowHeadRadius : protocol .Option (valueOrDefault (float32 (shape .HeadRadius ), 0.5 )),
903+ Segments : protocol .Option (valueOrDefault (uint8 (shape .HeadSegments ), 4 )),
904+ }
900905 case * debug.Box :
901- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeBox ))
906+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeBox ))
902907 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
903- ps .BoxBound = protocol .Option (valueOrDefault (vec64To32 (shape .Bounds ), mgl32.Vec3 {1 , 1 , 1 }))
904908 ps .Location = protocol .Option (vec64To32 (shape .Position ))
905909 ps .Scale = protocol .Option (valueOrDefault (float32 (shape .Scale ), 1 ))
910+ ps .ExtraShapeData = & protocol.BoxShape {BoxBound : valueOrDefault (vec64To32 (shape .Bounds ), mgl32.Vec3 {1 , 1 , 1 })}
906911 case * debug.Circle :
907- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeCircle ))
912+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeCircle ))
908913 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
909914 ps .Location = protocol .Option (vec64To32 (shape .Position ))
910915 ps .Scale = protocol .Option (valueOrDefault (float32 (shape .Scale ), 1 ))
911- ps .Segments = protocol .Option ( valueOrDefault (uint8 (shape .Segments ), 20 ))
916+ ps .ExtraShapeData = & protocol.SphereShape { Segments : valueOrDefault (uint8 (shape .Segments ), 20 )}
912917 case * debug.Line :
913- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeLine ))
918+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeLine ))
914919 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
915920 ps .Location = protocol .Option (vec64To32 (shape .Position ))
916- ps .LineEndLocation = protocol .Option ( vec64To32 (shape .EndPosition ))
921+ ps .ExtraShapeData = & protocol.LineShape { LineEndLocation : vec64To32 (shape .EndPosition )}
917922 case * debug.Sphere :
918- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeSphere ))
923+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeSphere ))
919924 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
920925 ps .Location = protocol .Option (vec64To32 (shape .Position ))
921926 ps .Scale = protocol .Option (valueOrDefault (float32 (shape .Scale ), 1 ))
922- ps .Segments = protocol .Option ( valueOrDefault (uint8 (shape .Segments ), 20 ))
927+ ps .ExtraShapeData = & protocol.SphereShape { Segments : valueOrDefault (uint8 (shape .Segments ), 20 )}
923928 case * debug.Text :
924- ps .Type = protocol .Option (uint8 (packet . ScriptDebugShapeText ))
929+ ps .Type = protocol .Option (uint8 (protocol . DebugDrawerShapeText ))
925930 ps .Colour = protocol .Option (valueOrDefault (shape .Colour , white ))
926931 ps .Location = protocol .Option (vec64To32 (shape .Position ))
927- ps .Text = protocol .Option ( shape .Text )
932+ ps .ExtraShapeData = & protocol.TextShape { Text : shape .Text }
928933 default :
929934 panic (fmt .Sprintf ("unknown debug shape type %T" , shape ))
930935 }
0 commit comments