Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 25, 2024
1 parent 6d20834 commit 7e7eeb0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions handlers/worlds/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ func (w *worldsHandler) saveWorldState(worldState *worldstate.World) error {
if err != nil {
return nil, err
}

return &w.serverState.behaviorPack.Manifest.Header, nil
}
return nil, nil
})
Expand Down
27 changes: 27 additions & 0 deletions utils/behaviourpack/custom_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type description struct {
Properties map[string]any `json:"properties,omitempty"`
MenuCategory menuCategory `json:"menu_category,omitempty"`
Traits map[string]Trait `json:"traits,omitempty"`
States map[string]any `json:"states,omitempty"`
}

type menuCategory struct {
Expand Down Expand Up @@ -243,6 +244,32 @@ func parseBlock(block protocol.BlockEntry) MinecraftBlock {
entry.Components = components
}

if properties, ok := block.Properties["properties"].([]any); ok {
entry.Description.States = make(map[string]any)
for _, property := range properties {
property := property.(map[string]any)
name, ok := property["name"].(string)
if !ok {
continue
}

var enum2 []any
enum, ok := property["enum"].([]any)
if ok {
enum2 = enum
} else {
enum, ok := property["enum"].([]uint8)
if ok {
for _, v := range enum {
enum2 = append(enum2, v != 0)
}
}
}

entry.Description.States[name] = enum2
}
}

if menu_category, ok := block.Properties["menu_category"].(map[string]any); ok {
entry.Description.MenuCategory = menu_category_from_map(menu_category)
}
Expand Down
3 changes: 3 additions & 0 deletions utils/proxy/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func (p *Context) connect(ctx context.Context, connect *utils.ConnectInfo) (err
p.handlers.OnSessionEnd()

if err, ok := err.(*errTransfer); ok {
if connect.Replay != "" {
return nil
}
address := fmt.Sprintf("%s:%d", err.transfer.Address, err.transfer.Port)
logrus.Infof("transferring to %s", address)
return p.connect(ctx, &utils.ConnectInfo{
Expand Down

0 comments on commit 7e7eeb0

Please sign in to comment.