mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 20:48:08 +01:00
Cache destroy packet
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
58b13fd007
commit
5959b37600
@ -27,6 +27,7 @@ import net.minestom.server.instance.InstanceManager;
|
|||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.instance.block.BlockGetter;
|
import net.minestom.server.instance.block.BlockGetter;
|
||||||
import net.minestom.server.instance.block.BlockHandler;
|
import net.minestom.server.instance.block.BlockHandler;
|
||||||
|
import net.minestom.server.network.packet.CachedPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.play.*;
|
import net.minestom.server.network.packet.server.play.*;
|
||||||
import net.minestom.server.permission.Permission;
|
import net.minestom.server.permission.Permission;
|
||||||
@ -72,6 +73,8 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
private static final Map<UUID, Entity> ENTITY_BY_UUID = new ConcurrentHashMap<>();
|
private static final Map<UUID, Entity> ENTITY_BY_UUID = new ConcurrentHashMap<>();
|
||||||
private static final AtomicInteger LAST_ENTITY_ID = new AtomicInteger();
|
private static final AtomicInteger LAST_ENTITY_ID = new AtomicInteger();
|
||||||
|
|
||||||
|
private final CachedPacket destroyPacketCache = new CachedPacket(() -> new DestroyEntitiesPacket(getEntityId()));
|
||||||
|
|
||||||
protected Instance instance;
|
protected Instance instance;
|
||||||
protected Chunk currentChunk;
|
protected Chunk currentChunk;
|
||||||
protected Pos position;
|
protected Pos position;
|
||||||
@ -452,7 +455,7 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
if (passenger != player) passenger.viewEngine.viewableOption.removal.accept(player);
|
if (passenger != player) passenger.viewEngine.viewableOption.removal.accept(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendPacket(new DestroyEntitiesPacket(getEntityId()));
|
player.sendPacket(destroyPacketCache.retrieve());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user