Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit fd589ea

Browse files
didntpotambienntcooldogedevsmell-of-curryTwistedAsylumMC
authored
Fetch from upstream. (#1)
* packet/level_sound_event.go: Add missing sound event enums (Sandertv#264) * minecraft/conn.go: Introduce Proto() method for accessing a conn's protocol (Sandertv#265) * protocol/events.go: Support the latest events (Sandertv#257) * protocol/trim.go: Fix typos in documentation (Sandertv#255) * packet/compression.go: Update documentation about default compression (Sandertv#260) * packet/event.go: Fix marshaling for Event packet * README.md: Removed Sponsors section. * .github/FUNDING.yml: Remove github funding * minecraft/protocol: Support 1.21.30 * protocol/packet: Update deprecation docs (Sandertv#254) --------- Co-authored-by: ambiennt <[email protected]> Co-authored-by: Doge <[email protected]> Co-authored-by: Smell of curry <[email protected]> Co-authored-by: TwistedAsylumMC <[email protected]> Co-authored-by: Sandertv <[email protected]>
1 parent 026ee37 commit fd589ea

26 files changed

+269
-240
lines changed

.github/FUNDING.yml

-1
This file was deleted.

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ Additionally, a MITM proxy is implemented in the [main.go file](https://github.c
1919
Gophertunnel supports only one version at a time (generally the latest official Minecraft release), but multiple protocols can be supported with the API. Generally, a new
2020
minor version is tagged when gophertunnel supports a new Minecraft version that was not previously supported.
2121

22-
## Sponsors
23-
[![Become Patron](https://img.shields.io/badge/dynamic/json?logo=patreon&style=for-the-badge&color=%23e85b46&label=Patreon&query=data.attributes.patron_count&suffix=%20patrons&url=https%3A%2F%2Fwww.patreon.com%2Fapi%2Fcampaigns%2F2832539)](https://patreon.com/sandertv)
24-
25-
Gophertunnel is sponsored by all my gopher sponsors. A special thanks goes to the Very Important Gophers!
26-
2722
## Contact
2823
[![Chat on Discord](https://img.shields.io/badge/Chat-On%20Discord-738BD7.svg?style=for-the-badge)](https://discord.com/invite/U4kFWHhTNR)
2924

minecraft/conn.go

+6-37
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ func (conn *Conn) GameData() GameData {
234234
return conn.gameData
235235
}
236236

237+
// Proto returns the protocol of the connection.
238+
func (conn *Conn) Proto() Protocol {
239+
return conn.proto
240+
}
241+
237242
// StartGame starts the game for a client that connected to the server. StartGame should be called for a Conn
238243
// obtained using a minecraft.Listener. The game data passed will be used to spawn the player in the world of
239244
// the server. To spawn a Conn obtained from a call to minecraft.Dial(), use Conn.DoSpawn().
@@ -928,19 +933,6 @@ func (conn *Conn) handleClientToServerHandshake() error {
928933
URL: pack.DownloadURL(),
929934
})
930935
}
931-
932-
// If it has behaviours, add it to the behaviour pack list. If not, we add it to the texture packs
933-
// list.
934-
if pack.HasBehaviours() {
935-
behaviourPack := protocol.BehaviourPackInfo{UUID: pack.UUID(), Version: pack.Version(), Size: uint64(pack.Len())}
936-
if pack.HasScripts() {
937-
// One of the resource packs has scripts, so we set HasScripts in the packet to true.
938-
pk.HasScripts = true
939-
behaviourPack.HasScripts = true
940-
}
941-
pk.BehaviourPacks = append(pk.BehaviourPacks, behaviourPack)
942-
continue
943-
}
944936
texturePack := protocol.TexturePackInfo{UUID: pack.UUID(), Version: pack.Version(), Size: uint64(pack.Len())}
945937
if pack.Encrypted() {
946938
texturePack.ContentKey = pack.ContentKey()
@@ -1014,7 +1006,7 @@ func (conn *Conn) handleClientCacheStatus(pk *packet.ClientCacheStatus) error {
10141006
func (conn *Conn) handleResourcePacksInfo(pk *packet.ResourcePacksInfo) error {
10151007
// First create a new resource pack queue with the information in the packet so we can download them
10161008
// properly later.
1017-
totalPacks := len(pk.TexturePacks) + len(pk.BehaviourPacks)
1009+
totalPacks := len(pk.TexturePacks)
10181010
conn.packQueue = &resourcePackQueue{
10191011
packAmount: totalPacks,
10201012
downloadingPacks: make(map[string]downloadingPack),
@@ -1045,29 +1037,6 @@ func (conn *Conn) handleResourcePacksInfo(pk *packet.ResourcePacksInfo) error {
10451037
contentKey: pack.ContentKey,
10461038
}
10471039
}
1048-
for index, pack := range pk.BehaviourPacks {
1049-
if _, ok := conn.packQueue.downloadingPacks[pack.UUID]; ok {
1050-
conn.log.Printf("handle ResourcePacksInfo: duplicate behaviour pack (UUID=%v)\n", pack.UUID)
1051-
conn.packQueue.packAmount--
1052-
continue
1053-
}
1054-
if conn.downloadResourcePack != nil && !conn.downloadResourcePack(uuid.MustParse(pack.UUID), pack.Version, index, totalPacks) {
1055-
conn.ignoredResourcePacks = append(conn.ignoredResourcePacks, exemptedResourcePack{
1056-
uuid: pack.UUID,
1057-
version: pack.Version,
1058-
})
1059-
conn.packQueue.packAmount--
1060-
continue
1061-
}
1062-
// This UUID_Version is a hack Mojang put in place.
1063-
packsToDownload = append(packsToDownload, pack.UUID+"_"+pack.Version)
1064-
conn.packQueue.downloadingPacks[pack.UUID] = downloadingPack{
1065-
size: pack.Size,
1066-
buf: bytes.NewBuffer(make([]byte, 0, pack.Size)),
1067-
newFrag: make(chan []byte),
1068-
contentKey: pack.ContentKey,
1069-
}
1070-
}
10711040

10721041
if len(packsToDownload) != 0 {
10731042
conn.expect(packet.IDResourcePackDataInfo, packet.IDResourcePackChunkData)

minecraft/protocol/attribute.go

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func (x *AttributeValue) Marshal(r IO) {
3939
// holds a default value, maximum and minimum value, name and its current value.
4040
type Attribute struct {
4141
AttributeValue
42+
// DefaultMin is the default minimum value of the attribute. It's not clear why this field must be sent to
43+
// the client, but it is required regardless.
44+
DefaultMin float32
45+
// DefaultMax is the default maximum value of the attribute. It's not clear why this field must be sent to
46+
// the client, but it is required regardless.
47+
DefaultMax float32
4248
// Default is the default value of the attribute. It's not clear why this field must be sent to the
4349
// client, but it is required regardless.
4450
Default float32
@@ -51,6 +57,8 @@ func (x *Attribute) Marshal(r IO) {
5157
r.Float32(&x.Min)
5258
r.Float32(&x.Max)
5359
r.Float32(&x.Value)
60+
r.Float32(&x.DefaultMin)
61+
r.Float32(&x.DefaultMax)
5462
r.Float32(&x.Default)
5563
r.String(&x.Name)
5664
Slice(r, &x.Modifiers)

minecraft/protocol/camera.go

+9
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,15 @@ type CameraPreset struct {
152152
RotX Optional[float32]
153153
// RotY is the default yaw of the camera.
154154
RotY Optional[float32]
155+
// RotationSpeed is the speed at which the camera should rotate.
156+
RotationSpeed Optional[float32]
157+
// SnapToTarget determines whether the camera should snap to the target entity or not.
158+
SnapToTarget Optional[bool]
155159
// ViewOffset is only used in a follow_orbit camera and controls an offset based on a pivot point to the
156160
// player, causing it to be shifted in a certain direction.
157161
ViewOffset Optional[mgl32.Vec2]
162+
// EntityOffset controls the offset from the entity that the camera should be rendered at.
163+
EntityOffset Optional[mgl32.Vec3]
158164
// Radius is only used in a follow_orbit camera and controls how far away from the player the camera should
159165
// be rendered.
160166
Radius Optional[float32]
@@ -174,7 +180,10 @@ func (x *CameraPreset) Marshal(r IO) {
174180
OptionalFunc(r, &x.PosZ, r.Float32)
175181
OptionalFunc(r, &x.RotX, r.Float32)
176182
OptionalFunc(r, &x.RotY, r.Float32)
183+
OptionalFunc(r, &x.RotationSpeed, r.Float32)
184+
OptionalFunc(r, &x.SnapToTarget, r.Bool)
177185
OptionalFunc(r, &x.ViewOffset, r.Vec2)
186+
OptionalFunc(r, &x.EntityOffset, r.Vec3)
178187
OptionalFunc(r, &x.Radius, r.Float32)
179188
OptionalFunc(r, &x.AudioListener, r.Uint8)
180189
OptionalFunc(r, &x.PlayerEffects, r.Bool)

minecraft/protocol/container.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ const (
112112
type FullContainerName struct {
113113
// ContainerID is the ID of the container that the slot was in.
114114
ContainerID byte
115-
// DynamicContainerID is the ID of the container if it is dynamic. If the container is not dynamic, this field is
116-
// set to 0.
117-
DynamicContainerID uint32
115+
// DynamicContainerID is the ID of the container if it is dynamic. If the container is not dynamic, this
116+
// field should be left empty. A non-optional value of 0 is assumed to be non-empty.
117+
DynamicContainerID Optional[uint32]
118118
}
119119

120120
func (x *FullContainerName) Marshal(r IO) {
121121
r.Uint8(&x.ContainerID)
122-
r.Uint32(&x.DynamicContainerID)
122+
OptionalFunc(r, &x.DynamicContainerID, r.Uint32)
123123
}

0 commit comments

Comments
 (0)