Skip to content

Commit 0582df0

Browse files
Merge branch 'minekube:master' into master
2 parents 6be9ee8 + 2c7e2af commit 0582df0

7 files changed

Lines changed: 77 additions & 113 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/urfave/cli/v2 v2.27.6
3333
github.com/zyedidia/generic v1.2.1
3434
go.minekube.com/brigodier v0.0.1
35-
go.minekube.com/common v0.1.0
35+
go.minekube.com/common v0.2.0
3636
go.minekube.com/connect v0.6.2
3737
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0
3838
go.opentelemetry.io/otel v1.35.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ github.com/zyedidia/generic v1.2.1 h1:Zv5KS/N2m0XZZiuLS82qheRG4X1o5gsWreGb0hR7XD
247247
github.com/zyedidia/generic v1.2.1/go.mod h1:ly2RBz4mnz1yeuVbQA/VFwGjK3mnHGRj1JuoG336Bis=
248248
go.minekube.com/brigodier v0.0.1 h1:v5x+fZNefM24JIi+fYQjQcjZ8rwJbfRSpnnpw4b/x6k=
249249
go.minekube.com/brigodier v0.0.1/go.mod h1:WJf/lyJVTId/phiY6phPW6++qkTjCQ72rbOWqo4XIqc=
250-
go.minekube.com/common v0.1.0 h1:5pjKxBXVvsrZ7s4ORLA1RHqZ1jEcSW5U7W9/pA9DdN4=
251-
go.minekube.com/common v0.1.0/go.mod h1:CKCUOhcDjVWRfn77u3Tp/ECV6l1OQ5WUW5M159pu38M=
250+
go.minekube.com/common v0.2.0 h1:b/4Scd2zXv1VIsbnTLKbTIipyVjmHHG/etMuJkrlJr4=
251+
go.minekube.com/common v0.2.0/go.mod h1:CKCUOhcDjVWRfn77u3Tp/ECV6l1OQ5WUW5M159pu38M=
252252
go.minekube.com/connect v0.6.2 h1:RajPc7YgqygcOviV2g4xetL3J0Wzi8b/lsYXUzIltxE=
253253
go.minekube.com/connect v0.6.2/go.mod h1:28k11I4RyzUfAL3AkOXt3atzjeOFAC8eqbCMwsYKAb0=
254254
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package packet
2+
3+
import (
4+
"io"
5+
6+
"github.com/Tnze/go-mc/nbt"
7+
"go.minekube.com/gate/pkg/edition/java/proto/state/states"
8+
"go.minekube.com/gate/pkg/edition/java/proto/util"
9+
"go.minekube.com/gate/pkg/gate/proto"
10+
)
11+
12+
type DialogClear struct{}
13+
14+
var _ proto.Packet = (*DialogClear)(nil)
15+
16+
func (d *DialogClear) Encode(c *proto.PacketContext, wr io.Writer) error {
17+
return nil
18+
}
19+
20+
func (d *DialogClear) Decode(c *proto.PacketContext, rd io.Reader) error {
21+
return nil
22+
}
23+
24+
type DialogShow struct {
25+
State states.State
26+
ID int
27+
BinaryTag nbt.RawMessage
28+
}
29+
30+
var _ proto.Packet = (*DialogShow)(nil)
31+
32+
func (d *DialogShow) Encode(c *proto.PacketContext, wr io.Writer) error {
33+
if d.State == states.ConfigState {
34+
return util.WriteBinaryTag(wr, c.Protocol, d.BinaryTag)
35+
}
36+
util.PWriteVarInt(wr, d.ID)
37+
if d.ID == 0 {
38+
return util.WriteBinaryTag(wr, c.Protocol, d.BinaryTag)
39+
}
40+
return nil
41+
}
42+
43+
func (d *DialogShow) Decode(c *proto.PacketContext, rd io.Reader) (err error) {
44+
if d.State == states.ConfigState {
45+
d.ID = 0
46+
} else {
47+
d.ID, err = util.ReadVarInt(rd)
48+
if err != nil {
49+
return err
50+
}
51+
}
52+
if d.ID == 0 {
53+
d.BinaryTag, err = util.ReadBinaryTag(rd, c.Protocol)
54+
return err
55+
}
56+
return nil
57+
}

