Refactor item mapping to use dragonflyMapping parameter and remove deleteDebugStick references

This commit is contained in:
AkmalFairuz
2025-07-02 21:53:13 +07:00
parent 0abc5c3694
commit 9b6ddc51fd
16 changed files with 86 additions and 76 deletions

View File

@@ -3,6 +3,7 @@ package legacyver
import (
_ "embed"
"github.com/akmalfairuz/legacy-version/mapping"
"github.com/sandertv/gophertunnel/minecraft/nbt"
)
const (
@@ -17,15 +18,33 @@ var (
requiredItemList818 []byte
//go:embed data/block_states_818.nbt
blockStateData818 []byte
//go:embed data/dragonfly_latest_vanilla_items.nbt
dragonflyLatestVanillaItemsRaw []byte
itemMappingLatestWithDebugStick = mapping.NewItemMapping(requiredItemList818, ItemVersion818, false)
itemMappingLatestWithoutDebugStick = mapping.NewItemMapping(requiredItemList818, ItemVersion818, true)
blockMappingLatest = mapping.NewBlockMapping(blockStateData818)
itemMappingLatestPocketMine = mapping.NewItemMapping(requiredItemList818, ItemVersion818)
itemMappingLatestDragonfly = mapping.NewItemMapping(requiredItemList818, ItemVersion818)
blockMappingLatest = mapping.NewBlockMapping(blockStateData818)
)
func itemMappingLatest(deleteDebugStick bool) mapping.Item {
if deleteDebugStick {
return itemMappingLatestWithoutDebugStick
func init() {
var m map[string]struct {
RuntimeID int32 `nbt:"runtime_id"`
ComponentBased bool `nbt:"component_based"`
Version int32 `nbt:"version"`
Data map[string]any `nbt:"data,omitempty"`
}
if err := nbt.Unmarshal(dragonflyLatestVanillaItemsRaw, &m); err != nil {
panic(err)
}
for identifier, v := range m {
itemMappingLatestDragonfly.SetItemRuntimeID(identifier, v.RuntimeID)
}
return itemMappingLatestWithDebugStick
}
func itemMappingLatest(dragonflyMapping bool) mapping.Item {
if dragonflyMapping {
return itemMappingLatestDragonfly
}
return itemMappingLatestPocketMine
}