Skip to content

Commit 2e9744c

Browse files
committed
remove redundant thread safety as main thread is forced before the listened events are posted
1 parent 1e86eff commit 2e9744c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/kotlin/com/lambda/interaction/request/breaking/BreakInfo.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import com.lambda.interaction.construction.context.BreakContext
2121
import com.lambda.interaction.request.ActionInfo
2222
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
2323
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak
24+
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary
25+
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary
2426
import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta
2527
import com.lambda.util.Describable
2628
import com.lambda.util.NamedEnum
@@ -72,24 +74,21 @@ data class BreakInfo(
7274
}
7375

7476
// Post Processing
75-
@Volatile
7677
var broken = false; private set
7778
private var item: ItemEntity? = null
7879
val callbacksCompleted
79-
@Synchronized get() = broken && (request.onItemDrop == null || item != null)
80+
get() = broken && (request.onItemDrop == null || item != null)
8081

81-
@Synchronized
8282
fun internalOnBreak() {
83-
if (type != BreakType.Rebreak) broken = true
83+
if (type != Rebreak) broken = true
8484
item?.let { item ->
8585
request.onItemDrop?.invoke(item)
8686
}
8787
}
8888

89-
@Synchronized
9089
fun internalOnItemDrop(item: ItemEntity) {
91-
if (type != BreakType.Rebreak) this.item = item
92-
if (broken || type == BreakType.Rebreak) {
90+
if (type != Rebreak) this.item = item
91+
if (broken || type == Rebreak) {
9392
request.onItemDrop?.invoke(item)
9493
}
9594
}
@@ -98,7 +97,7 @@ data class BreakInfo(
9897
updatedThisTick = true
9998
this.context = context
10099
request?.let { this.request = it }
101-
if (type == BreakType.RedundantSecondary) type = BreakType.Secondary
100+
if (type == RedundantSecondary) type = Secondary
102101
}
103102

104103
fun resetCallbacks() {

src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import net.minecraft.util.math.Box
9393
import net.minecraft.world.BlockView
9494
import kotlin.math.max
9595

96+
// ToDo: Fix root cause of breaks becoming redundant while the actual state is empty
9697
object BreakManager : RequestHandler<BreakRequest>(
9798
0,
9899
TickEvent.Pre,

0 commit comments

Comments
 (0)