Dieser Commit ist enthalten in:
Ursprung
0051f09409
Commit
f465d551bf
@ -59,6 +59,8 @@ public class REntity {
|
|||||||
private byte pitch;
|
private byte pitch;
|
||||||
private byte headYaw;
|
private byte headYaw;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean hidden;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean invisible;
|
private boolean invisible;
|
||||||
@Getter
|
@Getter
|
||||||
@ -104,6 +106,19 @@ public class REntity {
|
|||||||
this.objectData = objectData;
|
this.objectData = objectData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hide(boolean hide) {
|
||||||
|
if(hidden == hide)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(hide) {
|
||||||
|
despawn(packet -> server.updateEntity(this, packet));
|
||||||
|
hidden = true;
|
||||||
|
} else {
|
||||||
|
hidden = false;
|
||||||
|
spawn(packet -> server.updateEntity(this, packet));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void move(Location location) {
|
public void move(Location location) {
|
||||||
move(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), rotToByte(location.getYaw()));
|
move(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), rotToByte(location.getYaw()));
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,7 @@ public class REntityServer implements Listener {
|
|||||||
if(fromId == toId)
|
if(fromId == toId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(!entity.isHidden())
|
||||||
onMissing(players.get(fromId), players.get(toId), entity::despawn);
|
onMissing(players.get(fromId), players.get(toId), entity::despawn);
|
||||||
removeEntityFromChunk(entity);
|
removeEntityFromChunk(entity);
|
||||||
}
|
}
|
||||||
@ -149,10 +150,14 @@ public class REntityServer implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
addEntityToChunk(entity);
|
addEntityToChunk(entity);
|
||||||
|
if(!entity.isHidden())
|
||||||
onMissing(players.get(toId), players.get(fromId), entity::spawn);
|
onMissing(players.get(toId), players.get(fromId), entity::spawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateEntity(REntity entity, Object packet) {
|
void updateEntity(REntity entity, Object packet) {
|
||||||
|
if(entity.isHidden())
|
||||||
|
return;
|
||||||
|
|
||||||
for(Player player : players.getOrDefault(entityToId(entity), emptyPlayers)) {
|
for(Player player : players.getOrDefault(entityToId(entity), emptyPlayers)) {
|
||||||
TinyProtocol.instance.sendPacket(player, packet);
|
TinyProtocol.instance.sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
@ -260,6 +265,7 @@ public class REntityServer implements Listener {
|
|||||||
long id = chunkToId(x, z);
|
long id = chunkToId(x, z);
|
||||||
players.computeIfAbsent(id, i -> new HashSet<>()).add(player);
|
players.computeIfAbsent(id, i -> new HashSet<>()).add(player);
|
||||||
for(REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
for(REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
||||||
|
if(!entity.isHidden())
|
||||||
entity.spawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
entity.spawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,6 +279,7 @@ public class REntityServer implements Listener {
|
|||||||
players.remove(id);
|
players.remove(id);
|
||||||
|
|
||||||
for(REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
for(REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
||||||
|
if(!entity.isHidden())
|
||||||
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren