Custom Hitbox

Discussion in 'Plugin Help' started by IvanCraft623, Dec 23, 2020.

  1. IvanCraft623

    IvanCraft623 Witch

    Messages:
    60
    GitHub:
    IvanCraft623
    Hi! I have created a 3d skin and I have skinned a human entity, which brings me the problem that the hitbox of the entity is like that of the human entity and I want to make the hitbox adapt to the size of the skin. is there any way to modify the hitbox?

    Spawn Entity function
    PHP:
        public static function setNPCTomb(Player $player) {
            
    $nbt Entity::createBaseNBT($playernull22);
            
    $dir Murder::getInstance()->getDataFolder() . "Entities" DIRECTORY_SEPARATOR "Skins" DIRECTORY_SEPARATOR "Tomb.png";
            
    $img = @imagecreatefrompng($dir);
            
    $skinbytes '';
            
    $values = (int)@getimagesize($dir)[1];
            for(
    $y 0$y $values$y++) {
                for(
    $x 0$x 64$x++) {
                    
    $bytes = @imagecolorat($img$x$y);
                    
    $a = ((~((int)($bytes >> 24))) << 1) & 0xff;
                    
    $b = ($bytes >> 16) & 0xff;
                    
    $c = ($bytes >> 8) & 0xff;
                    
    $d $bytes 0xff;
                    
    $skinbytes .= chr($b) . chr($c) . chr($d) . chr($a);
                }
            }
            @
    imagedestroy($img);
            
    $skinTag = new CompoundTag("Skin", [
                
    "Name" => new StringTag("Name"$player->getSkin()->getSkinId()),
                
    "Data" => new ByteArrayTag("Data"$skinbytes),
                
    "GeometryName" => new StringTag("GeometryName""geometry.geometry.tomb"),
                
    "GeometryData" => new ByteArrayTag("GeometryData"file_get_contents(Murder::getInstance()->getDataFolder() . "Entities" DIRECTORY_SEPARATOR "Geometries" DIRECTORY_SEPARATOR "TombGeometry.json"))
            ]);
            
    $nbt->setTag($skinTag);
            
    $npc = new MurderTomb($player->getLevel(), $nbt);
            
    $npc->setNameTagAlwaysVisible(false);
            
    $npc->setNameTagVisible(false);
            
    $npc->yaw $player->getYaw();
            
    $npc->spawnToAll();
        }
    Entity Class:
    PHP:
    <?php

    declare(strict_types=1);

    namespace 
    IvanCraft623\MurderMystery\Entity;

    use 
    pocketmine\entity\{MonsterEntityIds};
    use 
    pocketmine\entity\Human;

    class 
    MurderTomb extends Human {

        public function 
    getName() : string {
            return 
    "";
        }
    }
    The entity looks something like this:
    upload_2020-12-23_14-25-52.png
     
  2. OguzhanUmutlu

    OguzhanUmutlu Witch

    Messages:
    53
    GitHub:
    OguzhanUmutlu
    You can use slapper's protocol.
     
  3. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    81
    GitHub:
    ricardomilos384

    PHP:
    <?php

    declare(strict_types=1);

    namespace 
    IvanCraft623\MurderMystery\Entity;

    use 
    pocketmine\entity\{MonsterEntityIds};
    use 
    pocketmine\entity\Human;

    class 
    MurderTomb extends Human {

        public 
    $weight 0.5;
        public 
    $height 0.5;

        public function 
    getName() : string {
            return 
    "";
        }
    }
     
    GamakCZ likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.