@Override public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet) { WorldClient wc = client.field_71441_e; Class<? extends Entity> cls = er.getEntityClass(); try { Entity entity; if (er.hasCustomSpawning()) { entity = er.doCustomSpawning(packet); } else { entity = (Entity) (cls.getConstructor(World.class).newInstance(wc)); int offset = packet.entityId - entity.field_70157_k; entity.field_70157_k = packet.entityId; entity.func_70012_b( packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch); if (entity instanceof EntityLiving) { ((EntityLiving) entity).field_70759_as = packet.scaledHeadYaw; } Entity parts[] = entity.func_70021_al(); if (parts != null) { for (int j = 0; j < parts.length; j++) { parts[j].field_70157_k += offset; } } } entity.field_70118_ct = packet.rawX; entity.field_70117_cu = packet.rawY; entity.field_70116_cv = packet.rawZ; if (entity instanceof IThrowableEntity) { Entity thrower = client.field_71439_g.field_70157_k == packet.throwerId ? client.field_71439_g : wc.func_73045_a(packet.throwerId); ((IThrowableEntity) entity).setThrower(thrower); } if (packet.metadata != null) { entity.func_70096_w().func_75687_a((List) packet.metadata); } if (packet.throwerId > 0) { entity.func_70016_h(packet.speedScaledX, packet.speedScaledY, packet.speedScaledZ); } if (entity instanceof IEntityAdditionalSpawnData) { ((IEntityAdditionalSpawnData) entity).readSpawnData(packet.dataStream); } wc.func_73027_a(packet.entityId, entity); return entity; } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "A severe problem occurred during the spawning of an entity"); throw Throwables.propagate(e); } }
@Override public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket packet) { Entity ent = client.field_71441_e.func_73045_a(packet.entityId); if (ent != null) { ent.field_70118_ct = packet.serverX; ent.field_70117_cu = packet.serverY; ent.field_70116_cv = packet.serverZ; } else { FMLLog.fine( "Attempted to adjust the position of entity %d which is not present on the client", packet.entityId); } }