Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复grid tick逻辑 #1000

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class ChargeCollectorManager {
private final Map<BlockPos, ChargeCollectorBlockEntity> chargeCollectors = new HashMap<>();
private static final Map<Level, ChargeCollectorManager> INSTANCES = new HashMap<>();

@Getter
private final Level level;

public ChargeCollectorManager(Level level) {
Expand Down Expand Up @@ -81,7 +81,7 @@ public boolean canCollect(ChargeCollectorBlockEntity blockEntity, BlockPos block
}

@Getter
public class Entry {
public static class Entry {
public final double distance;
public final ChargeCollectorBlockEntity blockEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void tickGrid() {
Set<PowerGrid> remove = Collections.synchronizedSet(new HashSet<>());
while (iterator.hasNext()) {
PowerGrid grid = iterator.next();
if (grid.isEmpty()) remove.add(grid);
if (grid.isEmpty() || grid.isRemove()) remove.add(grid);
grid.tick();
}
grids.removeAll(remove);
Expand Down Expand Up @@ -239,7 +239,6 @@ public void remove(IPowerComponent @NotNull ... components) {
for (IPowerComponent component : components) {
set.remove(component);
}
PowerGrid.getGridSet(this.level).remove(this);
new PowerGridRemovePack(this).broadcast();
PowerGrid.addComponent(set.toArray(IPowerComponent[]::new));
}
Expand Down Expand Up @@ -289,7 +288,7 @@ public static void addComponent(IPowerComponent @NotNull ... components) {
Set<PowerGrid> remove = Collections.synchronizedSet(new HashSet<>());
while (iterator.hasNext()) {
PowerGrid grid1 = iterator.next();
if (!grid1.isInRange(component)) continue;
if (grid1.isRemove() || !grid1.isInRange(component)) continue;
if (grid == null) grid = grid1;
else {
grid.merge(grid1);
Expand Down
Loading