private void DrawPrimitive ( DrawEntity e , World w ) throws Exception { String oldEntityName = e . getType ( ) . getValue ( ) ; String id = null ; for ( EntityEntry ent : net . minecraftforge . fml . common . registry . ForgeRegistries . ENTITIES ) { if ( ent . getName ( ) . equals ( oldEntityName ) ) { id = ent . getRegistryName ( ) . toString ( ) ; break ; } } if ( id == null ) return ; NBTTagCompound nbttagcompound = new NBTTagCompound ( ) ; nbttagcompound . setString ( "id" , id ) ; nbttagcompound . setBoolean ( "PersistenceRequired" , true ) ; // Don't let this entity despawn Entity entity ; try { entity = EntityList . createEntityFromNBT ( nbttagcompound , w ) ; if ( entity != null ) { positionEntity ( entity , e . getX ( ) . doubleValue ( ) , e . getY ( ) . doubleValue ( ) , e . getZ ( ) . doubleValue ( ) , e . getYaw ( ) . floatValue ( ) , e . getPitch ( ) . floatValue ( ) ) ; entity . setVelocity ( e . getXVel ( ) . doubleValue ( ) , e . getYVel ( ) . doubleValue ( ) , e . getZVel ( ) . doubleValue ( ) ) ; // Set all the yaw values imaginable: if ( entity instanceof EntityLivingBase ) { ( ( EntityLivingBase ) entity ) . rotationYaw = e . getYaw ( ) . floatValue ( ) ; ( ( EntityLivingBase ) entity ) . prevRotationYaw = e . getYaw ( ) . floatValue ( ) ; ( ( EntityLivingBase ) entity ) . prevRotationYawHead = e . getYaw ( ) . floatValue ( ) ; ( ( EntityLivingBase ) entity ) . rotationYawHead = e . getYaw ( ) . floatValue ( ) ; ( ( EntityLivingBase ) entity ) . prevRenderYawOffset = e . getYaw ( ) . floatValue ( ) ; ( ( EntityLivingBase ) entity ) . renderYawOffset = e . getYaw ( ) . floatValue ( ) ; } w . getBlockState ( entity . getPosition ( ) ) ; // Force-load the chunk if necessary, to ensure spawnEntity will work. if ( ! w . spawnEntity ( entity ) ) { System . out . println ( "WARNING: Failed to spawn entity! Chunk not loaded?" ) ; } } } catch ( RuntimeException runtimeexception ) { // Cannot summon this entity. throw new Exception ( "Couldn't create entity type: " + e . getType ( ) . getValue ( ) ) ; } }
Spawn a single entity at the specified position .