Skip to content

Commit

Permalink
Not working...
Browse files Browse the repository at this point in the history
  • Loading branch information
Intybyte committed Sep 26, 2024
1 parent 0a7fea8 commit 09e6506
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.commons.lang.Validate;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;

Expand Down Expand Up @@ -139,6 +140,21 @@ protected void addLocationToNetwork(@Nonnull Location l) {
}
}

protected void removeLocationToNetwork(@Nonnull Location l) {
Validate.notNull(l, "You cannot add a Location to a Network which is null!");
Validate.isTrue(l.getWorld().getUID().equals(worldId), "Networks cannot exist in multiple worlds!");

if (positions.remove(BlockPosition.getAsLong(l))) {
if (regulator.equals(l)) {
manager.unregisterNetwork(this);
return;
}
regulatorNodes.remove(l);
connectorNodes.remove(l);
terminusNodes.remove(l);
}
}

/**
* This method marks the given {@link Location} as dirty and adds it to a {@link Queue}
* to handle this update.
Expand Down Expand Up @@ -226,9 +242,19 @@ private void discoverStep() {
}

private void discoverNeighbors(@Nonnull Location l, double xDiff, double yDiff, double zDiff) {
boolean found_stop = false;
for (int i = getRange() + 1; i > 0; i--) {
Location newLocation = l.clone().add(i * xDiff, i * yDiff, i * zDiff);
addLocationToNetwork(newLocation);

if (!found_stop)
found_stop = newLocation.getBlock().getType() == Material.COAL_BLOCK;

if (found_stop) {
removeLocationToNetwork(newLocation);
manager.updateAllNetworks(newLocation);
} else {
addLocationToNetwork(newLocation);
}
}
}

Expand Down

0 comments on commit 09e6506

Please sign in to comment.