Skip to content

Commit

Permalink
Fix player feed particle
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed May 12, 2024
1 parent 101423f commit c04bc89
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import cn.nukkit.network.PacketViolationReason;
import cn.nukkit.network.SourceInterface;
import cn.nukkit.network.protocol.*;
import cn.nukkit.network.protocol.types.CommandOriginData.Origin;
import cn.nukkit.network.protocol.types.ContainerIds;
import cn.nukkit.network.protocol.types.NetworkInventoryAction;
import cn.nukkit.permission.PermissibleBase;
Expand Down Expand Up @@ -3333,11 +3334,17 @@ public void onCompletion(Server server) {
if (entityEventPacket.data == 0 || entityEventPacket.eid != this.id) {
break;
}
entityEventPacket.isEncoded = false;

this.dataPacket(entityEventPacket);
Server.broadcastPacket(this.getViewers().values(), entityEventPacket);
Item held = inventory.getItemInHand();
if (!(held instanceof ItemEdible)) {
break;
}

EntityEventPacket pk = new EntityEventPacket();
pk.eid = getId();
pk.event = EntityEventPacket.EATING_ITEM;
pk.data = (held.getId() << 16) | held.getDamage();
this.dataPacket(pk);
Server.broadcastPacket(this.getViewers().values(), pk);
break;
case EntityEventPacket.ENCHANT:
if (entityEventPacket.eid != this.id) {
Expand Down Expand Up @@ -6429,4 +6436,9 @@ public void swingArm() {
public int getMaxViewDistance() {
return server.getViewDistance();
}

@Override
public Origin getCommandOrigin() {
return Origin.PLAYER;
}
}
4 changes: 4 additions & 0 deletions src/main/java/cn/nukkit/command/CommandSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.nukkit.Server;
import cn.nukkit.lang.TextContainer;
import cn.nukkit.network.protocol.types.CommandOriginData.Origin;
import cn.nukkit.permission.Permissible;

/**
Expand Down Expand Up @@ -68,4 +69,7 @@ public interface CommandSender extends Permissible {

boolean isPlayer();

default Origin getCommandOrigin() {
return Origin.SCRIPT;
}
}
6 changes: 6 additions & 0 deletions src/main/java/cn/nukkit/command/ConsoleCommandSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.nukkit.Server;
import cn.nukkit.lang.TextContainer;
import cn.nukkit.network.protocol.types.CommandOriginData.Origin;
import cn.nukkit.permission.PermissibleBase;
import cn.nukkit.permission.Permission;
import cn.nukkit.permission.PermissionAttachment;
Expand Down Expand Up @@ -109,4 +110,9 @@ public boolean isOp() {
public void setOp(boolean value) {

}

@Override
public Origin getCommandOrigin() {
return Origin.DEDICATED_SERVER;
}
}

0 comments on commit c04bc89

Please sign in to comment.