Customies icon indicating copy to clipboard operation
Customies copied to clipboard

RenderOffset could be better

Open dadodasyra opened this issue 2 years ago • 2 comments

Based on https://github.com/MedicalJewel105/bedrock-render-offsets-generator/blob/main/main.py work. We can improve RenderOffsetsComponent that is not accurate with vanilla actually.

<?php
declare(strict_types=1);

namespace customiesdevs\customies\item\component;


final class RenderOffsetsComponent implements ItemComponent { //thanks to https://github.com/MedicalJewel105/bedrock-render-offsets-generator/blob/main/main.py

	private int $textureSize;

	public function __construct(int $textureSize) {
		$this->textureSize = $textureSize;
	}

	public function getName(): string {
		return "minecraft:render_offsets";
	}

	public function getValue(): array {
        $textureSize = $this->textureSize;
        $mainHand_fp = round(0.039 * 16 / $textureSize, 8);
        $offhand_fp = round(0.065 * 16 / $textureSize, 8);
        $mainHand_tp = $offhand_tp = round(0.0965 * 16 / $textureSize, 8);

		return [
			"main_hand" => [
                "first_person" => [
                    "scale" => [$mainHand_fp, $mainHand_fp, $mainHand_fp],
                ],
                "third_person" => [
                    "scale" => [$mainHand_tp, $mainHand_tp, $mainHand_tp]
                ]
            ],
			"off_hand" => [
                "first_person" => [
                    "scale" => [$offhand_fp, $offhand_fp, $offhand_fp],
                ],
                "third_person" => [
                    "scale" => [$offhand_tp, $offhand_tp, $offhand_tp]
                ]
            ]
		];
	}

	public function isProperty(): bool {
		return false;
	}
}

dadodasyra avatar Nov 28 '23 19:11 dadodasyra

The final values should be divided by 2

    $perspectives = [
        "first_person" => [
            "scale" => [$horizontal / 2, $vertical / 2, $horizontal / 2]
        ],
        "third_person" => [
            "scale" => [$horizontal , $vertical , $horizontal]
        ]
    ]

Faer12312333 avatar Feb 23 '24 07:02 Faer12312333

The final values should be divided by 2

    $perspectives = [
        "first_person" => [
            "scale" => [$horizontal / 2, $vertical / 2, $horizontal / 2]
        ],
        "third_person" => [
            "scale" => [$horizontal , $vertical , $horizontal]
        ]
    ]

Why ? based on ?

dadodasyra avatar Feb 23 '24 20:02 dadodasyra

See #144

dadodasyra avatar Feb 12 '25 20:02 dadodasyra