Merge pull request 'Add option to hide REntities' (#252) from hideEntities into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #252
Dieser Commit ist enthalten in:
Commit
62796040b0
@ -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,7 +138,8 @@ public class REntityServer implements Listener {
|
|||||||
if(fromId == toId)
|
if(fromId == toId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
onMissing(players.get(fromId), players.get(toId), entity::despawn);
|
if(!entity.isHidden())
|
||||||
|
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);
|
||||||
onMissing(players.get(toId), players.get(fromId), entity::spawn);
|
if(!entity.isHidden())
|
||||||
|
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,7 +265,8 @@ 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)) {
|
||||||
entity.spawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
if(!entity.isHidden())
|
||||||
|
entity.spawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +279,8 @@ 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)) {
|
||||||
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
if(!entity.isHidden())
|
||||||
|
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren