本文整理汇总了Java中net.minecraft.server.MathHelper类的典型用法代码示例。如果您正苦于以下问题:Java MathHelper类的具体用法?Java MathHelper怎么用?Java MathHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MathHelper类属于net.minecraft.server包,在下文中一共展示了MathHelper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBiteChance
import net.minecraft.server.MathHelper; //导入依赖的package包/类
public double getBiteChance() {
EntityFishingHook hook = getHandle();
if (this.biteChance == -1) {
if (hook.world.isRainingAt(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ))) {
return 1/300.0;
}
return 1/500.0;
}
return this.biteChance;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:12,代码来源:CraftFish.java
示例2: setDirection
import net.minecraft.server.MathHelper; //导入依赖的package包/类
public void setDirection(Vector direction) {
Validate.notNull(direction, "Direction can not be null");
double x = direction.getX();
double y = direction.getY();
double z = direction.getZ();
double magnitude = (double) MathHelper.sqrt(x * x + y * y + z * z);
getHandle().dirX = x / magnitude;
getHandle().dirY = y / magnitude;
getHandle().dirZ = z / magnitude;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:11,代码来源:CraftFireball.java
示例3: getBiteChance
import net.minecraft.server.MathHelper; //导入依赖的package包/类
public double getBiteChance() {
EntityFishingHook hook = getHandle();
if (this.biteChance == -1) {
if (hook.world.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ)))) {
return 1/300.0;
}
return 1/500.0;
}
return this.biteChance;
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:12,代码来源:CraftFish.java
示例4: activateEntities
import net.minecraft.server.MathHelper; //导入依赖的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();
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();
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:45,代码来源:ActivationRange.java
示例5: checkIfActive
import net.minecraft.server.MathHelper; //导入依赖的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.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
if ( isActive && !entity.world.areChunksLoaded( x, 0, z, 16 ) )
{
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:40,代码来源:ActivationRange.java
示例6: activateEntities
import net.minecraft.server.MathHelper; //导入依赖的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();
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();
}
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:45,代码来源:ActivationRange.java
示例7: checkIfActive
import net.minecraft.server.MathHelper; //导入依赖的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.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
{
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:41,代码来源:ActivationRange.java
示例8: activateEntities
import net.minecraft.server.MathHelper; //导入依赖的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();
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 ( EntityHuman player : world.players )
{
player.activatedTick = MinecraftServer.currentTick;
maxBB = player.getBoundingBox().grow( maxRange, 256, maxRange );
miscBB = player.getBoundingBox().grow( miscActivationRange, 256, miscActivationRange );
animalBB = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
monsterBB = player.getBoundingBox().grow( 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();
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:45,代码来源:ActivationRange.java
示例9: getBiteChance
import net.minecraft.server.MathHelper; //导入依赖的package包/类
public double getBiteChance() {
EntityFishingHook hook = getHandle();
if (this.biteChance == -1) {
if (hook.world.F(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ))) {
return 1/300.0;
}
return 1/500.0;
}
return this.biteChance;
}
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:12,代码来源:CraftFish.java
示例10: checkIfActive
import net.minecraft.server.MathHelper; //导入依赖的package包/类
/**
* Checks if the entity is active for this tick.
*
* @param entity
* @return
*/
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
// Never safe to skip fireworks or entities not yet added to chunk
// PAIL: inChunk
if ( !entity.aa || entity instanceof EntityFireworks ) {
SpigotTimings.checkIfActiveTimer.stopTiming();
return true;
}
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.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
{
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:48,代码来源:ActivationRange.java
注:本文中的net.minecraft.server.MathHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论