From bc8967ba638a692280f9471146e4160eaefe86e9 Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Tue, 12 Nov 2024 01:13:08 -0800 Subject: [PATCH] block/skull.go: Fix skulls not being correctly registered --- cmd/blockhash/main.go | 2 +- server/block/hash.go | 2 +- server/block/skull.go | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/blockhash/main.go b/cmd/blockhash/main.go index 9a8e8f51f..1f4084a06 100644 --- a/cmd/blockhash/main.go +++ b/cmd/blockhash/main.go @@ -246,7 +246,7 @@ func (b *hashBuilder) ftype(structName, s string, expr ast.Expr, directives map[ case "WoodType", "FlowerType", "DoubleFlowerType", "Colour": // Assuming these were all based on metadata, it should be safe to assume a bit size of 4 for this. return "uint64(" + s + ".Uint8())", 4 - case "CoralType": + case "CoralType", "SkullType": return "uint64(" + s + ".Uint8())", 3 case "AnvilType", "SandstoneType", "PrismarineType", "StoneBricksType", "NetherBricksType", "FroglightType", "WallConnectionType", "BlackstoneType", "DeepslateType", "TallGrassType": return "uint64(" + s + ".Uint8())", 2 diff --git a/server/block/hash.go b/server/block/hash.go index a00692ba3..05bf16d68 100644 --- a/server/block/hash.go +++ b/server/block/hash.go @@ -748,7 +748,7 @@ func (s Sign) Hash() (uint64, uint64) { } func (s Skull) Hash() (uint64, uint64) { - return hashSkull, uint64(s.Attach.FaceUint8()) + return hashSkull, uint64(s.Type.Uint8()) | uint64(s.Attach.FaceUint8())<<3 } func (s Slab) Hash() (uint64, uint64) { diff --git a/server/block/skull.go b/server/block/skull.go index 414fab5d3..62621dabd 100644 --- a/server/block/skull.go +++ b/server/block/skull.go @@ -115,10 +115,13 @@ func (s Skull) EncodeBlock() (string, map[string]interface{}) { // allSkulls ... func allSkulls() (skulls []world.Block) { - for _, f := range cube.HorizontalFaces() { - // A direction of -2 and -1 isn't actually valid, but when encoding the block these are encoded as 0 and 1. We - // can't otherwise represent this properly in an Attachment type. - skulls = append(skulls, Skull{Attach: WallAttachment(f.Direction())}) + for _, t := range SkullTypes() { + for _, f := range cube.HorizontalFaces() { + // A direction of -2 and -1 isn't actually valid, but when encoding the block these are encoded as 0 and 1. We + // can't otherwise represent this properly in an Attachment type. + skulls = append(skulls, Skull{Type: t, Attach: WallAttachment(f.Direction())}) + } + skulls = append(skulls, Skull{Type: t, Attach: StandingAttachment(0)}) } - return append(skulls, Skull{Attach: StandingAttachment(0)}) + return }