Skip to content

Commit 4015fb0

Browse files
committed
Fix legacy block convert failed
1 parent e7a8ca6 commit 4015fb0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

converter/normal_block.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ func (c *converter) SetBlockByStatesString(blockName string, blockStatesString s
5555
// SetBlockLegacy ..
5656
func (c *converter) SetBlockLegacy(blockName string, blockData uint16) error {
5757
copiedStates := make(map[string]any)
58-
if !strings.HasPrefix(blockName, "minecraft:") {
59-
blockName = "minecraft:" + blockName
60-
}
58+
blockName = strings.TrimPrefix(blockName, "minecraft:")
6159

6260
temp, found := blocks.LegacyBlockToRuntimeID(blockName, blockData)
6361
if !found {
6462
newItem := itemupgrader.Upgrade(itemupgrader.ItemMeta{
65-
Name: blockName,
63+
Name: "minecraft:" + blockName,
6664
Meta: int16(blockData),
6765
})
6866
if err := c.SetBlockByStatesString(newItem.Name, "[]"); err != nil {
@@ -71,10 +69,10 @@ func (c *converter) SetBlockLegacy(blockName string, blockData uint16) error {
7169
return nil
7270
}
7371

74-
name, states, _ := blocks.RuntimeIDToState(temp)
75-
maps.Copy(copiedStates, states)
72+
blockName, blockStates, _ := blocks.RuntimeIDToState(temp)
73+
maps.Copy(copiedStates, blockStates)
7674

77-
err := c.SetBlock(name, copiedStates)
75+
err := c.SetBlock(blockName, copiedStates)
7876
if err != nil {
7977
return fmt.Errorf("SetBlockLegacy: %v", err)
8078
}

0 commit comments

Comments
 (0)