Jump to content

Spawning a mob inside of a ticker


charsmud

Recommended Posts

Hello!  I am trying to spawn some mobs inside of my TickerClient.  I have spawned entities using items before, but for some reason, I cannot get the mobs to spawn!  At first, I thought it was because I was using WorldClient and not World, but even after switching to World instead of WorldClient, it still didn't work.  Here's the related code:

 

	
private void onTickInGame(Minecraft mc)
{
	mc.theWorld.getGameRules().setOrCreateGameRule("doMobSpawning", "false");


	File allEntityData = new File(mc.getMinecraftDir() + "/mods/TimeMod/past/EntityLocations/" + FMLClientHandler.instance().getServer().getWorldName() + "/" + TimeTraveler.vars.getPastTime() + ".epd");

		try 
		{
			BufferedReader reader = new BufferedReader(new FileReader(allEntityData));
			String line;
			while (((line = reader.readLine()) != null) && nextSet) 
			{
				if(line.equals("===================="))
				{
					nextSet = false;
				}
				else 
				{
					String[] entityData = line.split(",");

					String entityName = entityData[0];
					int entityX = Integer.parseInt(entityData[1]);
					int entityY = Integer.parseInt(entityData[2]);
					int entityZ = Integer.parseInt(entityData[3]);

					//System.out.println(entityName + " " + entityX + " " + entityY + " " + entityZ);
					Entity pastEntity = EntityList.createEntityByName(entityName, mc.thePlayer.worldObj);

					if(pastEntity != null)
					{
						PathEntity path = ((EntityLiving)pastEntity).getNavigator().getPath();
						if(pastEntity != null)
						{
							pastEntity.posX = (double)entityX;
							pastEntity.posY = (double)entityY;
							pastEntity.posZ = (double)entityZ;

							System.out.println(pastEntity);
							mc.thePlayer.worldObj.spawnEntityInWorld(pastEntity);
						}

					}
					else
					{
						EntityPlayerPast pastPlayer = new EntityPlayerPast(mc.thePlayer.worldObj);
						pastPlayer.posX = (double)entityX;
						pastPlayer.posY = (double)entityY;
						pastPlayer.posZ = (double)entityZ;
						System.out.println(pastPlayer);
						mc.thePlayer.worldObj.spawnEntityInWorld(pastPlayer);
					}

			        //path = ((EntityLiving)pastEntity).getNavigator().getPathToXYZ((double)entityX, (double)entityY, (double)entityZ);
			            		
			        //((EntityLiving)pastEntity).getNavigator().setPath(path, 1.0F);
			        //((EntityLiving)pastEntity).getNavigator().tryMoveToXYZ((double)entityX, (double)entityY, (double)entityZ, 0.5F);

				}
				System.out.println(nextSet);
			}
			reader.close();	
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		} 		
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.