Basic ScriptCraft/Bukkit syntax for Entities

478 views
Skip to first unread message

Jon Ippolito

unread,
Feb 16, 2014, 1:53:38 PM2/16/14
to scriptcraft---sc...@googlegroups.com
I'm new to Minecraft, Bukkit, and ScriptCraft and am trying to figure out how to perform some basic actions. Here's an easy one: how do I spawn an entity at a given location? I've tried variations like this to no avail:

var thisWorld = server.worlds.get(0) ;
thisWorld.spawn( 212, 63, 160, Zombie) ;

(I'm trying to adapt the syntax found at http://jd.bukkit.org/rb/apidocs/ but always getting an in-game error.)

For the record, it would be super-convenient to spawn entities at checkpoints (chkpt), but I'm assuming they only apply to Drones at this point.

I'm also having trouble with the teleport syntax for players and entities...

Any help appreciated!

jon

Walter Higgins

unread,
Feb 16, 2014, 4:40:11 PM2/16/14
to scriptcraft---sc...@googlegroups.com
Hi Jon,

To spawn an entity, you can use the jsp spawn command.
Type jsp spawn then press the TAB key to see a list of possible entities...

e.g. to spawn a cow at the player's current location...

/jsp spawn cow

If you want to spawn an entity using javascript...

/js var location = self.location
/js location.world.spawnEntity(location, org.bukkit.EntityType.ZOMBIE);

To teleport a player...

var TeleportCause = org.bukkit.event.player.TeleportEvent.TeleportCause;
var location = new org.bukkit.Location(world, x, y, z);
player.teleport( location, TeleportCause.PLUGIN );

Walter



Jon Ippolito

unread,
Feb 17, 2014, 8:25:29 PM2/17/14
to scriptcraft---sc...@googlegroups.com
Hi Walter,

Thanks for giving me this snippet for spawning a zombie:

var location = self.location
location.world.spawnEntity(location, org.bukkit.EntityType.ZOMBIE);

I couldn't get this to work in an external JavaScript so I tried the following at the in-game prompt:


/js var location = self.location ;
/js alert( self.location ) ;

The second line gave me this error:

ReferenceError: "location" is not defined.

So I left off the "var" to create a global variable and then it worked. However, when I subsequently type at the in-game prompt:

/js location.world.spawnEntity(location, org.bukkit.EntityType.ZOMBIE);

I get this error:

InternalError: Can't find method org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawnEntity(org.bukkit.Location,object). (<Unknown source>#641(eval)#1)
   
I get a similar error when I try to give location coordinates manually, eg:

var thisWorld = server.worlds.get( 0 ) ;
var spawnLocation = new org.bukkit.Location(thisWorld, 210, 60, 150) ;
spawnLocation.world.spawnEntity(spawnLocation, org.bukkit.EntityType.ZOMBIE);

Any ideas what's going wrong? I'm on a 2012 MacBook Pro running OS10.9.1 on a 2.5GHz Intel Core i7 with 8GB RAM over Wifi, with craftbukkit-1.7.2-R0.3 and ScriptCraft v2.0.4.

Thanks!

jon

Walter Higgins

unread,
Feb 18, 2014, 5:26:33 AM2/18/14
to scriptcraft---sc...@googlegroups.com
Which version of Java are you using? Type...

 java -version

... at the command prompt.

Walter

Jon Ippolito

unread,
Feb 18, 2014, 2:38:07 PM2/18/14
to scriptcraft---sc...@googlegroups.com
I'm running 1.6.0_65, which AFAICT is the "officially supported" Apple version for OS 10.9 Mavericks.

From a quick search online, it appears that Mavericks isn't very good at finding Java 1.7 when users directly download it from Oracle. If I need 1.7, then these appear to be the fixes:

http://www.monkehworks.com/set-java-7-as-default-jvm-on-mac-osx-mountain-lion

http://stackoverflow.com/questions/19533528/installing-java-on-os-x-10-9-mavericks
(Scroll down as the first answer only covers Java 1.6.)

Any advice appreciated!

jon


Jon Ippolito

unread,
Feb 18, 2014, 10:33:33 PM2/18/14
to scriptcraft---sc...@googlegroups.com
Walter,

Thanks for your correction of org.bukkit.entity.EntityType, instead of org.bukkit.EntityType--that works!
Reply all
Reply to author
Forward
0 new messages