Fix field synchronizer set not reacting properly to global markDirty()
This commit is contained in:
parent
8b7363b130
commit
a5dcf5a331
@ -1546,8 +1546,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) {
|
fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) {
|
||||||
event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
onceServer {
|
||||||
it.invalidateNetworkState()
|
event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||||
|
it.invalidateNetworkState()
|
||||||
|
it.recreateExoPackMenu()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1604,8 +1607,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
it.invalidateNetworkState()
|
it.invalidateNetworkState()
|
||||||
event.original.invalidateCaps()
|
event.original.invalidateCaps()
|
||||||
|
|
||||||
if (SERVER_IS_LIVE) {
|
onceServer {
|
||||||
it.tickList.timer(20) {
|
event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||||
|
it.invalidateNetworkState()
|
||||||
it.recreateExoPackMenu()
|
it.recreateExoPackMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1700,6 +1700,36 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
|||||||
super.remove()
|
super.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun markDirty() {
|
||||||
|
check(!isRemoved) { "Field was removed" }
|
||||||
|
|
||||||
|
if (isRemote || endpoints.isEmpty())
|
||||||
|
return
|
||||||
|
|
||||||
|
isDirty = true
|
||||||
|
|
||||||
|
val endpoints = LinkedList<MutableList<Pair<Any?, (DataOutputStream) -> Unit>>>()
|
||||||
|
|
||||||
|
forEachEndpoint {
|
||||||
|
endpoints.add(it.getSetBacklog(this))
|
||||||
|
it.addDirtyField(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoints.forEach {
|
||||||
|
it.clear()
|
||||||
|
it.add(null to ClearBacklogEntry)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (value in backingSet) {
|
||||||
|
val valueCopy = codec.copy(value)
|
||||||
|
val pair: Pair<Any?, (DataOutputStream) -> Unit> = valueCopy to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, valueCopy) }
|
||||||
|
|
||||||
|
endpoints.forEach {
|
||||||
|
it.add(pair)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun markDirty(endpoint: Endpoint) {
|
override fun markDirty(endpoint: Endpoint) {
|
||||||
super.markDirty(endpoint)
|
super.markDirty(endpoint)
|
||||||
|
|
||||||
@ -1708,7 +1738,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
|||||||
it.add(null to ClearBacklogEntry)
|
it.add(null to ClearBacklogEntry)
|
||||||
|
|
||||||
for (value in backingSet) {
|
for (value in backingSet) {
|
||||||
it.add(value to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, value) })
|
val valueCopy = codec.copy(value)
|
||||||
|
it.add(valueCopy to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, valueCopy) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1950,14 +1981,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
|||||||
for ((key, value) in backingMap) {
|
for ((key, value) in backingMap) {
|
||||||
val valueCopy = valueCodec.copy(value)
|
val valueCopy = valueCodec.copy(value)
|
||||||
|
|
||||||
val action = { it: DataOutputStream ->
|
val action = key to { it: DataOutputStream ->
|
||||||
it.write(ChangesetAction.ADD.ordinal + 1)
|
it.write(ChangesetAction.ADD.ordinal + 1)
|
||||||
keyCodec.write(it, key)
|
keyCodec.write(it, key)
|
||||||
valueCodec.write(it, valueCopy)
|
valueCodec.write(it, valueCopy)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (backlog in backlogs) {
|
for (backlog in backlogs) {
|
||||||
backlog.add(key to action)
|
backlog.add(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user