@@ -78,39 +78,5 @@ func Components(it world.CustomItem) map[string]any {
7878 if x , ok := it .(item.HandEquipped ); ok {
7979 builder .AddProperty ("hand_equipped" , x .HandEquipped ())
8080 }
81- itemScale := calculateItemScale (it )
82- builder .AddComponent ("minecraft:render_offsets" , map [string ]any {
83- "main_hand" : map [string ]any {
84- "first_person" : map [string ]any {
85- "scale" : itemScale ,
86- },
87- "third_person" : map [string ]any {
88- "scale" : itemScale ,
89- },
90- },
91- "off_hand" : map [string ]any {
92- "first_person" : map [string ]any {
93- "scale" : itemScale ,
94- },
95- "third_person" : map [string ]any {
96- "scale" : itemScale ,
97- },
98- },
99- })
100-
10181 return builder .Construct ()
10282}
103-
104- // calculateItemScale calculates the scale of the item to be rendered to the player according to the given size.
105- func calculateItemScale (it world.CustomItem ) []float32 {
106- width := float32 (it .Texture ().Bounds ().Dx ())
107- height := float32 (it .Texture ().Bounds ().Dy ())
108- var x , y , z float32 = 0.1 , 0.1 , 0.1
109- if _ , ok := it .(item.HandEquipped ); ok {
110- x , y , z = 0.075 , 0.125 , 0.075
111- }
112- newX := x / (width / 16 )
113- newY := y / (height / 16 )
114- newZ := z / (width / 16 )
115- return []float32 {newX , newY , newZ }
116- }
0 commit comments