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
8a310b2
commit 56ec96a
Showing
16 changed files
with
258 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ const ( | |
DeviceNX | ||
DeviceXBOX | ||
DeviceWP | ||
DeviceLinux | ||
) |
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,41 @@ | ||
package packet | ||
|
||
import ( | ||
"github.com/sandertv/gophertunnel/minecraft/protocol" | ||
) | ||
|
||
const ( | ||
LessonActionStart = iota | ||
LessonActionComplete | ||
LessonActionRestart | ||
) | ||
|
||
// LessonProgress is a packet sent by the server to the client to inform the client of updated progress on a lesson. | ||
// This packet only functions on the Minecraft: Education Edition version of the game. | ||
type LessonProgress struct { | ||
// Identifier is the identifier of the lesson that is being progressed. | ||
Identifier string | ||
// Action is the action the client should perform to show progress. This is one of the constants defined above. | ||
Action uint8 | ||
// Score is the score the client should use when displaying the progress. | ||
Score int32 | ||
} | ||
|
||
// ID ... | ||
func (*LessonProgress) ID() uint32 { | ||
return IDLessonProgress | ||
} | ||
|
||
// Marshal ... | ||
func (pk *LessonProgress) Marshal(w *protocol.Writer) { | ||
w.Uint8(&pk.Action) | ||
w.Varint32(&pk.Score) | ||
w.String(&pk.Identifier) | ||
} | ||
|
||
// Unmarshal ... | ||
func (pk *LessonProgress) Unmarshal(r *protocol.Reader) { | ||
r.Uint8(&pk.Action) | ||
r.Varint32(&pk.Score) | ||
r.String(&pk.Identifier) | ||
} |
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
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,78 @@ | ||
package packet | ||
|
||
import ( | ||
"github.com/sandertv/gophertunnel/minecraft/protocol" | ||
) | ||
|
||
const ( | ||
AbilityBuild = iota | ||
AbilityMine | ||
AbilityDoorsAndSwitches | ||
AbilityOpenContainers | ||
AbilityAttackPlayers | ||
AbilityAttackMobs | ||
AbilityOperatorCommands | ||
AbilityTeleport | ||
AbilityInvulnerable | ||
AbilityFlying | ||
AbilityMayFly | ||
AbilityInstantBuild | ||
AbilityLightning | ||
AbilityFlySpeed | ||
AbilityWalkSpeed | ||
AbilityMuted | ||
AbilityWorldBuilder | ||
AbilityNoClip | ||
AbilityAbilityCount | ||
) | ||
|
||
// RequestAbility is a packet sent by the client to the server to request permission for a specific ability from the | ||
// server. These abilities are defined above. | ||
type RequestAbility struct { | ||
// Ability is the ability that the client is requesting. This is one of the constants defined above. | ||
Ability int32 | ||
// Value represents the value of the ability. This can either be a boolean or a float32, otherwise the writer/reader | ||
// will panic. | ||
Value any | ||
} | ||
|
||
// ID ... | ||
func (*RequestAbility) ID() uint32 { | ||
return IDRequestAbility | ||
} | ||
|
||
// Marshal ... | ||
func (pk *RequestAbility) Marshal(w *protocol.Writer) { | ||
w.Varint32(&pk.Ability) | ||
switch val := pk.Value.(type) { | ||
case bool: | ||
valType, defaultVal := uint8(1), float32(0) | ||
w.Uint8(&valType) | ||
w.Bool(&val) | ||
w.Float32(&defaultVal) | ||
case float32: | ||
valType, defaultVal := uint8(2), false | ||
w.Uint8(&valType) | ||
w.Bool(&defaultVal) | ||
w.Float32(&val) | ||
default: | ||
w.InvalidValue(pk.Value, "ability value type", "must be bool or float32") | ||
} | ||
} | ||
|
||
// Unmarshal ... | ||
func (pk *RequestAbility) Unmarshal(r *protocol.Reader) { | ||
valType, boolVal, floatVal := uint8(0), false, float32(0) | ||
r.Varint32(&pk.Ability) | ||
r.Uint8(&valType) | ||
r.Bool(&boolVal) | ||
r.Float32(&floatVal) | ||
switch valType { | ||
case 1: | ||
pk.Value = boolVal | ||
case 2: | ||
pk.Value = floatVal | ||
default: | ||
r.InvalidValue(valType, "ability value type", "must be bool or float32") | ||
} | ||
} |
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,37 @@ | ||
package packet | ||
|
||
import ( | ||
"github.com/sandertv/gophertunnel/minecraft/protocol" | ||
) | ||
|
||
// RequestPermissions is a packet sent from the client to the server to request permissions that the client does not | ||
// currently have. It can only be sent by operators and host in vanilla Minecraft. | ||
type RequestPermissions struct { | ||
// EntityUniqueID is the unique ID of the player. The unique ID is unique for the entire world and is | ||
// often used in packets. Most servers send an EntityUniqueID equal to the EntityRuntimeID. | ||
EntityUniqueID int64 | ||
// PermissionLevel is the current permission level of the player. This is one of the constants that may be found | ||
// in the AdventureSettings packet. | ||
PermissionLevel uint8 | ||
// RequestedPermissions contains the requested permission flags. | ||
RequestedPermissions uint16 | ||
} | ||
|
||
// ID ... | ||
func (*RequestPermissions) ID() uint32 { | ||
return IDRequestPermissions | ||
} | ||
|
||
// Marshal ... | ||
func (pk *RequestPermissions) Marshal(w *protocol.Writer) { | ||
w.Int64(&pk.EntityUniqueID) | ||
w.Uint8(&pk.PermissionLevel) | ||
w.Uint16(&pk.RequestedPermissions) | ||
} | ||
|
||
// Unmarshal ... | ||
func (pk *RequestPermissions) Unmarshal(r *protocol.Reader) { | ||
r.Int64(&pk.EntityUniqueID) | ||
r.Uint8(&pk.PermissionLevel) | ||
r.Uint16(&pk.RequestedPermissions) | ||
} |
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.