You can use World.spawnArrow / World.spawnBoat / World.spawnMinecart which are also Entities but you're probably talking about living entities, which doesn't seem to be possible.
Somehow it must be possible yet. Like in this plugin: http://forums.bukkit.org/threads/bukkitmon.1005/
There is no way to do it in the Bukkit API (yet), but if you're not shy about digging into CraftBukkit (and minecraft-server itself), you can. Check out the "familiar" spell in my spells plugin- here's a snippet: Code: EntityLiving e = null; CraftPlayer craftPlayer = (CraftPlayer)player; CraftWorld craftWorld = (CraftWorld)craftPlayer.getWorld(); World world = craftWorld.getHandle(); e = new EntitySheep(world); e.getBukkitEntity().teleportTo(location); world.a(e); That last bit is really the only missing part from the API- it's (I'm assuming) the Minecraft world command that adds an entity to the world.
Awesome! Thank you for these informations Do i have to include the craftbukkit.jar to use these methods? [EDIT] Found it out myself Thanks again!
Glad I could help! You seem to have figured it out, but yes you have to link to CraftBukkit.jar to do this. And maybe minecraft_server.jar, too? --- merged: Jan 24, 2011 1:31 AM --- And, of course, the disclaimer here is the usual "this isn't the Bukkit way to do it, it means your plugin is now tied to CraftBukkit", etc. Hopefully they'll add a spawn() function to World that does this soon. If I'm feeling industrious, I'll add it and request a pull.
I would love to contribute to bukkit directly, but i'm so sure my programming style would cause them headaches ^^
Something like this, in theory, would be really simple- just a quick add to World and CraftWorld with that one little bit of code.
The multiworld code has changed this snippet very slightly, as craftWorld.getHandle() returns a WorldServer object, not a World object. This works for me: Code: EntityLiving e = null; CraftPlayer craftPlayer = (CraftPlayer)player; CraftWorld craftWorld = (CraftWorld)craftPlayer.getWorld(); net.minecraft.server.World mworld = (net.minecraft.server.World)(craftWorld.getHandle()); e = new EntitySheep(mworld); e.getBukkitEntity().teleportTo(loc); mworld.a(e);
I don't know about anyone else - but i have found that if you turn mobs off in server.properties, the above methods of spawning mobs no longer work since the minecraft server deletes it straight after it spawns. Anyone got any ideas on how to get around this?
this will allow me to spawn an living entity? how would i make the entity spawn on the player attached to the event that calls it, or better yet, behind the player? would this make a squid spawn on the players location? Code: EntityLiving e = null CraftPlayer craftPlayer = (CraftPlayer)player; CraftWorld craftWorld = (CraftWorld)craftPlayer.getWorld(); World world = craftWorld.getHandle(); e = new EntitySquid(world); e.getBukkitEntity().teleportTo(player.getLocation()); world.a(e); how could i add to the location data to move it 1 block behind the player?
Code: e.getBukkitEntity().teleportTo(location); Is the key line for doing that. Just replace 'location' with 'craftPlayer.getLocation()';
so event.getPlayer().getLocation() wont work? if all goes well, the plug-in 'BigCatch' will have a 3.3333% chance of catching a squid, and 0.3333 chance of snagging a skeleton or zombie.
Actually, you should update Bukkit! My original advice is outdated- it's in the API now See World.spawnCreature, and CreatureType.
how do i specify the location? how new is this? a few days? ill be sure to update my API, but wouldn't that make my plug-in not work for older craft Bukkit builds or no?