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


Java AreaReference.equals方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:46,代码来源:PlayerManager.java

示例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);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:57,代码来源:PlayerManager.java


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