當前位置: 首頁>>代碼示例>>Java>>正文


Java MinecraftServer.currentTick方法代碼示例

本文整理匯總了Java中net.minecraft.server.MinecraftServer.currentTick方法的典型用法代碼示例。如果您正苦於以下問題:Java MinecraftServer.currentTick方法的具體用法?Java MinecraftServer.currentTick怎麽用?Java MinecraftServer.currentTick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.server.MinecraftServer的用法示例。


在下文中一共展示了MinecraftServer.currentTick方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activateChunkEntities

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Checks for the activation state of all entities in this chunk.
 *
 * @param chunk
 */
private static void activateChunkEntities(Chunk chunk)
{
    for ( List<Entity> slice : chunk.entityLists )
    {
        for ( Entity entity : slice )
        {
            if ( MinecraftServer.currentTick > entity.activatedTick )
            {
                if ( entity.defaultActivationState )
                {
                    entity.activatedTick = MinecraftServer.currentTick;
                    continue;
                }
                switch ( entity.activationType )
                {
                    case 1:
                        if ( monsterBB.intersectsWith( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 2:
                        if ( animalBB.intersectsWith( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 3:
                    default:
                        if ( miscBB.intersectsWith( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                }
            }
        }
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:44,代碼來源:ActivationRange.java

示例2: checkIfActive

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Checks if the entity is active for this tick.
 *
 * @param entity
 * @return
 */
public static boolean checkIfActive(Entity entity)
{
    SpigotTimings.checkIfActiveTimer.startTiming();

    boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;

    // Should this entity tick?
    if ( !isActive )
    {
        if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
        {
            // Check immunities every 20 ticks.
            if ( checkEntityImmunities( entity ) )
            {
                // Triggered some sort of immunity, give 20 full ticks before we check again.
                entity.activatedTick = MinecraftServer.currentTick + 20;
            }
            isActive = true;
        }
        // Add a little performance juice to active entities. Skip 1/4 if not immune.
    } else if ( !entity.defaultActivationState && entity.ticksExisted % 4 == 0 && !checkEntityImmunities( entity ) )
    {
        isActive = false;
    }

    // Cauldron - we check for entities in forced chunks in World.updateEntityWithOptionalForce
    // Make sure not on edge of unloaded chunk
    int x = net.minecraft.util.MathHelper.floor_double( entity.posX );
    int z = net.minecraft.util.MathHelper.floor_double( entity.posZ );
    if ( isActive && !entity.worldObj.doChunksNearChunkExist( x, 0, z, 16 ) ) {
        isActive = false;
    }

    SpigotTimings.checkIfActiveTimer.stopTiming();
    return isActive;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:43,代碼來源:ActivationRange.java

示例3: activateEntities

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * 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();
    // Cauldron start - proxy world support
    final int miscActivationRange = world.getSpigotConfig().miscActivationRange;
    final int animalActivationRange = world.getSpigotConfig().animalActivationRange;
    final int monsterActivationRange = world.getSpigotConfig().monsterActivationRange;
    // Cauldron end

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

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

        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_double( maxBB.minX / 16.0D );
        int j = MathHelper.floor_double( maxBB.maxX / 16.0D );
        int k = MathHelper.floor_double( maxBB.minZ / 16.0D );
        int l = MathHelper.floor_double( maxBB.maxZ / 16.0D );

        for ( int i1 = i; i1 <= j; ++i1 )
        {
            for ( int j1 = k; j1 <= l; ++j1 )
            {
                if ( world.getWorld().isChunkLoaded( i1, j1 ) )
                {
                    activateChunkEntities( world.getChunkFromChunkCoords( i1, j1 ) );
                }
            }
        }
    }
    SpigotTimings.entityActivationCheckTimer.stopTiming();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:47,代碼來源:ActivationRange.java


注:本文中的net.minecraft.server.MinecraftServer.currentTick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。