本文整理汇总了Java中ethanjones.cubes.world.reference.multi.AreaReferenceSet类的典型用法代码示例。如果您正苦于以下问题:Java AreaReferenceSet类的具体用法?Java AreaReferenceSet怎么用?Java AreaReferenceSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AreaReferenceSet类属于ethanjones.cubes.world.reference.multi包,在下文中一共展示了AreaReferenceSet类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPosition
import ethanjones.cubes.world.reference.multi.AreaReferenceSet; //导入依赖的package包/类
public void setPosition(Vector3 newPosition, Vector3 newAngle, boolean clientKnows) {
synchronized (this) {
setPositionIf(newPosition, clientKnows, newAngle);
AreaReference newRef = new AreaReference().setFromPositionVector3(newPosition);
AreaReference oldRef = new AreaReference().setFromPositionVector3(client.getPlayer().position);
if (!newRef.equals(oldRef)) {
WorldRegion newRegion = new WorldRegion(newRef, loadDistance);
WorldRegion oldRegion = new WorldRegion(oldRef, loadDistance);
AreaReferenceSet difference = new AreaReferenceSet();
difference.addAll(newRegion.getAreaReferences());
difference.removeAll(oldRegion.getAreaReferences());
for (AreaReference areaReference : difference) {
Area area = server.world.getArea(areaReference, false); // don't
// request
// individually,
// request
// in
// a
// batch
if (area != null && area.featuresGenerated())
sendArea(area);
}
server.world.requestRegion(difference, null);
PacketEntityAdd packet;
setPositionFor1(packet);
playerArea.setFromAreaReference(newRef);
}
client.getPlayer().position.set(newPosition);
client.getPlayer().angle.set(newAngle);
if (client.getPlayer().position.y < -10f)
teleportToSpawn();
if (!clientKnows)
NetworkingManager.sendPacketToClient(new PacketPlayerMovement(client.getPlayer()), client);
NetworkingManager.sendPacketToOtherClients(new PacketOtherPlayerMovement(client.getPlayer()), client);
}
}
示例2: setPosition
import ethanjones.cubes.world.reference.multi.AreaReferenceSet; //导入依赖的package包/类
public void setPosition(Vector3 newPosition, Vector3 newAngle, boolean clientKnows) {
synchronized (this) {
if (newPosition != null) {
float x = newPosition.x, y = newPosition.y, z = newPosition.z;
if (new PlayerMovementEvent(client.getPlayer(), newPosition).post().isCanceled()) {
// cancel move
if (!clientKnows) return;
// client knows new position, need to send old position
newPosition = client.getPlayer().position.cpy();
newAngle = client.getPlayer().angle.cpy();
clientKnows = false;
} else if (newPosition.x != x || newPosition.y != y || newPosition.z != z) {
// event handler changed new position
clientKnows = false;
}
}
if (newPosition == null) newPosition = client.getPlayer().position.cpy();
if (newAngle == null) newAngle = client.getPlayer().angle.cpy();
AreaReference newRef = new AreaReference().setFromPositionVector3(newPosition);
AreaReference oldRef = new AreaReference().setFromPositionVector3(client.getPlayer().position);
if (!newRef.equals(oldRef)) {
WorldRegion newRegion = new WorldRegion(newRef, loadDistance);
WorldRegion oldRegion = new WorldRegion(oldRef, loadDistance);
AreaReferenceSet difference = new AreaReferenceSet();
difference.addAll(newRegion.getAreaReferences());
difference.removeAll(oldRegion.getAreaReferences());
for (AreaReference areaReference : difference) {
Area area = server.world.getArea(areaReference, false); //don't request individually, request in a batch
if (area != null && area.featuresGenerated()) sendArea(area);
}
server.world.requestRegion(difference, null);
for (Entity entity : Cubes.getServer().world.entities.values()) {
if (!(entity instanceof Player) && newRegion.contains(entity.position) && !oldRegion.contains(entity.position)) {
PacketEntityAdd packet = new PacketEntityAdd();
packet.entity = entity;
NetworkingManager.sendPacketToClient(packet, client);
}
}
playerArea.setFromAreaReference(newRef);
}
client.getPlayer().position.set(newPosition);
client.getPlayer().angle.set(newAngle);
if (client.getPlayer().position.y < -10f) teleportToSpawn();
if (!clientKnows) NetworkingManager.sendPacketToClient(new PacketPlayerMovement(client.getPlayer()), client);
NetworkingManager.sendPacketToOtherClients(new PacketOtherPlayerMovement(client.getPlayer()), client);
}
}