本文整理汇总了Java中com.flowpowered.math.GenericMath类的典型用法代码示例。如果您正苦于以下问题:Java GenericMath类的具体用法?Java GenericMath怎么用?Java GenericMath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericMath类属于com.flowpowered.math包,在下文中一共展示了GenericMath类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onClientPlayerPosition
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@PacketHandler
public void onClientPlayerPosition(PCSession session, ClientPlayerPositionPacket packet) {
final Entity entity = session.getEntity();
final double deltaX = packet.getX() - entity.x;
final double deltaY = packet.getY() - entity.y;
final double deltaZ = packet.getZ() - entity.z;
entity.x = packet.getX();
entity.y = packet.getY();
entity.z = packet.getZ();
entity.yaw = packet.getYaw();
entity.headYaw = entity.yaw;
entity.pitch = packet.getPitch();
SpongeGame.instance.getServer().getNetwork().getSessions().stream().filter(otherSession -> otherSession.isConnected()
&& ((PCSession) otherSession).getPacketProtocol().getProtocolPhase() == ProtocolPhase.INGAME).forEach(otherSession -> {
if (otherSession != session) {
otherSession.send(new ServerEntityPositionRotationPacket(entity.id, deltaX, deltaY, deltaZ, GenericMath.floor(packet.getYaw()
* 256.0F / 360.0F), GenericMath.floor(packet.getPitch() * 256.0F / 360.0F), false));
otherSession.send(new ServerEntityHeadLookPacket(entity.id, GenericMath.floor(entity.headYaw * 256.0F / 360.0F)));
}
}
);
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:26,代码来源:IngameHandlers.java
示例2: onClientPlayerRotation
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@PacketHandler
public void onClientPlayerRotation(PCSession session, ClientPlayerRotationPacket packet) {
final Entity entity = session.getEntity();
entity.yaw = packet.getYaw();
entity.headYaw = entity.yaw;
entity.pitch = packet.getPitch();
SpongeGame.instance.getServer().getNetwork().getSessions().stream().filter(otherSession -> otherSession.isConnected()
&& ((PCSession) otherSession).getPacketProtocol().getProtocolPhase() == ProtocolPhase.INGAME).forEach(otherSession -> {
if (otherSession != session) {
otherSession.send(new ServerEntityRotationPacket(entity.id, GenericMath.floor(packet.getYaw() * 256.0F / 360.0F),
GenericMath.floor(packet.getPitch() * 256.0F / 360.0F), false));
otherSession.send(new ServerEntityHeadLookPacket(entity.id, GenericMath.floor(entity.headYaw * 256.0F / 360.0F)));
}
}
);
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:19,代码来源:IngameHandlers.java
示例3: onClientPlayerPositionRotation
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@PacketHandler
public void onClientPlayerPositionRotation(PCSession session, ClientPlayerPositionRotationPacket packet) {
final Entity entity = session.getEntity();
final double deltaX = packet.getX() - entity.x;
final double deltaY = packet.getY() - entity.y;
final double deltaZ = packet.getZ() - entity.z;
entity.x = packet.getX();
entity.y = packet.getY();
entity.z = packet.getZ();
entity.yaw = packet.getYaw();
entity.headYaw = entity.yaw;
entity.pitch = packet.getPitch();
SpongeGame.instance.getServer().getNetwork().getSessions().stream().filter(otherSession -> otherSession.isConnected()
&& ((PCSession) otherSession).getPacketProtocol().getProtocolPhase() == ProtocolPhase.INGAME).forEach(otherSession -> {
if (otherSession != session) {
otherSession.send(new ServerEntityPositionRotationPacket(entity.id, deltaX, deltaY, deltaZ, GenericMath.floor(packet.getYaw()
* 256.0F / 360.0F), GenericMath.floor(packet.getPitch() * 256.0F / 360.0F), false));
otherSession.send(new ServerEntityHeadLookPacket(entity.id, GenericMath.floor(entity.headYaw * 256.0F / 360.0F)));
}
}
);
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:27,代码来源:IngameHandlers.java
示例4: 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
示例5: 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
示例6: testA
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@Test
public void testA() {
final LanternScriptGameRegistry scriptGameRegistry = LanternScriptGameRegistry.get();
final Script<FloatValueProvider> script = scriptGameRegistry.compile("return 0.5f", FloatValueProvider.class);
//noinspection ConstantConditions
assertEquals(0.5, script.get().get(null), GenericMath.FLT_EPSILON);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:ScriptTest.java
示例7: testB
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@Test
public void testB() {
final LanternScriptGameRegistry scriptGameRegistry = LanternScriptGameRegistry.get();
final Script<DoubleValueProvider> script = scriptGameRegistry.compile("return 0.999999d", DoubleValueProvider.class);
//noinspection ConstantConditions
assertEquals(0.999999d, script.get().get(null), GenericMath.DBL_EPSILON);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:ScriptTest.java
示例8: test
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@Test
public void test() {
final double valueA = 10.684;
final int valueB = 500;
final AbstractModule module = new AbstractModule() {
@Override
protected void configure() {
install(new InjectionPointProvider());
final OptionParser optionParser = new OptionParser();
optionParser.allowsUnrecognizedOptions();
install(new OptionModule() {
@Override
protected void configure0() {
bindArguments().toInstance(new String[] {
"--my-option=" + valueB,
"--my-other-option=" + valueA
});
bindParser().toInstance(optionParser);
}
});
}
};
final Injector injector = Guice.createInjector(module);
final TestObject testObject = injector.getInstance(TestObject.class);
assertEquals(testObject.myOtherOption, valueA, GenericMath.DBL_EPSILON);
assertEquals(testObject.myOption, valueB);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:28,代码来源:InjectionTest.java
示例9: getHighestYAt
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@Override
public int getHighestYAt(int x, int z) {
checkRange(x, this.blockMin.getY(), z);
final int y = this.extent.getHighestYAt(x, z);
return GenericMath.clamp(y, this.blockMin.getY(), this.blockMax.getY());
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:SoftBufferExtentViewDownsize.java
示例10: getPrecipitationLevelAt
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
@Override
public int getPrecipitationLevelAt(int x, int z) {
checkRange(x, this.blockMin.getY(), z);
final int y = this.extent.getPrecipitationLevelAt(x, z);
return GenericMath.clamp(y, this.blockMin.getY(), this.blockMax.getY());
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:SoftBufferExtentViewDownsize.java
示例11: setViewDistance
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
public void setViewDistance(int viewDistance) {
this.viewDistance = viewDistance == USE_SERVER_VIEW_DISTANCE ? viewDistance :
GenericMath.clamp(viewDistance, MIN_VIEW_DISTANCE, MAX_VIEW_DISTANCE);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:WorldConfig.java
示例12: setViewDistance
import com.flowpowered.math.GenericMath; //导入依赖的package包/类
public void setViewDistance(int viewDistance) {
this.worlds.viewDistance = GenericMath.clamp(viewDistance, MIN_VIEW_DISTANCE, MAX_VIEW_DISTANCE);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:GlobalConfig.java
示例13: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论