1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Remove falling of Item Entity

Discussion in 'Development' started by Kyd, Feb 11, 2018.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    How do I remove falling of item entity?
    I tried it with data flags, but it's not working
    PHP:
    $entity->setDataFlag($entity::DATA_FLAGS16true);
    PHP:
    $entity->setDataFlag($entity::DATA_FLAGS$entity::DATA_FLAG_AFFECTED_BY_GRAVITYfalse);
     
  2. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    To disable client-sided simulation:

    PHP:
    $entity->setGenericFlag(Entity::DATA_FLAG_NO_AI);
    Removing server-side gravity is a bit more tricky, because the server doesn't respect those flags yet. You'd have to register a custom Item class extending \pocketmine\item\Item and override `applyGravity()` with an empty function - or you could set the protected $gravity field to zero.
     
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I overriden gravity field and set it to 0, but item still fall
    PHP:
    <?php

    namespace BedWars\game\entity;
    use 
    pocketmine\entity\Item;

    /**
    * Created by PhpStorm.
    * User: Honza
    * Date: 11.02.2018
    * Time: 14:27
    */

    class DroppedItem extends Item
    {
        protected 
    $gravity 0;

    }
     
  4. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    did you find any way to disable this severity?
     
  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.