Skip to content

Commit

Permalink
fix space station world border
Browse files Browse the repository at this point in the history
  • Loading branch information
screret committed Aug 26, 2024
1 parent fbe16cc commit 535dd7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ public BlockPos getStationWorldPos(int id) {

@Override
public List<Integer> getStationsNearPos(Vec2i position, int range) {
return stations.int2ObjectEntrySet().stream().filter(obj -> obj.getValue().position().distanceToSqr(position) <= range * range).sorted(Map.Entry.comparingByKey()).map(Int2ObjectMap.Entry::getIntKey).collect(Collectors.toList());
}

@Override
public List<Integer> getStationsNearWorldPos(BlockPos position, int range) {
return stations.int2ObjectEntrySet().stream().filter(obj -> obj.getValue().position().distanceToBlockSqr(position) <= range * range).sorted(Map.Entry.comparingByKey()).map(Int2ObjectMap.Entry::getIntKey).collect(Collectors.toList());
return stations.int2ObjectEntrySet().stream()
.filter(obj -> obj.getValue().position().distanceToSqr(position) <= range * range)
.sorted(Map.Entry.comparingByKey())
.map(Int2ObjectMap.Entry::getIntKey)
.collect(Collectors.toList());
}

@Override
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/argent_matter/gcyr/util/Vec2i.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package argent_matter.gcyr.util;

import argent_matter.gcyr.api.space.station.SpaceStation;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import org.jetbrains.annotations.NotNull;

public record Vec2i(int x, int y) implements Comparable<Vec2i> {
Expand All @@ -22,12 +20,6 @@ public int distanceToSqr(Vec2i other) {
return f * f + g * g;
}

public int distanceToBlockSqr(BlockPos other) {
int f = other.getX() - (this.x * SpaceStation.BLOCK_MULTIPLIER - (SpaceStation.BLOCK_MULTIPLIER / 2));
int g = other.getZ() - (this.y * SpaceStation.BLOCK_MULTIPLIER - (SpaceStation.BLOCK_MULTIPLIER / 2));
return f * f + g * g;
}

@Override
public int compareTo(@NotNull Vec2i other) {
return this.x == other.x ? this.y - other.y : this.x - other.x;
Expand Down

0 comments on commit 535dd7b

Please sign in to comment.