Fixed EntitySpawnExtension buffer being unable to be read from, Fix #208 (#220)

* Fixed EntitySpawnExtension buffer being unable to read from, #208

* Release the extensions buffer when it is no longer needed

* Cleaned the buffer fix for EntitySpawnExtension

Co-authored-by: Paul <paul.l.preston@hotmail.com>
This commit is contained in:
Hiroku
2022-03-20 22:26:53 +10:00
committed by shedaniel
parent 36a5aea8aa
commit f9d8a59790

View File

@@ -84,6 +84,8 @@ public class SpawnEntityPacket {
var deltaX = buf.readDouble();
var deltaY = buf.readDouble();
var deltaZ = buf.readDouble();
// Retain this buffer so we can use it in the queued task (EntitySpawnExtension)
buf.retain();
context.queue(() -> {
var entityType = Registry.ENTITY_TYPE.byId(entityTypeId);
if (entityType == null) {
@@ -105,6 +107,7 @@ public class SpawnEntityPacket {
if (entity instanceof EntitySpawnExtension ext) {
ext.loadAdditionalSpawnData(buf);
}
buf.release();
Minecraft.getInstance().level.putNonPlayerEntity(id, entity);
entity.lerpMotion(deltaX, deltaY, deltaZ);
});