Added EntityCreature#setView

This commit is contained in:
Felix Cravic 2020-05-27 20:55:33 +02:00
parent 039e9aca4f
commit 70be25bd1c
4 changed files with 20 additions and 7 deletions

View File

@ -765,6 +765,14 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
}
}
/**
* Update the entity view internally
* <p>
* Warning: you probably want to use {@link EntityCreature#setView(float, float)}
*
* @param yaw the yaw
* @param pitch the pitch
*/
public void refreshView(float yaw, float pitch) {
this.lastYaw = position.getYaw();
this.lastPitch = position.getPitch();

View File

@ -119,16 +119,20 @@ public abstract class EntityCreature extends LivingEntity {
}
if (lastYaw != yaw) {
EntityHeadLookPacket entityHeadLookPacket = new EntityHeadLookPacket();
entityHeadLookPacket.entityId = getEntityId();
entityHeadLookPacket.yaw = yaw;
sendPacketToViewers(entityHeadLookPacket);
refreshView(yaw, pitch);
setView(yaw, pitch);
}
refreshPosition(newX, newY, newZ);
}
public void setView(float yaw, float pitch) {
EntityHeadLookPacket entityHeadLookPacket = new EntityHeadLookPacket();
entityHeadLookPacket.entityId = getEntityId();
entityHeadLookPacket.yaw = yaw;
sendPacketToViewers(entityHeadLookPacket);
refreshView(yaw, pitch);
}
@Override
public void spawn() {

View File

@ -9,7 +9,7 @@ import java.util.function.Consumer;
public class ChunkLoader {
private static String getChunkKey(int chunkX, int chunkZ) {
return "chunk_" + chunkX + "." + chunkZ;
return chunkX + "." + chunkZ;
}
protected void saveChunk(Chunk chunk, StorageFolder storageFolder, Runnable callback) {

View File

@ -413,7 +413,8 @@ public class InstanceContainer extends Instance {
}
private void cacheChunk(Chunk chunk) {
this.chunks.put(ChunkUtils.getChunkIndex(chunk.getChunkX(), chunk.getChunkZ()), chunk);
long index = ChunkUtils.getChunkIndex(chunk.getChunkX(), chunk.getChunkZ());
this.chunks.put(index, chunk);
}
@Override