mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-06-03 11:22:07 +00:00
Avoid using TickScheduler unless needed
Fixes #2190, or at least works around the problems in BuildingGadgets enough.
This commit is contained in:
+2
-2
@@ -115,7 +115,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
|
||||
void queueRefreshPeripheral() {
|
||||
refreshPeripheral = true;
|
||||
TickScheduler.schedule(tickToken);
|
||||
getLevel().scheduleTick(getBlockPos(), getBlockState().getBlock(), 0);
|
||||
}
|
||||
|
||||
InteractionResult use(Player player) {
|
||||
@@ -183,7 +183,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
|
||||
void scheduleConnectionsChanged() {
|
||||
refreshConnections = true;
|
||||
TickScheduler.schedule(tickToken);
|
||||
getLevel().scheduleTick(getBlockPos(), getBlockState().getBlock(), 0);
|
||||
}
|
||||
|
||||
void connectionsChanged() {
|
||||
|
||||
+2
-2
@@ -115,7 +115,7 @@ public class WiredModemFullBlockEntity extends BlockEntity {
|
||||
|
||||
void queueRefreshPeripheral(Direction facing) {
|
||||
invalidSides |= 1 << facing.ordinal();
|
||||
TickScheduler.schedule(tickToken);
|
||||
getLevel().scheduleTick(getBlockPos(), getBlockState().getBlock(), 0);
|
||||
}
|
||||
|
||||
public InteractionResult use(Player player) {
|
||||
@@ -190,7 +190,7 @@ public class WiredModemFullBlockEntity extends BlockEntity {
|
||||
|
||||
private void scheduleConnectionsChanged() {
|
||||
refreshConnections = true;
|
||||
TickScheduler.schedule(tickToken);
|
||||
getLevel().scheduleTick(getBlockPos(), getBlockState().getBlock(), 0);
|
||||
}
|
||||
|
||||
private void connectionsChanged() {
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public final class RedstoneRelayBlockEntity extends BlockEntity {
|
||||
|
||||
// If the input has changed, and we're not currently in update(), then schedule a new tick so we can queue a
|
||||
// redstone event.
|
||||
if (changed && !ticking) TickScheduler.schedule(tickToken);
|
||||
if (changed && !ticking) getLevel().scheduleTick(getBlockPos(), getBlockState().getBlock(), 0);
|
||||
}
|
||||
|
||||
private ComputerSide mapSide(Direction globalSide) {
|
||||
|
||||
@@ -27,6 +27,10 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
* We use this when modems and other peripherals change a block in a different thread.
|
||||
*/
|
||||
public final class TickScheduler {
|
||||
// FIXME: We also use this to schedule ticks in {@link BlockEntity#clearRemoved()}, as the chunk is not fully
|
||||
// loaded at this point ({@link LevelChunk#registerTickContainerInLevel(ServerLevel)} has not been called). This
|
||||
// delays this a tick, which works in practice, but relies on us winning a race condition.
|
||||
// It might be worth using Forge's BlockEntity.onLoad or having some custom hook based on chunk load.
|
||||
private TickScheduler() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user