Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderOffset could be better #114

Open
dadodasyra opened this issue Nov 28, 2023 · 2 comments · May be fixed by #116
Open

RenderOffset could be better #114

dadodasyra opened this issue Nov 28, 2023 · 2 comments · May be fixed by #116

Comments

@dadodasyra
Copy link

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 dadodasyra linked a pull request Jan 24, 2024 that will close this issue
@Faer12312333
Copy link

Faer12312333 commented Feb 23, 2024

The final values should be divided by 2

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

@dadodasyra
Copy link
Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants