mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-08 23:06:58 -04:00
Added delay for screen multiblock check on clients, to make it less likely that some tile entities don't have their data when the check is performed; hopefully fixes #560.
This commit is contained in:
parent
0a58af6d84
commit
ffc62381f1
@ -9,7 +9,7 @@ import li.cil.oc.util.mods.{BuildCraft, Mods}
|
||||
import li.cil.oc.util.{Color, PackedColor, Tooltip}
|
||||
import li.cil.oc.{Localization, OpenComputers, Settings}
|
||||
import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor}
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.{EntityLivingBase, Entity}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.entity.projectile.EntityArrow
|
||||
import net.minecraft.item.{EnumRarity, ItemStack}
|
||||
@ -298,6 +298,14 @@ class Screen(val parent: SimpleDelegator, val tier: Int) extends RedstoneAware w
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def addedByEntity(world: World, x: Int, y: Int, z: Int, player: EntityLivingBase, stack: ItemStack) {
|
||||
super.addedByEntity(world, x, y, z, player, stack)
|
||||
world.getBlockTileEntity(x, y, z) match {
|
||||
case screen: tileentity.Screen => screen.delayUntilCheckForMultiBlock = 0
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
|
||||
override def rightClick(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
|
||||
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = rightClick(world, x, y, z, player, side, hitX, hitY, hitZ, force = false)
|
||||
|
||||
|
@ -31,6 +31,13 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
|
||||
*/
|
||||
var shouldCheckForMultiBlock = true
|
||||
|
||||
/**
|
||||
* On the client we delay connecting screens a little, to avoid glitches
|
||||
* when not all tile entity data for a chunk has been received within a
|
||||
* single tick (meaning some screens are still "missing").
|
||||
*/
|
||||
var delayUntilCheckForMultiBlock = 40
|
||||
|
||||
var width, height = 1
|
||||
|
||||
var origin = this
|
||||
@ -149,7 +156,7 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
|
||||
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (shouldCheckForMultiBlock && (isClient || isConnected)) {
|
||||
if (shouldCheckForMultiBlock && ((isClient && isClientReadyForMultiBlockCheck) || (isServer && isConnected))) {
|
||||
// Make sure we merge in a deterministic order, to avoid getting
|
||||
// different results on server and client due to the update order
|
||||
// differing between the two. This also saves us from having to save
|
||||
@ -232,6 +239,11 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
|
||||
}
|
||||
}
|
||||
|
||||
private def isClientReadyForMultiBlockCheck = if (delayUntilCheckForMultiBlock > 0) {
|
||||
delayUntilCheckForMultiBlock -= 1
|
||||
false
|
||||
} else true
|
||||
|
||||
override def dispose() {
|
||||
super.dispose()
|
||||
screens.clone().foreach(_.checkMultiBlock())
|
||||
|
Loading…
x
Reference in New Issue
Block a user