Browse Source

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>
Hiroku 3 năm trước cách đây
mục cha
commit
24a07946ec

+ 3 - 0
fabric/src/main/java/me/shedaniel/architectury/networking/fabric/SpawnEntityPacket.java

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