ItemEntity

Accasua

Пользователь
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
 
Top