Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c078f1
commit 59cac89
Showing
20 changed files
with
337 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package protocol | ||
|
||
const ( | ||
AbilityBuild = 1 << iota | ||
AbilityMine | ||
AbilityDoorsAndSwitches | ||
AbilityOpenContainers | ||
AbilityAttackPlayers | ||
AbilityAttackMobs | ||
AbilityOperatorCommands | ||
AbilityTeleport | ||
AbilityInvulnerable | ||
AbilityFlying | ||
AbilityMayFly | ||
AbilityInstantBuild | ||
AbilityLightning | ||
AbilityFlySpeed | ||
AbilityWalkSpeed | ||
AbilityMuted | ||
AbilityWorldBuilder | ||
AbilityNoClip | ||
AbilityCount | ||
) | ||
|
||
const ( | ||
AbilityLayerTypeCustomCache = iota | ||
AbilityLayerTypeBase | ||
AbilityLayerTypeSpectator | ||
AbilityLayerTypeCommands | ||
) | ||
|
||
const ( | ||
AbilityBaseFlySpeed = 0.05 | ||
AbilityBaseWalkSpeed = 0.1 | ||
) | ||
|
||
// AbilityLayer represents the abilities of a specific layer, such as the base layer or the spectator layer. | ||
type AbilityLayer struct { | ||
// Type represents the type of the layer. This is one of the AbilityLayerType constants defined above. | ||
Type uint16 | ||
// Abilities is a set of abilities that are enabled for the layer. This is one of the Ability constants defined | ||
// above. | ||
Abilities uint32 | ||
// Values is a set of values that are associated with the enabled abilities, representing the values of the | ||
// abilities. | ||
Values uint32 | ||
// FlySpeed is the default fly speed of the layer. | ||
FlySpeed float32 | ||
// WalkSpeed is the default walk speed of the layer. | ||
WalkSpeed float32 | ||
} | ||
|
||
// SerializedLayer reads/writes a AbilityLayer x using IO r. | ||
func SerializedLayer(r IO, x *AbilityLayer) { | ||
r.Uint16(&x.Type) | ||
r.Uint32(&x.Abilities) | ||
r.Uint32(&x.Values) | ||
r.Float32(&x.FlySpeed) | ||
r.Float32(&x.WalkSpeed) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package packet | ||
|
||
import ( | ||
"github.com/sandertv/gophertunnel/minecraft/protocol" | ||
) | ||
|
||
// DeathInfo is a packet sent from the server to the client expected to be sent when a player dies. It contains messages | ||
// related to the player's death, which are shown on the death screen as of v1.19.10. | ||
type DeathInfo struct { | ||
// Cause is the cause of the player's death, such as "suffocation" or "suicide". | ||
Cause string | ||
// Messages is a list of death messages to be shown on the death screen. | ||
Messages []string | ||
} | ||
|
||
// ID ... | ||
func (*DeathInfo) ID() uint32 { | ||
return IDDeathInfo | ||
} | ||
|
||
// Marshal ... | ||
func (pk *DeathInfo) Marshal(w *protocol.Writer) { | ||
w.String(&pk.Cause) | ||
messageLen := uint32(len(pk.Messages)) | ||
w.Varuint32(&messageLen) | ||
for _, message := range pk.Messages { | ||
w.String(&message) | ||
} | ||
} | ||
|
||
// Unmarshal ... | ||
func (pk *DeathInfo) Unmarshal(r *protocol.Reader) { | ||
r.String(&pk.Cause) | ||
var messageLen uint32 | ||
r.Varuint32(&messageLen) | ||
pk.Messages = make([]string, messageLen) | ||
for i := uint32(0); i < messageLen; i++ { | ||
r.String(&pk.Messages[i]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package packet | ||
|
||
import ( | ||
"github.com/sandertv/gophertunnel/minecraft/nbt" | ||
"github.com/sandertv/gophertunnel/minecraft/protocol" | ||
) | ||
|
||
// EditorNetwork is a packet sent from the server to the client and vise-versa to communicate editor-mode related | ||
// information. It carries a single compound tag containing the relevant information. | ||
type EditorNetwork struct { | ||
// Payload is a network little endian compound tag holding data relevant to the editor. | ||
Payload map[string]any | ||
} | ||
|
||
// ID ... | ||
func (*EditorNetwork) ID() uint32 { | ||
return IDEditorNetwork | ||
} | ||
|
||
// Marshal ... | ||
func (pk *EditorNetwork) Marshal(w *protocol.Writer) { | ||
w.NBT(&pk.Payload, nbt.NetworkLittleEndian) | ||
} | ||
|
||
// Unmarshal ... | ||
func (pk *EditorNetwork) Unmarshal(r *protocol.Reader) { | ||
r.NBT(&pk.Payload, nbt.NetworkLittleEndian) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.