Search in sources :

Example 1 with WorldServerHandle

use of com.bergerkiller.generated.net.minecraft.server.WorldServerHandle in project BKCommonLib by bergerhealer.

the class EntityUtil method addEntity.

/**
     * Adds a single entity to the server
     *
     * @param entity to add
     */
public static void addEntity(org.bukkit.entity.Entity entity) {
    EntityHandle nmsentity = CommonNMS.getHandle(entity);
    WorldServerHandle nmsworld = nmsentity.getWorldServer();
    entity.getWorld().getChunkAt(MathUtil.toChunk(nmsentity.getLocX()), MathUtil.toChunk(nmsentity.getLocZ()));
    nmsentity.setDead(false);
    // Remove an entity tracker for this entity if it was present
    nmsworld.getEntityTracker().stopTracking(entity);
    // Add the entity to the world
    nmsworld.addEntity(nmsentity);
}
Also used : WorldServerHandle(com.bergerkiller.generated.net.minecraft.server.WorldServerHandle) EntityHandle(com.bergerkiller.generated.net.minecraft.server.EntityHandle)

Aggregations

EntityHandle (com.bergerkiller.generated.net.minecraft.server.EntityHandle)1 WorldServerHandle (com.bergerkiller.generated.net.minecraft.server.WorldServerHandle)1