当前位置: 首页>>代码示例>>Java>>正文


Java GenericMath.floor方法代码示例

本文整理汇总了Java中com.flowpowered.math.GenericMath.floor方法的典型用法代码示例。如果您正苦于以下问题:Java GenericMath.floor方法的具体用法?Java GenericMath.floor怎么用?Java GenericMath.floor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.flowpowered.math.GenericMath的用法示例。


在下文中一共展示了GenericMath.floor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LanternChunkPreGenerateTask

import com.flowpowered.math.GenericMath; //导入方法依赖的package包/类
private LanternChunkPreGenerateTask(PluginContainer plugin, World world, Vector3d center, double diameter,
        int chunkCount, float tickPercent, int tickInterval, Cause cause, List<Consumer<ChunkPreGenerationEvent>> eventListeners) {
    final int preferredTickInterval = Lantern.getScheduler().getPreferredTickInterval();

    this.plugin = plugin;
    this.world = world;

    this.chunkRadius = GenericMath.floor(diameter / 32);
    this.chunkCount = chunkCount;
    this.tickPercent = tickPercent;
    this.tickTimeLimit = Math.round(preferredTickInterval * tickPercent);
    this.cause = cause;
    this.tickInterval = tickInterval;
    final Optional<Vector3i> currentPosition = LanternChunkLayout.INSTANCE.toChunk(center.toInt());
    if (currentPosition.isPresent()) {
        this.currentPosition = currentPosition.get();
    } else {
        throw new IllegalArgumentException("Center is not a valid chunk coordinate");
    }
    this.currentGenCount = 4;
    this.currentLayer = 0;
    this.currentIndex = 0;
    this.nextJump = 0;

    this.totalChunksToGenerate = (int) Math.pow(this.chunkRadius * 2 + 1, 2);

    this.spongeTask = Lantern.getScheduler()
            .createTaskBuilder()
            .intervalTicks(preferredTickInterval)
            .execute(this)
            .submit(plugin);

    if (!eventListeners.isEmpty()) {
        this.eventListener = new LanternChunkPreGenerateListener(this.spongeTask.getUniqueId(), eventListeners);
        Sponge.getEventManager().registerListener(plugin, ChunkPreGenerationEvent.class, this.eventListener);
    } else {
        this.eventListener = null;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:40,代码来源:LanternChunkPreGenerateTask.java

示例2: wrapAngle

import com.flowpowered.math.GenericMath; //导入方法依赖的package包/类
/**
 * Wraps the double angle into a byte.
 * 
 * @param angle The angle
 * @return The byte value
 */
public static byte wrapAngle(double angle) {
    while (angle >= 180.0) {
        angle -= 360.0;
    }
    while (angle < -180.0) {
        angle += 360.0;
    }
    return (byte) GenericMath.floor(angle / 360.0 * 256.0);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:CodecUtils.java

示例3: getFlooredAmount

import com.flowpowered.math.GenericMath; //导入方法依赖的package包/类
/**
 * Gets the amount as if from {@link #getAmount(Random)} but floored to the
 * nearest integer equivalent.
 *
 * @param random The random object
 * @return The floored amount
 */
default int getFlooredAmount(@Nonnull Random random) {
    return GenericMath.floor(getAmount(random));
}
 
开发者ID:lucko,项目名称:helper,代码行数:11,代码来源:VariableAmount.java


注:本文中的com.flowpowered.math.GenericMath.floor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。