Skip to content

Commit

Permalink
block version wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 26, 2024
1 parent 1aa3647 commit c5c15fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
7 changes: 5 additions & 2 deletions utils/behaviourpack/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ func (bp *Pack) AddBlock(block protocol.BlockEntry) {
if ns == "minecraft" {
return
}

minecraftBlock, version := parseBlock(block)

bp.blocks[block.Name] = &blockBehaviour{
FormatVersion: "1.21.0",
MinecraftBlock: parseBlock(block),
FormatVersion: version,
MinecraftBlock: minecraftBlock,
}
}
24 changes: 13 additions & 11 deletions utils/behaviourpack/custom_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ type MinecraftBlock struct {
Permutations []permutation `json:"permutations,omitempty"`
}

func parseBlock(block protocol.BlockEntry) MinecraftBlock {
func parseBlock(block protocol.BlockEntry) (MinecraftBlock, string) {
version := "1.16.0"
entry := MinecraftBlock{
Description: description{
Identifier: block.Name,
Expand All @@ -58,6 +59,7 @@ func parseBlock(block protocol.BlockEntry) MinecraftBlock {
}

if traits, ok := block.Properties["traits"].([]any); ok {
version = "1.21.0"
entry.Description.Traits = make(map[string]Trait)

for _, traitIn := range traits {
Expand Down Expand Up @@ -134,6 +136,15 @@ func parseBlock(block protocol.BlockEntry) MinecraftBlock {

for k, v := range components {
if v, ok := v.(map[string]any); ok {
if k == "minecraft:friction" {
if friction, ok := v["value"].(float32); ok {
if friction == 0.4 {
delete(components, "minecraft:friction")
}
}
continue
}

// fix missing * instance
if k == "minecraft:material_instances" {
components[k] = processMaterialInstances(v)
Expand Down Expand Up @@ -219,15 +230,6 @@ func parseBlock(block protocol.BlockEntry) MinecraftBlock {
delete(components, k)
continue
}

if k == "minecraft:friction" {
if friction, ok := v.(float32); ok {
if friction == 0.4 {
delete(components, "minecraft:friction")
}
}
continue
}
}
}

Expand Down Expand Up @@ -290,5 +292,5 @@ func parseBlock(block protocol.BlockEntry) MinecraftBlock {
}
}

return entry
return entry, version
}

0 comments on commit c5c15fd

Please sign in to comment.