Skip to content

Commit

Permalink
highway width setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jan 17, 2025
1 parent 5913b51 commit 5031d23
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static xaeroplus.util.ChunkUtils.regionCoordToChunkCoord;

public class ChunkHighlightDatabase implements Closeable {
public static int MAX_HIGHLIGHTS_LIST = 25000;
public static final int MAX_HIGHLIGHTS_LIST = 25000;
private final Connection connection;
protected final String databaseName;
private static final DatabaseMigrator MIGRATOR = new DatabaseMigrator();
Expand Down
51 changes: 51 additions & 0 deletions common/src/main/java/xaeroplus/module/impl/Highways.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public class Highways extends Module {
private int highwaysColor = getColor(0, 0, 255, 100);
private int width = 2;

// Highway data sourced from: https://www.desmos.com/calculator/oexoz81fxy

Expand Down Expand Up @@ -84,26 +85,72 @@ public void onDisable() {

public boolean isHighwayChunk(int x, int z, ResourceKey<Level> dimension) {
if (x == 0 || z == 0) return true; // cardinal directions
int w = width / 2;
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if (x + i == 0 || x - i == 0) return true;
if (z + i == 0 || z - i == 0) return true;
}
}
var xAbs = Math.abs(x);
var zAbs = Math.abs(z);
if (xAbs == zAbs) return true; // diags
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if (xAbs - i == zAbs || xAbs + i == zAbs) return true;
}
}
if (dimension == Level.NETHER) {
// ring roads
if (ringRoads.contains(xAbs)) {
if (z >= -xAbs && z <= xAbs) return true;
}
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if (ringRoads.contains(xAbs - i)) {
if (z >= -xAbs + i && z <= xAbs - i) return true;
}
if (ringRoads.contains(xAbs + i)) {
if (z >= -xAbs - i && z <= xAbs + i) return true;
}
}
}
if (ringRoads.contains(zAbs)) {
if (x >= -zAbs && x <= zAbs) return true;
}
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if (ringRoads.contains(zAbs - i)) {
if (x >= -zAbs + i && x <= zAbs - i) return true;
}
if (ringRoads.contains(zAbs + i)) {
if (x >= -zAbs - i && x <= zAbs + i) return true;
}
}
}

// diamonds
if (diamonds.contains(xAbs + zAbs)) return true;
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if (diamonds.contains(xAbs + zAbs - i)) return true;
if (diamonds.contains(xAbs + zAbs + i)) return true;
}
}

// grid
if (xAbs < fiftyK && zAbs < fiftyK) {
if ((xAbs * 16) % 5000 == 0) return true;
if ((zAbs * 16) % 5000 == 0) return true;
}
if (w >= 1) {
for (int i = 1; i <= w; i++) {
if ((xAbs - i) * 16 % 5000 == 0) return true;
if ((xAbs + i) * 16 % 5000 == 0) return true;
if ((zAbs - i) * 16 % 5000 == 0) return true;
if ((zAbs + i) * 16 % 5000 == 0) return true;
}
}
}
return false;
}
Expand Down Expand Up @@ -136,6 +183,10 @@ public void setAlpha(final double a) {
highwaysColor = ColorHelper.getColorWithAlpha(highwaysColor, (int) a);
}

public void setWidth(final Settings.HighwayWidth w) {
width = w.getWidth();
}

