Search in sources :

Example 1 with BlockPositionHandle

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

the class NMSTileEntity method getBlock.

public static Block getBlock(Object tileEntity) {
    TileEntityHandle handle = TileEntityHandle.createHandle(tileEntity);
    BlockPositionHandle pos = handle.getPosition();
    return handle.getWorld().getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
}
Also used : TileEntityHandle(com.bergerkiller.generated.net.minecraft.server.TileEntityHandle) BlockPositionHandle(com.bergerkiller.generated.net.minecraft.server.BlockPositionHandle)

Example 2 with BlockPositionHandle

use of com.bergerkiller.generated.net.minecraft.server.BlockPositionHandle 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 : ConvertingList(com.bergerkiller.mountiplex.conversion.util.ConvertingList) BiomeMetaHandle(com.bergerkiller.generated.net.minecraft.server.BiomeBaseHandle.BiomeMetaHandle) BlockPositionHandle(com.bergerkiller.generated.net.minecraft.server.BlockPositionHandle)

Aggregations

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