ItemEntity

Discussion in 'Разработка плагинов' started by Accasua, 15/11/16.

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
We welcome you on our site. This site is devoted to the Nukkit project and all that is connected with him. Here you can communicate, download plugins, also many other things get acquainted! Register the account right now :3
  1. Accasua

    Accasua Пользователь

    Messages:
    8
    Likes Received:
    0
    Minecraft:
    Accasia
    I want to make an ItemEntity which floats on player's head.


    i wrote code, but it doesn't work.

    Help me plz.. :p

    package buff.BaseEntity;
    import buff.BuffCore;
    import cn.nukkit.Player;
    import cn.nukkit.entity.data.ByteEntityData;
    import cn.nukkit.entity.item.EntityItem;
    import cn.nukkit.item.Item;
    import cn.nukkit.level.format.FullChunk;
    import cn.nukkit.nbt.tag.CompoundTag;
    import cn.nukkit.network.protocol.AddEntityPacket;
    public class BuffItem extends EntityItem{

    public Player player;

    public BuffItem(FullChunk chunk, CompoundTag nbt, Player player, Item item) {
    super(chunk, nbt);
    this.item = item;
    this.player = player;
    }

    @Override
    public boolean onUpdate(int tickes){
    this.motionX = player.x;
    this.motionY = player.y + 2;
    this.motionZ = player.z;
    this.level = player.level;
    this.yaw = 0;
    this.pitch = 0;

    int time = BuffCore.getInstance().getListener().time.get(this.player);
    if(time < 1){
    this.kill();
    this.close();
    return false;
    }
    return true;
    }

    @Override
    public void spawnTo(Player player){
    AddEntityPacket pk = new AddEntityPacket();
    pk.entityRuntimeId = this.getId();
    pk.entityUniqueId = this.getId();
    pk.type = this.getNetworkId();
    pk.x = (float) this.x;
    pk.y = (float) this.y;
    pk.z = (float) this.z;
    pk.speedX = pk.speedY = pk.speedZ = 0;
    pk.yaw = (float) this.yaw;
    pk.pitch = (float) this.pitch;
    pk.metadata = this.dataProperties;
    this.setDataProperty(new ByteEntityData(DATA_FLAG_NO_AI, (byte) 1));
    player.dataPacket(pk);
    }
    }





    sorry for my bad english, and thx!
    :D
     

Share This Page