本文整理匯總了Java中ethanjones.cubes.world.reference.AreaReference.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java AreaReference.equals方法的具體用法?Java AreaReference.equals怎麽用?Java AreaReference.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ethanjones.cubes.world.reference.AreaReference
的用法示例。
在下文中一共展示了AreaReference.equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setPosition
import ethanjones.cubes.world.reference.AreaReference; //導入方法依賴的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.AreaReference; //導入方法依賴的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);
}
}