mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Tweaked nearby player check for text buffer update sending.
Should ensure remote terminals work properly at max range (assuming server rack is chunk loaded).
This commit is contained in:
parent
43a734e110
commit
aec5457739
@ -44,17 +44,17 @@ abstract class PacketBuilder(stream: OutputStream) extends DataOutputStream(stre
|
||||
|
||||
def sendToAllPlayers() = OpenComputers.channel.sendToAll(packet)
|
||||
|
||||
def sendToPlayersNearTileEntity(t: TileEntity, range: Double = 1024): Unit = sendToNearbyPlayers(t.getWorldObj, t.xCoord + 0.5, t.yCoord + 0.5, t.zCoord + 0.5, range)
|
||||
def sendToPlayersNearTileEntity(t: TileEntity, range: Option[Double] = None): Unit = sendToNearbyPlayers(t.getWorldObj, t.xCoord + 0.5, t.yCoord + 0.5, t.zCoord + 0.5, range)
|
||||
|
||||
def sendToPlayersNearHost(host: EnvironmentHost, range: Double = 1024): Unit = sendToNearbyPlayers(host.world, host.xPosition, host.yPosition, host.zPosition, range)
|
||||
def sendToPlayersNearHost(host: EnvironmentHost, range: Option[Double] = None): Unit = sendToNearbyPlayers(host.world, host.xPosition, host.yPosition, host.zPosition, range)
|
||||
|
||||
def sendToNearbyPlayers(world: World, x: Double, y: Double, z: Double, range: Double) {
|
||||
def sendToNearbyPlayers(world: World, x: Double, y: Double, z: Double, range: Option[Double]) {
|
||||
val dimension = world.provider.dimensionId
|
||||
val server = FMLCommonHandler.instance.getMinecraftServerInstance
|
||||
val manager = server.getConfigurationManager
|
||||
for (player <- manager.playerEntityList.map(_.asInstanceOf[EntityPlayerMP]) if player.dimension == dimension) {
|
||||
val playerRenderDistance = Int.MaxValue // ObfuscationReflectionHelper.getPrivateValue(classOf[EntityPlayerMP], player, "renderDistance").asInstanceOf[Integer]
|
||||
val playerSpecificRange = math.min(range, (manager.getViewDistance min playerRenderDistance) * 16)
|
||||
val playerRenderDistance = 16 // ObfuscationReflectionHelper.getPrivateValue(classOf[EntityPlayerMP], player, "renderDistance").asInstanceOf[Integer]
|
||||
val playerSpecificRange = range.getOrElse((manager.getViewDistance min playerRenderDistance) * 16.0)
|
||||
if (player.getDistanceSq(x, y, z) < playerSpecificRange * playerSpecificRange) {
|
||||
sendToPlayer(player)
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class TextBuffer(val host: EnvironmentHost) extends prefab.ManagedEnvironment wi
|
||||
}
|
||||
|
||||
this.synchronized {
|
||||
_pendingCommands.foreach(_.sendToPlayersNearHost(host))
|
||||
_pendingCommands.foreach(_.sendToPlayersNearHost(host, Option(Settings.get.maxWirelessRange * Settings.get.maxWirelessRange)))
|
||||
_pendingCommands = None
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ object PacketSender {
|
||||
pb.writeDouble(event.getZ)
|
||||
}
|
||||
|
||||
pb.sendToPlayersNearHost(host, 64)
|
||||
pb.sendToPlayersNearHost(host, Option(64))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ object PacketSender {
|
||||
pb.writeTileEntity(t.proxy)
|
||||
pb.writeInt(t.animationTicksTotal)
|
||||
|
||||
pb.sendToPlayersNearTileEntity(t, 64)
|
||||
pb.sendToPlayersNearTileEntity(t, Option(64))
|
||||
}
|
||||
|
||||
def sendRobotAnimateTurn(t: tileentity.Robot) {
|
||||
@ -276,7 +276,7 @@ object PacketSender {
|
||||
pb.writeByte(t.turnAxis)
|
||||
pb.writeInt(t.animationTicksTotal)
|
||||
|
||||
pb.sendToPlayersNearTileEntity(t, 64)
|
||||
pb.sendToPlayersNearTileEntity(t, Option(64))
|
||||
}
|
||||
|
||||
def sendRobotInventory(t: tileentity.Robot, slot: Int, stack: ItemStack) {
|
||||
@ -295,7 +295,7 @@ object PacketSender {
|
||||
pb.writeTileEntity(t.proxy)
|
||||
pb.writeInt(t.selectedSlot)
|
||||
|
||||
pb.sendToPlayersNearTileEntity(t, 16)
|
||||
pb.sendToPlayersNearTileEntity(t, Option(16))
|
||||
}
|
||||
|
||||
def sendRotatableState(t: Rotatable) {
|
||||
@ -313,7 +313,7 @@ object PacketSender {
|
||||
|
||||
pb.writeTileEntity(t)
|
||||
|
||||
pb.sendToPlayersNearTileEntity(t, 64)
|
||||
pb.sendToPlayersNearTileEntity(t, Option(64))
|
||||
}
|
||||
|
||||
def appendTextBufferColorChange(pb: PacketBuilder, foreground: PackedColor.Color, background: PackedColor.Color) {
|
||||
@ -457,6 +457,6 @@ object PacketSender {
|
||||
pb.writeShort(frequency.toShort)
|
||||
pb.writeShort(duration.toShort)
|
||||
|
||||
pb.sendToNearbyPlayers(world, x, y, z, 16)
|
||||
pb.sendToNearbyPlayers(world, x, y, z, Option(16))
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user