This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/modules/spawn.js

24 lines
672 B
JavaScript

/*global require, module, __plugin, Packages*/
'use strict';
var entities = require('entities');
module.exports = function(entityType, location){
var entityTypeFn;
if (typeof entityType === 'string'){
entityTypeFn = entities[entityType.toLowerCase()];
entityType = entityTypeFn();
}
if (typeof entityType === 'function'){
entityType = entityType();
}
var world = location.world;
if (__plugin.bukkit){
world.spawnEntity( location, entityType);
}
if (__plugin.canary){
var Canary = Packages.net.canarymod.Canary,
entityInstance = Canary.factory().entityFactory.newEntity(entityType, location);
entityInstance.spawn();
}
};