private static IntOpenHashSet chunkSetFromPosList(int... pos) {
final IntOpenHashSet set = new IntOpenHashSet(pos.length);
for (int i = 0; i < pos.length; i++) {
Expand Down
25 changes: 25 additions & 0 deletions common/src/main/java/xaeroplus/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,31 @@ static void markChunksDirtyInWriteDistance() {
false,
(b) -> ModuleManager.getModule(Highways.class).setEnabled(b)),
SettingLocation.CHUNK_HIGHLIGHTS);
public enum HighwayWidth implements TranslatableSettingEnum {
// Must be odd numbers for the center to be aligned correctly
ONE(1), THREE(3), FIVE(5);
private final int width;
HighwayWidth(final int width) {
this.width = width;
}

@Override
public String getTranslationKey() {
return String.valueOf(width);
}

public int getWidth() {
return width;
}
}
public final EnumSetting<HighwayWidth> highwayWidthSetting = register(
EnumSetting.create(
"2b2t Highways Width",
"xaeroplus.setting.2b2t_highways_width",
HighwayWidth.values(),
HighwayWidth.ONE,
(v) -> ModuleManager.getModule(Highways.class).setWidth(v)),
SettingLocation.CHUNK_HIGHLIGHTS);
public final EnumSetting<ColorHelper.HighlightColor> highwaysColorSetting = register(
EnumSetting.create(
"2b2t Highways Color",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Uses OldChunks Inverse to determine if a chunk was not loaded before. Therefore a portal could not have been created in its radius. \n Requires OldChunks inverse to be enabled.",
"xaeroplus.setting.2b2t_highways_enabled": "2b2t Highways",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Highlights chunks on 2b2t highways",
"xaeroplus.setting.2b2t_highways_width": "2b2t Highways Width",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Sets the width of the highway highlights",
"xaeroplus.setting.2b2t_highways_color": "2b2t Highways Color",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Sets the color of 2b2t Highways highlights",
"xaeroplus.setting.2b2t_highways_opacity": "2b2t Highways Opacity",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/es_ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Usa ChunksAntiguos para determinar si un chunk no se cargó antes. Por lo tanto, no se pudo haber creado un portal en su radio. \n Requiere que ChunksAntiguos Invertido esté habilitado.",
"xaeroplus.setting.2b2t_highways_enabled": "Carreteras 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Destaca los chunks en las carreteras de 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Ancho de las autopistas 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Establece el ancho de las marcas de las autopistas",
"xaeroplus.setting.2b2t_highways_color": "Color de las Carreteras 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Establece el color de los resaltados de las carreteras de 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Opacidad de las Carreteras 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/fr_ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Utilise OldChunks Inverse pour déterminer si un morceau n'a pas été chargé auparavant. Un portail n’aurait donc pas pu être créé dans son rayon.\n Nécessite l’activation d’OldChunks inverse.",
"xaeroplus.setting.2b2t_highways_enabled": "Autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Surligne les chunks sur les autoroutes de 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Largeur des autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Définit la largeur des surbrillances des autoroutes",
"xaeroplus.setting.2b2t_highways_color": "Couleur des Autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Définit la couleur des surlignages des autoroutes de 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Opacité des Autoroutes 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Utilise OldChunks Inverse pour déterminer si un morceau n'a pas été chargé auparavant. Un portail n’aurait donc pas pu être créé dans son rayon.\n Nécessite l’activation d’OldChunks inverse.",
"xaeroplus.setting.2b2t_highways_enabled": "Autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Surligne les chunks sur les autoroutes de 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Largeur des autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Définit la largeur des surbrillances des autoroutes",
"xaeroplus.setting.2b2t_highways_color": "Couleur des Autoroutes 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Définit la couleur des surlignages des autoroutes de 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Opacité des Autoroutes 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "チャンクが以前にロードされていないかどうかを判断するために、OldChunks Inverseを使用する。そのため、ポータルがその半径内に作成されていない可能性があります。\nOldChunks Inverseが有効になっている必要があります。",
"xaeroplus.setting.2b2t_highways_enabled": "2b2t ハイウェイ",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "2b2t ハイウェイ上のチャンクを強調表示します",
"xaeroplus.setting.2b2t_highways_width": "2b2t ハイウェイの幅",
"xaeroplus.setting.2b2t_highways_width.tooltip": "ハイウェイのハイライトの幅を設定します",
"xaeroplus.setting.2b2t_highways_color": "2b2t ハイウェイの色",
"xaeroplus.setting.2b2t_highways_color.tooltip": "2b2t ハイウェイの強調表示の色を設定します",
"xaeroplus.setting.2b2t_highways_opacity": "2b2t ハイウェイの不透明度",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/pl_pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Używa OldChunks Inverse, aby określić, czy porcja nie była wcześniej załadowana. Dlatego w jego promieniu nie można było stworzyć portalu.\n Wymaga włączenia odwrotności OldChunks.",
"xaeroplus.setting.2b2t_highways_enabled": "Autostrady 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Podświetla chunki na autostradach 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Szerokość autostrad 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Ustawia szerokość wyróżnień autostrad",
"xaeroplus.setting.2b2t_highways_color": "Kolor Autostrad 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Ustawia kolor podświetleń autostrad 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Przezroczystość Autostrad 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/pt_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Usa partes antigas inversamente para determinar se essa parte ainda não tinha sido carregada. Portanto um portal não poderá ter sido criado na sua área. \n É necessário Partes Antigas Invertidas ativo.",
"xaeroplus.setting.2b2t_highways_enabled": "Rodovias 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Destaca chunks nas rodovias 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Largura das rodovias 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Define a largura dos destaques das rodovias",
"xaeroplus.setting.2b2t_highways_color": "Cor das Rodovias 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Define a cor dos destaques das rodovias 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Opacidade das Rodovias 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Использует OldChunks Inverse, чтобы определить, не был ли чанк загружен ранее. Следовательно, портал не мог быть создан в его радиусе.\n Требуется, чтобы инверсия OldChunks была включена.",
"xaeroplus.setting.2b2t_highways_enabled": "Шоссе 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Выделяет чанки на шоссе 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Ширина шоссе 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Устанавливает ширину выделения шоссе",
"xaeroplus.setting.2b2t_highways_color": "Цвет шоссе 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Устанавливает цвет выделения шоссе 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Прозрачность шоссе 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/vi_vn.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "Sử dụng Đảo Ngược OldChunks để xác định nếu một chunk chưa được tải trước đó. Do đó, một cổng không thể được tạo trong bán kính của nó. \n Yêu cầu Đảo Ngược OldChunks được kích hoạt.",
"xaeroplus.setting.2b2t_highways_enabled": "Đường cao tốc 2b2t",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "Làm nổi bật các chunk trên đường cao tốc 2b2t",
"xaeroplus.setting.2b2t_highways_width": "Chiều rộng đường cao tốc 2b2t",
"xaeroplus.setting.2b2t_highways_width.tooltip": "Đặt chiều rộng của điểm nổi bật trên đường cao tốc",
"xaeroplus.setting.2b2t_highways_color": "Màu sắc Đường cao tốc 2b2t",
"xaeroplus.setting.2b2t_highways_color.tooltip": "Đặt màu cho các điểm nổi bật trên đường cao tốc 2b2t",
"xaeroplus.setting.2b2t_highways_opacity": "Độ trong suốt Đường cao tốc 2b2t",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "使用 OldChunks Inverse 来确定之前是否未加载过块。 因此不可能在其半径内创建传送门。\n 需要启用 OldChunks 逆功能。",
"xaeroplus.setting.2b2t_highways_enabled": "2b2t 高速公路",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "突出显示 2b2t 高速公路上的区块",
"xaeroplus.setting.2b2t_highways_width": "2b2t 高速公路宽度",
"xaeroplus.setting.2b2t_highways_width.tooltip": "设置高速公路高亮显示的宽度",
"xaeroplus.setting.2b2t_highways_color": "2b2t 高速公路颜色",
"xaeroplus.setting.2b2t_highways_color.tooltip": "设置 2b2t 高速公路高亮显示的颜色",
"xaeroplus.setting.2b2t_highways_opacity": "2b2t 高速公路不透明度",
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/xaeroplus/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"xaeroplus.setting.portal_skip_old_chunks_inverse.tooltip": "使用舊區塊反轉來確定區塊之前是否未載入。因此,無法在其半徑內建立傳送門。 \n 需要啟用舊區塊反轉。",
"xaeroplus.setting.2b2t_highways_enabled": "2b2t 公路",
"xaeroplus.setting.2b2t_highways_enabled.tooltip": "高亮顯示 2b2t 公路上的區塊",
"xaeroplus.setting.2b2t_highways_width": "2b2t 高速公路寬度",
"xaeroplus.setting.2b2t_highways_width.tooltip": "設置高速公路高亮顯示的寬度",
"xaeroplus.setting.2b2t_highways_color": "2b2t 公路顏色",
"xaeroplus.setting.2b2t_highways_color.tooltip": "設定 2b2t 公路高亮的顏色",
"xaeroplus.setting.2b2t_highways_opacity": "2b2t 公路不透明度",
Expand Down

0 comments on commit 5031d23

Please sign in to comment.