Search in sources :

Example 1 with ConvertingList

use of com.bergerkiller.mountiplex.conversion.util.ConvertingList in project BKCommonLib by bergerhealer.

the class PlayerUtil method getNearbyPlayers.

/**
 * Gets a (referenced) list of all players nearby another Player
 *
 * @param player to get the nearby players of
 * @param radius to look around the player for other playrs
 * @return list of nearby players
 */
public static List<Player> getNearbyPlayers(Player player, double radius) {
    EntityPlayerHandle handle = CommonNMS.getHandle(player);
    List<?> nearbyPlayerHandles = handle.getWorld().getRawEntitiesOfType(EntityPlayerHandle.T.getType(), handle.getBoundingBox().grow(radius, radius, radius));
    return new ConvertingList<Player>(nearbyPlayerHandles, DuplexConversion.player);
}
Also used : ConvertingList(com.bergerkiller.mountiplex.conversion.util.ConvertingList) EntityPlayerHandle(com.bergerkiller.generated.net.minecraft.server.EntityPlayerHandle)

Example 2 with ConvertingList

use of com.bergerkiller.mountiplex.conversion.util.ConvertingList in project BKCommonLib by bergerhealer.

the class ChunkProviderServerHook method getMobsFor.

@HookMethod("public List<BiomeBase.BiomeMeta> getBiomeSpawnInfo:???(EnumCreatureType enumcreaturetype, BlockPosition blockposition)")
public List<?> getMobsFor(Object enumcreaturetype, Object blockposition) {
    List<?> mobs = base.getMobsFor(enumcreaturetype, blockposition);
    if (CommonPlugin.hasInstance()) {
        // There is no use wasting CPU time when no one handles the event!
        if (LogicUtil.nullOrEmpty(mobs) || !CommonUtil.hasHandlers(CreaturePreSpawnEvent.getHandlerList())) {
            return mobs;
        }
        // Wrap the parameters and send the event along
        BlockPositionHandle pos = BlockPositionHandle.createHandle(blockposition);
        org.bukkit.World world = getWorld();
        List<BiomeMetaHandle> mobsHandles = new ConvertingList<BiomeMetaHandle>(mobs, BiomeMetaHandle.T.getHandleConverter());
        mobsHandles = CommonPlugin.getInstance().getEventFactory().handleCreaturePreSpawn(world, pos.getX(), pos.getY(), pos.getZ(), mobsHandles);
        return new ConvertingList<Object>(mobsHandles, BiomeMetaHandle.T.getHandleConverter().reverse());
    } else {
        return mobs;
    }
}
Also used : BiomeMetaHandle(com.bergerkiller.generated.net.minecraft.server.BiomeBaseHandle.BiomeMetaHandle) ConvertingList(com.bergerkiller.mountiplex.conversion.util.ConvertingList) BlockPositionHandle(com.bergerkiller.generated.net.minecraft.server.BlockPositionHandle)

Aggregations

ConvertingList (com.bergerkiller.mountiplex.conversion.util.ConvertingList)2 BiomeMetaHandle (com.bergerkiller.generated.net.minecraft.server.BiomeBaseHandle.BiomeMetaHandle)1 BlockPositionHandle (com.bergerkiller.generated.net.minecraft.server.BlockPositionHandle)1 EntityPlayerHandle (com.bergerkiller.generated.net.minecraft.server.EntityPlayerHandle)1