Fix Bug
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-22 19:55:32 -04:00
parent cc4795c9d3
commit 49d58af604

View File

@ -26,19 +26,34 @@ import java.util.List;
import java.util.Objects;
public class EnergyProviderBlockEntity extends BlockEntity implements EnergyProvider, BlockEntityClientSerializable, Tickable {
private static volatile boolean isTicking = false;
private static final List<EnergyProviderBlockEntity> scheduledTicks = new ArrayList<>();
private static final List<EnergyProviderBlockEntity> scheduledTicksNext = new ArrayList<>();
public static void tickScheduled() {
isTicking = true;
Collections.shuffle(scheduledTicks);
for (EnergyProviderBlockEntity provider : scheduledTicks) {
provider.serverTick();
}
scheduledTicks.clear();
isTicking = false;
for (EnergyProviderBlockEntity entity : scheduledTicksNext) {
entity.schedule();
}
scheduledTicksNext.clear();
}
private void schedule() {
if (!scheduledTicks.contains(this)) {
scheduledTicks.add(this);
List<EnergyProviderBlockEntity> list;
if (isTicking) {
list = scheduledTicksNext;
} else {
list = scheduledTicks;
}
if (!list.contains(this)) {
list.add(this);
}
}