mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-09 08:51:38 +01:00
Added EntityCreature#setView
This commit is contained in:
parent
039e9aca4f
commit
70be25bd1c
@ -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();
|
||||
|
@ -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() {
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user