Java 类net.minecraft.server.World 实例源码

项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);

    boolean canBuild = true;
    for (int i = 0; i < blockStates.size(); i++) {
        if (!canBuild(craftWorld, player, blockStates.get(i).getX(), blockStates.get(i).getZ())) {
            canBuild = false;
            break;
        }
    }

    BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage, boolean keepInventory) {
    CraftPlayer entity = victim.getBukkitEntity();
    PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
    event.setKeepInventory(keepInventory);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();

    if (event.getKeepInventory()) {
        return event;
    }

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
    org.bukkit.World bukkitWorld = world.getWorld();
    Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
    IgniteCause cause;
    switch (igniter.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            cause = IgniteCause.LAVA;
            break;
        case DISPENSER:
            cause = IgniteCause.FLINT_AND_STEEL;
            break;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
    IgniteCause cause;
    switch (bukkitIgniter.getType()) {
    case ENDER_CRYSTAL:
        cause = IgniteCause.ENDER_CRYSTAL;
        break;
    case LIGHTNING:
        cause = IgniteCause.LIGHTNING;
        break;
    case SMALL_FIREBALL:
    case FIREBALL:
        cause = IgniteCause.FIREBALL;
        break;
    default:
        cause = IgniteCause.FLINT_AND_STEEL;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();

    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    Block placedBlock = replacedBlockState.getBlock();

    boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());

    BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
    CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
    EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.expToDrop = event.getDroppedExp();

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
    CraftPlayer entity = victim.getBukkitEntity();
    PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
    org.bukkit.World bukkitWorld = world.getWorld();
    Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
    IgniteCause cause;
    switch (igniter.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            cause = IgniteCause.LAVA;
            break;
        case DISPENSER:
            cause = IgniteCause.FLINT_AND_STEEL;
            break;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
    IgniteCause cause;
    switch (bukkitIgniter.getType()) {
    case ENDER_CRYSTAL:
        cause = IgniteCause.ENDER_CRYSTAL;
        break;
    case LIGHTNING:
        cause = IgniteCause.LIGHTNING;
        break;
    case SMALL_FIREBALL:
    case FIREBALL:
        cause = IgniteCause.FIREBALL;
        break;
    default:
        cause = IgniteCause.FLINT_AND_STEEL;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CCBolts    文件:CCHook.java   
public static IPeripheral getPeripheral(World world, int x, int y, int z) {
    if (y >= 0 && y < world.getHeight()) {
        TileEntity tileEntity = world.getTileEntity(x, y, z);
        if (tileEntity == null) {
            return null;
        } else if (tileEntity instanceof TileEntityHowlerAlarm) {
            return new HowlerAlarmPeripheral(
                    (TileEntityHowlerAlarm) tileEntity);
        } else if (tileEntity instanceof TileEntityNuclearReactor) {
            return new IC2NuclearReactorPeripheral(
                    (TileEntityNuclearReactor) tileEntity);
        } else if (tileEntity instanceof IEnergyConductor) {
            return new IC2WirePeripheral(
                    (IEnergyConductor) tileEntity);
        } else if (tileEntity instanceof TileEntityElectricBlock) {
            return new IC2BatteryPeripiheral(
                    (TileEntityElectricBlock) tileEntity);
        } else {
            return null;
        }
    }

    return null;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);

    boolean canBuild = true;
    for (int i = 0; i < blockStates.size(); i++) {
        if (!canBuild(craftWorld, player, blockStates.get(i).getX(), blockStates.get(i).getZ())) {
            canBuild = false;
            break;
        }
    }

    BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage, boolean keepInventory) {
    CraftPlayer entity = victim.getBukkitEntity();
    PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
    event.setKeepInventory(keepInventory);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();

    if (event.getKeepInventory()) {
        return event;
    }

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
    org.bukkit.World bukkitWorld = world.getWorld();
    Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
    IgniteCause cause;
    switch (igniter.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            cause = IgniteCause.LAVA;
            break;
        case DISPENSER:
            cause = IgniteCause.FLINT_AND_STEEL;
            break;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
    IgniteCause cause;
    switch (bukkitIgniter.getType()) {
    case ENDER_CRYSTAL:
        cause = IgniteCause.ENDER_CRYSTAL;
        break;
    case LIGHTNING:
        cause = IgniteCause.LIGHTNING;
        break;
    case SMALL_FIREBALL:
    case FIREBALL:
        cause = IgniteCause.FIREBALL;
        break;
    default:
        cause = IgniteCause.FLINT_AND_STEEL;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();

    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    Block placedBlock = replacedBlockState.getBlock();

    boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());

    BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
    CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
    EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.expToDrop = event.getDroppedExp();

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
    CraftPlayer entity = victim.getBukkitEntity();
    PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
    org.bukkit.World bukkitWorld = world.getWorld();
    Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
    IgniteCause cause;
    switch (igniter.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            cause = IgniteCause.LAVA;
            break;
        case DISPENSER:
            cause = IgniteCause.FLINT_AND_STEEL;
            break;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
    IgniteCause cause;
    switch (bukkitIgniter.getType()) {
    case ENDER_CRYSTAL:
        cause = IgniteCause.ENDER_CRYSTAL;
        break;
    case LIGHTNING:
        cause = IgniteCause.LIGHTNING;
        break;
    case SMALL_FIREBALL:
    case FIREBALL:
        cause = IgniteCause.FIREBALL;
        break;
    default:
        cause = IgniteCause.FLINT_AND_STEEL;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CraftBukkit    文件:QueuedChunk.java   
public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) {
    this.x = x;
    this.z = z;
    this.loader = loader;
    this.world = world;
    this.provider = provider;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.source == null ? null : explosion.source.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Craftbukkit    文件:CraftRabbit.java   
@Override
public void setRabbitType(Type type) {
    EntityRabbit entity = getHandle();
    if (getRabbitType() == Type.THE_KILLER_BUNNY) {
        // Reset goals and target finders.
        World world = ((CraftWorld) this.getWorld()).getHandle();
        entity.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
        entity.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
        entity.initializePathFinderGoals();
    }

    entity.setRabbitType(CraftMagicMapping.toMagic(type)); 
}
项目:Craftbukkit    文件:QueuedChunk.java   
public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) {
    this.x = x;
    this.z = z;
    this.loader = loader;
    this.world = world;
    this.provider = provider;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, int type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(type);
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.source == null ? null : explosion.source.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static BlockTickEvent callBlockTickEvent(World world, int x, int y, int z, Random random) {
    org.bukkit.World bukkitWorld = world.getWorld();
    final Block bukkitBlock = bukkitWorld.getBlockAt(x, y, z);
    final BlockTickEvent event = new BlockTickEvent(bukkitBlock, random);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:ActivationRange.java   
/**
 * Find what entities are in range of the players in the world and set
 * active if in range.
 *
 * @param world
 */
public static void activateEntities(World world)
{
    SpigotTimings.entityActivationCheckTimer.startTiming();
    final int miscActivationRange = world.spigotConfig.miscActivationRange;
    final int animalActivationRange = world.spigotConfig.animalActivationRange;
    final int monsterActivationRange = world.spigotConfig.monsterActivationRange;

    int maxRange = Math.max( monsterActivationRange, animalActivationRange );
    maxRange = Math.max( maxRange, miscActivationRange );
    maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );

    for ( Entity player : new ArrayList<Entity>( world.players ) )
    {

        player.activatedTick = MinecraftServer.currentTick;
        growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
        growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
        growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
        growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );

        int i = MathHelper.floor( maxBB.a / 16.0D );
        int j = MathHelper.floor( maxBB.d / 16.0D );
        int k = MathHelper.floor( maxBB.c / 16.0D );
        int l = MathHelper.floor( maxBB.f / 16.0D );

        for ( int i1 = i; i1 <= j; ++i1 )
        {
            for ( int j1 = k; j1 <= l; ++j1 )
            {
                if ( world.getWorld().isChunkLoaded( i1, j1 ) )
                {
                    activateChunkEntities( world.getChunkAt( i1, j1 ) );
                }
            }
        }
    }
    SpigotTimings.entityActivationCheckTimer.stopTiming();
}
项目:Almura-Server    文件:AntiXray.java   
/**
 * Starts the timings handler, then updates all blocks within the set radius
 * of the given coordinate, revealing them if they are hidden ores.
 */
public void updateNearbyBlocks(World world, int x, int y, int z)
{
    if ( world.spigotConfig.antiXray )
    {
        update.startTiming();
        updateNearbyBlocks( world, x, y, z, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
        update.stopTiming();
    }
}
项目:Almura-Server    文件:AntiXray.java   
/**
 * Starts the timings handler, and then removes all non exposed ores from
 * the chunk buffer.
 */
public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
{
    if ( world.spigotConfig.antiXray )
    {
        obfuscate.startTiming();
        obfuscate( chunkX, chunkY, bitmask, buffer, world );
        obfuscate.stopTiming();
    }
}
项目:Almura-Server    文件:AntiXray.java   
private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
{
    // If the block in question is loaded
    if ( world.isLoaded( x, y, z ) )
    {
        // Get block id
        int id = world.getTypeId( x, y, z );

        // See if it needs update
        if ( updateSelf && obfuscateBlocks[id] )
        {
            // Send the update
            world.notify( x, y, z );
        }

        // Check other blocks for updates
        if ( radius > 0 )
        {
            updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
            updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
        }
    }
}
项目:Almura-Server    文件:AntiXray.java   
private static boolean isLoaded(World world, int x, int y, int z, int radius)
{
    return world.isLoaded( x, y, z )
            || ( radius > 0
            && ( isLoaded( world, x + 1, y, z, radius - 1 )
            || isLoaded( world, x - 1, y, z, radius - 1 )
            || isLoaded( world, x, y + 1, z, radius - 1 )
            || isLoaded( world, x, y - 1, z, radius - 1 )
            || isLoaded( world, x, y, z + 1, radius - 1 )
            || isLoaded( world, x, y, z - 1, radius - 1 ) ) );
}
项目:Almura-Server    文件:AntiXray.java   
private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius)
{
    return !Block.l( world.getTypeId( x, y, z ) ) /* isSolidBlock */
            || ( radius > 0
            && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x - 1, y, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y + 1, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y - 1, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y, z + 1, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
}
项目:Tweakkit-Server    文件:QueuedChunk.java   
public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) {
    this.x = x;
    this.z = z;
    this.loader = loader;
    this.world = world;
    this.provider = provider;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.source == null ? null : explosion.source.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * Find what entities are in range of the players in the world and set
 * active if in range.
 *
 * @param world
 */
public static void activateEntities(World world)
{
    SpigotTimings.entityActivationCheckTimer.startTiming();
    final int miscActivationRange = world.spigotConfig.miscActivationRange;
    final int animalActivationRange = world.spigotConfig.animalActivationRange;
    final int monsterActivationRange = world.spigotConfig.monsterActivationRange;

    int maxRange = Math.max( monsterActivationRange, animalActivationRange );
    maxRange = Math.max( maxRange, miscActivationRange );
    maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );

    for ( Entity player : (List<Entity>) world.players )
    {

        player.activatedTick = MinecraftServer.currentTick;
        growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
        growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
        growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
        growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );

        int i = MathHelper.floor( maxBB.a / 16.0D );
        int j = MathHelper.floor( maxBB.d / 16.0D );
        int k = MathHelper.floor( maxBB.c / 16.0D );
        int l = MathHelper.floor( maxBB.f / 16.0D );

        for ( int i1 = i; i1 <= j; ++i1 )
        {
            for ( int j1 = k; j1 <= l; ++j1 )
            {
                if ( world.getWorld().isChunkLoaded( i1, j1 ) )
                {
                    activateChunkEntities( world.getChunkAt( i1, j1 ) );
                }
            }
        }
    }
    SpigotTimings.entityActivationCheckTimer.stopTiming();
}
项目:Tweakkit-Server    文件:AntiXray.java   
/**
 * Starts the timings handler, then updates all blocks within the set radius
 * of the given coordinate, revealing them if they are hidden ores.
 */
public void updateNearbyBlocks(World world, int x, int y, int z)
{
    if ( world.spigotConfig.antiXray )
    {
        update.startTiming();
        updateNearbyBlocks( world, x, y, z, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
        update.stopTiming();
    }
}
项目:Tweakkit-Server    文件:AntiXray.java   
/**
 * Starts the timings handler, and then removes all non exposed ores from
 * the chunk buffer.
 */
public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
{
    if ( world.spigotConfig.antiXray )
    {
        obfuscate.startTiming();
        obfuscate( chunkX, chunkY, bitmask, buffer, world );
        obfuscate.stopTiming();
    }
}
项目:Tweakkit-Server    文件:AntiXray.java   
private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
{
    // If the block in question is loaded
    if ( world.isLoaded( x, y, z ) )
    {
        // Get block id
        Block block = world.getType(x, y, z);

        // See if it needs update
        if ( updateSelf && obfuscateBlocks[Block.getId( block )] )
        {
            // Send the update
            world.notify( x, y, z );
        }

        // Check other blocks for updates
        if ( radius > 0 )
        {
            updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
            updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
        }
    }
}