From 0c778af9f109a34d1519e05e9ac7a301c8430829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 29 Nov 2013 14:29:51 +0100 Subject: [PATCH] fixed a fix; fixed power updates sending every time in robot gui (forgot saving last sent state...) --- li/cil/oc/client/gui/Robot.scala | 4 ++-- li/cil/oc/common/PacketBuilder.scala | 5 ++--- li/cil/oc/common/container/Robot.scala | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/li/cil/oc/client/gui/Robot.scala b/li/cil/oc/client/gui/Robot.scala index e59a8be47..a8079923c 100644 --- a/li/cil/oc/client/gui/Robot.scala +++ b/li/cil/oc/client/gui/Robot.scala @@ -81,6 +81,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten protected override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) { drawBufferLayer() + GL11.glPushAttrib(0xFFFFFFFF) // Me lazy... prevents NEI render glitch. if (isPointInRegion(powerX, powerY, powerWidth, powerHeight, mouseX, mouseY)) { val tooltip = new java.util.ArrayList[String] val format = StatCollector.translateToLocal(Settings.namespace + "gui.Robot.Power") + ": %d%% (%d/%d)" @@ -91,13 +92,12 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) } if (powerButton.func_82252_a) { - GL11.glPushAttrib(0xFFFFFFFF) // Me lazy... prevents NEI render glitch. val tooltip = new java.util.ArrayList[String] val which = if (robot.isRunning) "gui.Robot.TurnOff" else "gui.Robot.TurnOn" tooltip.add(StatCollector.translateToLocal(Settings.namespace + which)) drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) - GL11.glPopAttrib() } + GL11.glPopAttrib() } override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { diff --git a/li/cil/oc/common/PacketBuilder.scala b/li/cil/oc/common/PacketBuilder.scala index 243147f5c..5e7f0f371 100644 --- a/li/cil/oc/common/PacketBuilder.scala +++ b/li/cil/oc/common/PacketBuilder.scala @@ -14,7 +14,6 @@ import net.minecraft.world.World import net.minecraftforge.common.ForgeDirection import scala.collection.convert.WrapAsScala._ -/** Utility class for packet creation. */ class PacketBuilder(packetType: PacketType.Value, private val stream: ByteArrayOutputStream = new ByteArrayOutputStream) extends DataOutputStream(stream) { writeByte(packetType.id) @@ -39,7 +38,7 @@ class PacketBuilder(packetType: PacketType.Value, private val stream: ByteArrayO def sendToAllPlayers() = PacketDispatcher.sendPacketToAllPlayers(packet) - def sendToNearbyPlayers(t: TileEntity, range: Double = 64): Unit = sendToNearbyPlayers(t.world, t.x + 0.5, t.y + 0.5, t.z + 0.5, range) + def sendToNearbyPlayers(t: TileEntity, range: Double = 1024): Unit = sendToNearbyPlayers(t.world, t.x + 0.5, t.y + 0.5, t.z + 0.5, range) def sendToNearbyPlayers(world: World, x: Double, y: Double, z: Double, range: Double) { val dimension = world.provider.dimensionId @@ -48,7 +47,7 @@ class PacketBuilder(packetType: PacketType.Value, private val stream: ByteArrayO for (player <- manager.playerEntityList.map(_.asInstanceOf[EntityPlayerMP]) if player.dimension == dimension) { val playerSpecificRange = range min ((manager.getViewDistance min PacketBuilder.tryGetPlayerRenderDistance(player)) * 16) if (player.getDistanceSq(x, y, z) < playerSpecificRange * playerSpecificRange) { - player.playerNetServerHandler.sendPacketToPlayer(packet) + sendToPlayer(player.asInstanceOf[Player]) } } } diff --git a/li/cil/oc/common/container/Robot.scala b/li/cil/oc/common/container/Robot.scala index ab2d14112..c215b877f 100644 --- a/li/cil/oc/common/container/Robot.scala +++ b/li/cil/oc/common/container/Robot.scala @@ -21,11 +21,12 @@ class Robot(playerInventory: InventoryPlayer, robot: tileentity.Robot) extends P addPlayerInventorySlots(8, 160) - var lastSentBuffer = -1 + var lastSentBuffer = Double.NegativeInfinity override def detectAndSendChanges() { super.detectAndSendChanges() if ((robot.globalBuffer - lastSentBuffer).abs > 1) { + lastSentBuffer = robot.globalBuffer ServerPacketSender.sendPowerState(robot) } }