Try to get around palette issue
This commit is contained in:
parent
ed1d9b150c
commit
0c93939766
@ -23,10 +23,10 @@ public class MatterGrid implements IMatterGridListener {
|
||||
private final Set<IMatterGridCell> cells = new HashSet<>();
|
||||
private final Set<IMatterGridListener> listeners = new HashSet<>();
|
||||
|
||||
private static final Set<Supplier<Boolean>> discovering_neighbours = new HashSet<>();
|
||||
private static final WeakHashMap<Level, Set<Supplier<Boolean>>> discovering_neighbours = new WeakHashMap<>();
|
||||
|
||||
public static void scheduleDiscoverNeighbours(IMatterGridCell cell, BlockPos pos, Level level) {
|
||||
discovering_neighbours.add(() -> !cell.isValidMatterCell() || cell.connectOrCreateMatterGrid(pos, level, true));
|
||||
discovering_neighbours.computeIfAbsent(level, (key) -> new HashSet<>()).add(() -> !cell.isValidMatterCell() || cell.connectOrCreateMatterGrid(pos, level, true));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@ -40,11 +40,16 @@ public class MatterGrid implements IMatterGridListener {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void discoverNeighbours(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END && discovering_neighbours.size() != 0) {
|
||||
public static void discoverNeighbours(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START)
|
||||
return;
|
||||
|
||||
var set = discovering_neighbours.get(event.world);
|
||||
|
||||
if (set != null && set.size() != 0) {
|
||||
ArrayList<Supplier<Boolean>> invalid = new ArrayList<>();
|
||||
|
||||
for (Supplier<Boolean> cell : discovering_neighbours) {
|
||||
for (Supplier<Boolean> cell : set) {
|
||||
if (cell.get()) {
|
||||
invalid.add(cell);
|
||||
}
|
||||
@ -52,9 +57,13 @@ public class MatterGrid implements IMatterGridListener {
|
||||
|
||||
if (invalid.size() != 0) {
|
||||
for (Supplier<Boolean> cell : invalid) {
|
||||
discovering_neighbours.remove(cell);
|
||||
set.remove(cell);
|
||||
}
|
||||
}
|
||||
|
||||
if (set.size() == 0) {
|
||||
discovering_neighbours.remove(event.world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user