CustomiesDevs / Customies

A PocketMine-MP plugin that implements support for custom blocks, items and entities.
MIT License
112 stars 52 forks source link

RenderOffset could be better #114

Open dadodasyra opened 10 months ago

dadodasyra commented 10 months ago

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;
    }
}
Faer12312333 commented 7 months ago

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 commented 7 months ago

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 ?