Skip to content

Commit

Permalink
iteminternal/components.go: Remove deprecated minecraft:render_offset…
Browse files Browse the repository at this point in the history
…s component (#996)
  • Loading branch information
xNatsuri authored Jan 19, 2025
1 parent 6fbcb9e commit 6654b25
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions server/internal/iteminternal/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,5 @@ func Components(it world.CustomItem) map[string]any {
if x, ok := it.(item.HandEquipped); ok {
builder.AddProperty("hand_equipped", x.HandEquipped())
}
itemScale := calculateItemScale(it)
builder.AddComponent("minecraft:render_offsets", map[string]any{
"main_hand": map[string]any{
"first_person": map[string]any{
"scale": itemScale,
},
"third_person": map[string]any{
"scale": itemScale,
},
},
"off_hand": map[string]any{
"first_person": map[string]any{
"scale": itemScale,
},
"third_person": map[string]any{
"scale": itemScale,
},
},
})

return builder.Construct()
}

// calculateItemScale calculates the scale of the item to be rendered to the player according to the given size.
func calculateItemScale(it world.CustomItem) []float32 {
width := float32(it.Texture().Bounds().Dx())
height := float32(it.Texture().Bounds().Dy())
var x, y, z float32 = 0.1, 0.1, 0.1
if _, ok := it.(item.HandEquipped); ok {
x, y, z = 0.075, 0.125, 0.075
}
newX := x / (width / 16)
newY := y / (height / 16)
newZ := z / (width / 16)
return []float32{newX, newY, newZ}
}

0 comments on commit 6654b25

Please sign in to comment.