pkg/edition/java/proto/packet/packet_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ var packets = []proto.Packet{
275275
&cookie.CookieRequest{Key: key.New("minecraft", "test")},
276276
&cookie.CookieResponse{Key: key.New("minecraft", "test"), Payload: []byte("payload")},
277277
&cookie.CookieStore{Key: key.New("minecraft", "test"), Payload: []byte("payload")},
278+
&DialogClear{},
279+
&DialogShow{},
278280
}
279281

280282
func generatePlayerKey() crypto.IdentifiedKey {

pkg/edition/java/proto/state/register.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ func init() {
127127
Config.ClientBound.Register(&cookie.CookieStore{},
128128
m(0x0A, version.Minecraft_1_20_5),
129129
)
130+
Config.ClientBound.Register(&p.DialogClear{},
131+
m(0x11, version.Minecraft_1_21_6),
132+
)
133+
Config.ClientBound.Register(&p.DialogShow{},
134+
m(0x12, version.Minecraft_1_21_6),
135+
)
130136

131137
Login.ServerBound.Register(&p.ServerLogin{},
132138
m(0x00, version.Minecraft_1_7_2))

pkg/edition/java/proto/util/chat.go

Lines changed: 8 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -43,121 +43,20 @@ func DefaultJsonCodec() codec.Codec {
4343

4444
var (
4545
// Json component codec supporting pre-1.16 clients
46-
// Equivalent to PRE_1_16_SERIALIZER
47-
jsonCodec_Pre_1_16 = &codec.Json{
48-
UseLegacyFieldNames: true, // EMIT_CLICK_EVENT_TYPE = CAMEL_CASE
49-
UseLegacyClickEventStructure: true, // EMIT_CLICK_EVENT_TYPE = VALUE_FIELD (universal "value")
50-
UseLegacyHoverEventStructure: true, // EMIT_HOVER_EVENT_TYPE = VALUE_FIELD
51-
NoDownsampleColor: false, // EMIT_RGB = FALSE (downsampleColors)
52-
NoLegacyHover: false, // Support legacy hover events
53-
StdJson: true,
54-
/* Equivalent to PRE_1_16_SERIALIZER:
55-
GsonComponentSerializer.builder()
56-
.downsampleColors()
57-
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
58-
.options(
59-
OptionSchema.globalSchema().stateBuilder()
60-
// before 1.16
61-
.value(JSONOptions.EMIT_RGB, Boolean.FALSE)
62-
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.VALUE_FIELD)
63-
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE)
64-
// before 1.20.3
65-
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
66-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
67-
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.FALSE)
68-
.build()
69-
)
70-
.build();
71-
*/
72-
}
46+
// Equivalent to PRE_1_16_SERIALIZER from Adventure
47+
jsonCodec_Pre_1_16 = codec.JsonPre1_16
7348

7449
// Json component codec for 1.16+ clients (pre-1.20.3)
75-
// Equivalent to PRE_1_20_3_SERIALIZER
76-
jsonCodec_Pre_1_20_3 = &codec.Json{
77-
UseLegacyFieldNames: true, // EMIT_CLICK_EVENT_TYPE = CAMEL_CASE
78-
UseLegacyClickEventStructure: true, // EMIT_CLICK_EVENT_TYPE = CAMEL_CASE (universal "value")
79-
UseLegacyHoverEventStructure: true, // EMIT_HOVER_EVENT_TYPE = CAMEL_CASE (contents wrapper)
80-
NoDownsampleColor: true, // EMIT_RGB = TRUE
81-
NoLegacyHover: true, // Modern hover events only
82-
StdJson: true,
83-
/* Equivalent to PRE_1_20_3_SERIALIZER:
84-
GsonComponentSerializer.builder()
85-
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
86-
.options(
87-
OptionSchema.globalSchema().stateBuilder()
88-
// after 1.16
89-
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
90-
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.CAMEL_CASE)
91-
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE)
92-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_KEY_AS_TYPE_AND_UUID_AS_ID, true)
93-
// before 1.20.3
94-
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
95-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
96-
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.FALSE)
97-
.build()
98-
)
99-
.build();
100-
*/
101-
}
50+
// Equivalent to PRE_1_20_3_SERIALIZER from Adventure
51+
jsonCodec_Pre_1_20_3 = codec.JsonPre1_20_3
10252

10353
// Json component codec for 1.20.3+ clients (pre-1.21.5)
104-
// Equivalent to PRE_1_21_5_SERIALIZER
105-
jsonCodec_Pre_1_21_5 = &codec.Json{
106-
UseLegacyFieldNames: true, // EMIT_CLICK_EVENT_TYPE = CAMEL_CASE
107-
UseLegacyClickEventStructure: true, // EMIT_CLICK_EVENT_TYPE = CAMEL_CASE (universal "value")
108-
UseLegacyHoverEventStructure: true, // EMIT_HOVER_EVENT_TYPE = CAMEL_CASE (contents wrapper)
109-
NoDownsampleColor: true, // EMIT_RGB = TRUE
110-
NoLegacyHover: true, // Modern hover events only
111-
StdJson: true,
112-
/* Equivalent to PRE_1_21_5_SERIALIZER:
113-
GsonComponentSerializer.builder()
114-
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
115-
.options(
116-
OptionSchema.globalSchema().stateBuilder()
117-
// after 1.16
118-
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
119-
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.CAMEL_CASE)
120-
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE)
121-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_KEY_AS_TYPE_AND_UUID_AS_ID, true)
122-
// after 1.20.3
123-
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.TRUE)
124-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.TRUE)
125-
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.TRUE)
126-
.build()
127-
)
128-
.build();
129-
*/
130-
}
54+
// Equivalent to PRE_1_21_5_SERIALIZER from Adventure
55+
jsonCodec_Pre_1_21_5 = codec.JsonPre1_21_5
13156

13257
// Json component codec for 1.21.5+ clients (modern format)
133-
// Equivalent to MODERN_SERIALIZER
134-
jsonCodec_Modern = &codec.Json{
135-
UseLegacyFieldNames: false, // EMIT_CLICK_EVENT_TYPE = SNAKE_CASE
136-
UseLegacyClickEventStructure: false, // EMIT_CLICK_EVENT_TYPE = SNAKE_CASE (specific fields)
137-
UseLegacyHoverEventStructure: false, // EMIT_HOVER_EVENT_TYPE = SNAKE_CASE (inlined structure)
138-
NoDownsampleColor: true, // EMIT_RGB = TRUE
139-
NoLegacyHover: true, // Modern hover events only
140-
StdJson: true,
141-
/* Equivalent to MODERN_SERIALIZER:
142-
GsonComponentSerializer.builder()
143-
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
144-
.options(
145-
OptionSchema.globalSchema().stateBuilder()
146-
// after 1.16
147-
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
148-
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.SNAKE_CASE)
149-
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.SNAKE_CASE)
150-
// after 1.20.3
151-
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.TRUE)
152-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.TRUE)
153-
// after 1.21.5
154-
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_KEY_AS_TYPE_AND_UUID_AS_ID, Boolean.FALSE)
155-
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.TRUE)
156-
.build()
157-
)
158-
.build();
159-
*/
160-
}
58+
// Equivalent to MODERN_SERIALIZER from Adventure
59+
jsonCodec_Modern = codec.JsonModern
16160
)
16261

16362
// MarshalPlain marshals a component into plain text.

pkg/edition/java/proto/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var (
4949
Minecraft_1_21_4 = v(769, "1.21.4")
5050
Minecraft_1_21_5 = v(770, "1.21.5")
5151
Minecraft_1_21_6 = v(771, "1.21.6")
52-
Minecraft_1_21_7 = v(772, "1.21.7")
52+
Minecraft_1_21_7 = v(772, "1.21.7", "1.21.8")
5353

5454
// Versions ordered from lowest to highest
5555
Versions = []*proto.Version{

0 commit comments

Comments
 (0)