Search in sources :

Example 1 with DefaultEntityController

use of com.bergerkiller.bukkit.common.controller.DefaultEntityController in project BKCommonLib by bergerhealer.

the class CommonEntityType method createNMSHookEntity.

public <T extends Entity> CommonEntity<T> createNMSHookEntity(Location location) {
    World world = location.getWorld();
    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();
    EntityHook hook = new EntityHook();
    hook.setStack(new Throwable());
    Object handle = hook.constructInstance(this.nmsType.getType(), new Class<?>[] { NMSWorld.T.getType(), double.class, double.class, double.class }, new Object[] { Conversion.toWorldHandle.convert(world), x, y, z });
    CommonEntity<T> entity = createCommonEntityFromHandle(handle);
    entity.loc.set(entity.last.set(location));
    DefaultEntityController controller = new DefaultEntityController();
    controller.bind(entity, false);
    return entity;
}
Also used : EntityHook(com.bergerkiller.bukkit.common.internal.hooks.EntityHook) DefaultEntityController(com.bergerkiller.bukkit.common.controller.DefaultEntityController) World(org.bukkit.World) NMSWorld(com.bergerkiller.reflection.net.minecraft.server.NMSWorld)

Example 2 with DefaultEntityController

use of com.bergerkiller.bukkit.common.controller.DefaultEntityController in project BKCommonLib by bergerhealer.

the class CommonEntityType method createCommonEntityNull.

public <T extends Entity> CommonEntity<T> createCommonEntityNull() {
    EntityHook hook = new EntityHook();
    hook.setStack(new Throwable());
    Object handle = hook.createInstance(this.nmsType.getType());
    CommonEntity<T> entity = createCommonEntityFromHandle(handle);
    DefaultEntityController controller = new DefaultEntityController();
    controller.bind(entity, false);
    return entity;
}
Also used : EntityHook(com.bergerkiller.bukkit.common.internal.hooks.EntityHook) DefaultEntityController(com.bergerkiller.bukkit.common.controller.DefaultEntityController)

Aggregations

DefaultEntityController (com.bergerkiller.bukkit.common.controller.DefaultEntityController)2 EntityHook (com.bergerkiller.bukkit.common.internal.hooks.EntityHook)2 NMSWorld (com.bergerkiller.reflection.net.minecraft.server.NMSWorld)1 World (org.bukkit.World)1