From 01fa7069b33cedd4992f7b0f21b29916b949de1c Mon Sep 17 00:00:00 2001
From: Cubitect Cubiomes Viewer offers highly customizable seed-finding utilities and a map viewer for the biome and structure generation of Minecraft Java Edition for the main releases up to 1.19. Cubiomes Viewer offers highly customizable seed-finding utilities and a map viewer for the biome and structure generation of Minecraft Java Edition for the main releases up to 1.21.";
for (int j = 0; j < NP_MAX; j++)
{
@@ -310,6 +302,8 @@ ConditionDialog::ConditionDialog(FormConditions *parent, Config *config, int mcv
ui->checkSkipRef->setChecked(false);
ui->radioSquare->setChecked(true);
ui->checkRadius->setChecked(false);
+ ui->lineCoverage->setText("100");
+ ui->lineConfidence->setText("95");
onCheckStartChanged(false);
on_comboClimatePara_currentIndexChanged(0);
@@ -328,22 +322,25 @@ ConditionDialog::ConditionDialog(FormConditions *parent, Config *config, int mcv
ui->comboLua->setCurrentIndex(-1); // force index change
ui->comboLua->setCurrentIndex(ui->comboLua->findData(QVariant::fromValue(cond.hash)));
- ui->comboBoxCat->setCurrentIndex(ui->comboBoxCat->findData(ft.cat));
- for (int i = 0; i < ui->comboBoxType->count(); i++)
+ ui->comboCat->setCurrentIndex(ui->comboCat->findData(ft.cat));
+ for (int i = 0; i < ui->comboType->count(); i++)
{
- int type = ui->comboBoxType->itemData(i, Qt::UserRole).toInt();
+ int type = ui->comboType->itemData(i, Qt::UserRole).toInt();
if (type == cond.type)
{
- ui->comboBoxType->setCurrentIndex(i);
+ ui->comboType->setCurrentIndex(i);
break;
}
}
- ui->comboBoxRelative->setCurrentIndex(initindex);
- on_comboBoxRelative_activated(initindex);
+ ui->comboRelative->setCurrentIndex(initindex);
+ on_comboRelative_activated(initindex);
ui->textEditLua->document()->setModified(false);
- ui->comboMatchBiome->insertItem(0, getBiomeDisplay(mc, cond.biomeId), QVariant::fromValue(cond.biomeId));
+ if (cond.step)
+ ui->lineSpiralStep->setText(QString::number(cond.step));
+
+ ui->comboMatchBiome->insertItem(0, getBiomeDisplay(wi.mc, cond.biomeId), QVariant::fromValue(cond.biomeId));
ui->comboMatchBiome->setCurrentIndex(0);
ui->comboClimatePara->setCurrentIndex(ui->comboClimatePara->findData(QVariant::fromValue(cond.para)));
@@ -364,6 +361,10 @@ ConditionDialog::ConditionDialog(FormConditions *parent, Config *config, int mcv
ui->checkApprox->setChecked(cond.flags & Condition::FLG_APPROX);
ui->checkMatchAny->setChecked(cond.flags & Condition::FLG_MATCH_ANY);
+ ui->lineCoverage->setText(QString::number(cond.converage ? cond.converage * 100 : 100));
+ ui->lineConfidence->setText(QString::number(cond.confidence ? cond.confidence * 100 : 95));
+ ui->checkSamplePos->setChecked(cond.count == 1);
+
int i, n = ui->comboY->count();
for (i = 0; i < n; i++)
if (ui->comboY->itemText(i).section(' ', 0, 0).toInt() == cond.y)
@@ -475,26 +476,40 @@ void ConditionDialog::addTempCat(int temp, QString name)
int r = temp % Special;
ui->gridLayoutTemps->addWidget(tempsboxes[temp], r, c * 2 + 0);
ui->gridLayoutTemps->addWidget(l, r, c * 2 + 1);
- if (mc > MC_1_6 && mc <= MC_1_17)
- l->setToolTip(getTip(mc, L_SPECIAL_1024, 0, r + (temp >= Special ? 256 : 0)));
+ if (wi.mc > MC_1_6 && wi.mc <= MC_1_17)
+ {
+ uint64_t mL = 0, mM = 0;
+ genPotential(&mL, &mM, L_SPECIAL_1024, wi.mc, 0, r + (temp >= Special ? 256 : 0));
+ QString tip = ConditionDialog::tr("Generates any of:");
+ for (int j = 0; j < 64; j++)
+ if (mL & (1ULL << j))
+ tip += QString("\n") + getBiomeDisplay(wi.mc, j);
+ for (int j = 0; j < 64; j++)
+ if (mM & (1ULL << j))
+ tip += QString("\n") + getBiomeDisplay(wi.mc, 128+j);
+ l->setToolTip(tip);
+ }
}
void ConditionDialog::updateMode()
{
- int filterindex = ui->comboBoxType->currentData().toInt();
+ int filterindex = ui->comboType->currentData().toInt();
const FilterInfo &ft = g_filterinfo.list[filterindex];
ui->lineSummary->setPlaceholderText(QApplication::translate("Filter", ft.name));
QPalette pal;
- if (mc < ft.mcmin || mc > ft.mcmax)
+ if (wi.mc < ft.mcmin || wi.mc > ft.mcmax)
pal.setColor(QPalette::Normal, QPalette::Button, QColor(255,0,0,127));
- ui->comboBoxType->setPalette(pal);
+ ui->comboType->setPalette(pal);
ui->groupBoxGeneral->setEnabled(filterindex != F_SELECT);
ui->groupBoxPosition->setEnabled(filterindex != F_SELECT);
- ui->checkRadius->setEnabled(ft.rmax);
+ ui->checkRadius->setEnabled(ft.loc & FilterInfo::LOC_R);
+
+ bool p1 = ft.loc & FilterInfo::LOC_1;
+ bool p2 = ft.loc & FilterInfo::LOC_2;
if (ui->checkRadius->isEnabled() && ui->checkRadius->isChecked())
{
@@ -516,28 +531,44 @@ void ConditionDialog::updateMode()
}
else
{
- bool custom = ui->radioCustom->isChecked();
-
ui->lineRadius->setEnabled(false);
- ui->radioSquare->setEnabled(ft.area);
- ui->radioCustom->setEnabled(ft.area);
+ ui->radioSquare->setEnabled(p2);
+ ui->radioCustom->setEnabled(p2);
- ui->lineSquare->setEnabled(!custom && ft.area);
-
- ui->labelX1->setEnabled(ft.coord && (custom || !ft.area));
- ui->labelZ1->setEnabled(ft.coord && (custom || !ft.area));
- ui->labelX2->setEnabled(custom && ft.area);
- ui->labelZ2->setEnabled(custom && ft.area);
- ui->lineEditX1->setEnabled(ft.coord && (custom || !ft.area));
- ui->lineEditZ1->setEnabled(ft.coord && (custom || !ft.area));
- ui->lineEditX2->setEnabled(custom && ft.area);
- ui->lineEditZ2->setEnabled(custom && ft.area);
+ if (ui->radioCustom->isChecked())
+ {
+ ui->lineSquare->setEnabled(false);
+ ui->labelX1->setEnabled(p1);
+ ui->labelZ1->setEnabled(p1);
+ ui->labelX2->setEnabled(p2);
+ ui->labelZ2->setEnabled(p2);
+ ui->lineEditX1->setEnabled(p1);
+ ui->lineEditZ1->setEnabled(p1);
+ ui->lineEditX2->setEnabled(p2);
+ ui->lineEditZ2->setEnabled(p2);
+ }
+ else
+ {
+ ui->lineSquare->setEnabled(p2);
+ ui->labelX1->setEnabled(p1 && !p2);
+ ui->labelZ1->setEnabled(p1 && !p2);
+ ui->labelX2->setEnabled(false);
+ ui->labelZ2->setEnabled(false);
+ ui->lineEditX1->setEnabled(p1 && !p2);
+ ui->lineEditZ1->setEnabled(p1 && !p2);
+ ui->lineEditX2->setEnabled(false);
+ ui->lineEditZ2->setEnabled(false);
+ }
}
- ui->labelSpinBox->setEnabled(ft.count);
- ui->spinBox->setEnabled(ft.count);
- ui->checkSkipRef->setEnabled(ft.count);
+ ui->buttonFromVisible->setEnabled(mapview && p2 && ui->comboRelative->currentIndex() == 0);
+
+ bool cnt = ft.branch == FilterInfo::BR_CLUST;
+
+ ui->labelSpinBox->setEnabled(cnt);
+ ui->spinBox->setEnabled(cnt);
+ ui->checkSkipRef->setEnabled(cnt);
ui->labelY->setEnabled(ft.hasy);
ui->comboY->setEnabled(ft.hasy);
@@ -561,14 +592,18 @@ void ConditionDialog::updateMode()
else if (ft.cat == CAT_BIOMES || ft.cat == CAT_NETHER || ft.cat == CAT_END)
{
ui->stackedWidget->setCurrentWidget(ui->pageBiomes);
- ui->checkApprox->setEnabled(mc <= MC_1_17 || ft.step == 4);
+ ui->checkApprox->setEnabled(wi.mc <= MC_1_17 || ft.grid == 4);
ui->checkMatchAny->setEnabled(true);
+ if (filterindex == F_BIOME_SAMPLE)
+ ui->stackedBiome->setCurrentWidget(ui->pageBiomeOptSample);
+ else
+ ui->stackedBiome->setCurrentWidget(ui->pageBiomeOpt);
}
else if (filterindex == F_VILLAGE)
{
ui->stackedWidget->setCurrentWidget(ui->pageVillage);
- ui->checkStartPieces->setEnabled(mc >= MC_1_14);
- ui->checkAbandoned->setEnabled(filterindex == F_VILLAGE && mc >= MC_1_10);
+ ui->checkStartPieces->setEnabled(wi.mc >= MC_1_14);
+ ui->checkAbandoned->setEnabled(filterindex == F_VILLAGE && wi.mc >= MC_1_10);
}
else if (filterindex == F_FORTRESS)
{
@@ -578,22 +613,22 @@ void ConditionDialog::updateMode()
else if (filterindex == F_BASTION)
{
ui->stackedWidget->setCurrentWidget(ui->pageBastion);
- ui->checkStartBastion->setEnabled(mc >= MC_1_16_1);
+ ui->checkStartBastion->setEnabled(wi.mc >= MC_1_16_1);
}
else if (filterindex == F_PORTAL || filterindex == F_PORTALN)
{
ui->stackedWidget->setCurrentWidget(ui->pagePortal);
- ui->checkStartPortal->setEnabled(mc >= MC_1_16_1);
+ ui->checkStartPortal->setEnabled(wi.mc >= MC_1_16_1);
}
else if (filterindex == F_ENDCITY)
{
ui->stackedWidget->setCurrentWidget(ui->pageEndCity);
- ui->checkBasement->setEnabled(mc >= MC_1_9);
+ ui->checkBasement->setEnabled(wi.mc >= MC_1_9);
}
else if (filterindex == F_IGLOO)
{
ui->stackedWidget->setCurrentWidget(ui->pageIgloo);
- ui->checkEndShip->setEnabled(mc >= MC_1_9);
+ ui->checkEndShip->setEnabled(wi.mc >= MC_1_9);
}
else if (filterindex == F_HEIGHT)
{
@@ -603,6 +638,10 @@ void ConditionDialog::updateMode()
{
ui->stackedWidget->setCurrentWidget(ui->pageLua);
}
+ else if (filterindex == F_SPIRAL)
+ {
+ ui->stackedWidget->setCurrentWidget(ui->pageSpiral);
+ }
else
{
ui->stackedWidget->setCurrentWidget(ui->pageNone);
@@ -610,26 +649,14 @@ void ConditionDialog::updateMode()
updateBiomeSelection();
- QString loc = "";
- QString areatip = "";
- QString lowtip = "";
- QString uptip = "";
+ QString loc = tr("Location");
+ QString areatip = tr("From floor(-x/2) to floor(x/2) on both axes (inclusive)");
+ QString lowtip = tr("Lower bound (inclusive)");
+ QString uptip = tr("Upper bound (inclusive)");
+
+ if (ft.grid > 1)
+ loc += " " + tr("(sampled on a grid of scale 1:%1)").arg(ft.grid);
- if (ft.step > 1)
- {
- QString multxt = QString("%1%2").arg(QChar(0xD7)).arg(ft.step);
- loc = tr("Location (coordinates are multiplied by %1)").arg(multxt);
- areatip = tr("From floor(-x/2)%1 to floor(x/2)%1 on both axes (inclusive)").arg(multxt);
- lowtip = tr("Lower bound %1 (inclusive)").arg(multxt);
- uptip = tr("Upper bound %1 (inclusive)").arg(multxt);
- }
- else
- {
- loc = tr("Location");
- areatip = tr("From floor(-x/2) to floor(x/2) on both axes (inclusive)");
- lowtip = tr("Lower bound (inclusive)");
- uptip = tr("Upper bound (inclusive)");
- }
ui->groupBoxPosition->setTitle(loc);
ui->radioSquare->setToolTip(areatip);
ui->labelX1->setToolTip(lowtip);
@@ -646,7 +673,7 @@ void ConditionDialog::updateMode()
void ConditionDialog::updateBiomeSelection()
{
- int filterindex = ui->comboBoxType->currentData().toInt();
+ int filterindex = ui->comboType->currentData().toInt();
const FilterInfo &ft = g_filterinfo.list[filterindex];
// clear tool tips
@@ -669,14 +696,14 @@ void ConditionDialog::updateBiomeSelection()
available.push_back(cold_ocean);
available.push_back(frozen_ocean);
}
- else if (ft.cat == CAT_BIOMES && mc > MC_B1_7 && mc <= MC_1_17)
+ else if (ft.cat == CAT_BIOMES && wi.mc > MC_B1_7 && wi.mc <= MC_1_17)
{
int layerId = ft.layer;
if (layerId == 0)
{
Generator tmp;
- setupGenerator(&tmp, mc, 0);
- const Layer *l = getLayerForScale(&tmp, ft.step);
+ setupGenerator(&tmp, wi.mc, 0);
+ const Layer *l = getLayerForScale(&tmp, ft.grid);
if (l)
layerId = l - tmp.ls.layers;
}
@@ -688,7 +715,7 @@ void ConditionDialog::updateBiomeSelection()
QCheckBox *cb = it.second;
uint64_t mL = 0, mM = 0;
uint32_t flags = 0;
- genPotential(&mL, &mM, layerId, mc, flags, it.first);
+ genPotential(&mL, &mM, layerId, wi.mc, flags, it.first);
if (mL || mM)
{
@@ -699,12 +726,12 @@ void ConditionDialog::updateBiomeSelection()
for (int j = 0; j < 64; j++)
{
if (mL & (1ULL << j))
- tip += QString("\n") + getBiomeDisplay(mc, j);
+ tip += QString("\n") + getBiomeDisplay(wi.mc, j);
}
for (int j = 0; j < 64; j++)
{
if (mM & (1ULL << j))
- tip += QString("\n") + getBiomeDisplay(mc, j+128);
+ tip += QString("\n") + getBiomeDisplay(wi.mc, j+128);
}
cb->setToolTip(tip);
}
@@ -719,12 +746,12 @@ void ConditionDialog::updateBiomeSelection()
{
for (const auto& it : biomecboxes)
{
- if (isOverworld(mc, it.first))
+ if (isOverworld(wi.mc, it.first))
available.push_back(it.first);
}
}
- IdCmp cmp = {IdCmp::SORT_LEX, mc, DIM_UNDEF};
+ IdCmp cmp = {IdCmp::SORT_LEX, wi.mc, DIM_UNDEF};
std::sort(available.begin(), available.end(), cmp);
if (ui->stackedWidget->currentWidget() == ui->pageBiomes)
@@ -772,7 +799,7 @@ void ConditionDialog::updateBiomeSelection()
for (int id: available)
{
- QString s = getBiomeDisplay(mc, id);
+ QString s = getBiomeDisplay(wi.mc, id);
ui->comboMatchBiome->addItem(getBiomeIcon(id), s, QVariant::fromValue(id));
allowed_matches.append(s);
}
@@ -785,7 +812,7 @@ void ConditionDialog::updateBiomeSelection()
}
else
{
- QString s = QString("%1 %2").arg(WARNING_CHAR).arg(getBiomeDisplay(mc, curid.toInt()));
+ QString s = QString("%1 %2").arg(WARNING_CHAR).arg(getBiomeDisplay(wi.mc, curid.toInt()));
ui->comboMatchBiome->insertItem(0, getBiomeIcon(curid.toInt(), true), s, curid);
ui->comboMatchBiome->setCurrentIndex(0);
allowed_matches.append(s);
@@ -830,21 +857,25 @@ int ConditionDialog::warnIfBad(Condition cond)
}
else if (cond.type == F_BIOME_CENTER || cond.type == F_BIOME_CENTER_256)
{
- int w = cond.x2 - cond.x1 + 1;
- int h = cond.z2 - cond.z1 + 1;
+ int s = ft.pow2;
+ int w = (cond.x2 >> s) - (cond.x1 >> s) + 1;
+ int h = (cond.z2 >> s) - (cond.z1 >> s) + 1;
if ((unsigned int)(w * h) < cond.count * cond.biomeSize)
{
QString text = tr(
- "The biome locator checks for %1 instances of size %2 each, "
- "which cannot be satisfied by an area of size %3%4%5 = %6.")
- .arg(cond.count).arg(cond.biomeSize).arg(w).arg(QChar(0xD7)).arg(h).arg(w * h);
+ "The biome locator checks for %n instance(s), each of size %1, "
+ "which cannot be satisfied by an area of size\n"
+ "%2%3%4 = %5 < %6 @ scale 1:%7.", "", cond.count)
+ .arg(cond.biomeSize)
+ .arg(w).arg(QChar(0xD7)).arg(h).arg(w*h)
+ .arg(cond.count * cond.biomeSize).arg(1<
= MC_1_18)
+ if (wi.mc >= MC_1_18)
{
uint64_t m = cond.biomeToFindM;
uint64_t underground =
@@ -890,8 +921,8 @@ void ConditionDialog::onAccept()
Condition c = cond;
c.version = Condition::VER_CURRENT;
- c.type = ui->comboBoxType->currentData().toInt();
- c.relative = ui->comboBoxRelative->currentData().toInt();
+ c.type = ui->comboType->currentData().toInt();
+ c.relative = ui->comboRelative->currentData().toInt();
c.count = ui->spinBox->value();
c.skipref = ui->checkSkipRef->isChecked();
@@ -923,19 +954,21 @@ void ConditionDialog::onAccept()
c.z2 = ui->lineEditZ2->text().toInt();
}
- if (ft.area)
+ if (ft.loc & FilterInfo::LOC_2)
{
if (c.x1 > c.x2) std::swap(c.x1, c.x2);
if (c.z1 > c.z2) std::swap(c.z1, c.z2);
}
- if (ui->checkRadius->isChecked())
+ if (ui->checkRadius->isEnabled() && ui->checkRadius->isChecked())
c.rmax = ui->lineRadius->text().toInt() + 1;
else
c.rmax = 0;
c.y = ui->comboY->currentText().section(' ', 0, 0).toInt();
+ c.step = ui->lineSpiralStep->text().toUShort();
+
if (ui->stackedWidget->currentWidget() == ui->pageBiomes)
{
c.biomeToFind = c.biomeToFindM = 0;
@@ -959,7 +992,9 @@ void ConditionDialog::onAccept()
}
}
}
- c.count = 0;
+ c.count = ui->checkSamplePos->isChecked() ? 1 : 0;
+ c.converage = ui->lineCoverage->text().toFloat() / 100.0;
+ c.confidence = ui->lineConfidence->text().toFloat() / 100.0;
}
if (ui->stackedWidget->currentWidget() == ui->pageBiomeCenter)
{
@@ -1029,17 +1064,18 @@ void ConditionDialog::onAccept()
close();
}
-void ConditionDialog::on_comboBoxType_activated(int)
+void ConditionDialog::on_comboType_activated(int)
{
updateMode();
}
-void ConditionDialog::on_comboBoxRelative_activated(int)
+void ConditionDialog::on_comboRelative_activated(int)
{
QPalette pal;
- if (ui->comboBoxRelative->currentText().contains(WARNING_CHAR))
+ if (ui->comboRelative->currentText().contains(WARNING_CHAR))
pal.setColor(QPalette::Normal, QPalette::Button, QColor(255,0,0,127));
- ui->comboBoxRelative->setPalette(pal);
+ ui->comboRelative->setPalette(pal);
+ updateMode();
}
void ConditionDialog::on_buttonUncheck_clicked()
@@ -1073,21 +1109,34 @@ void ConditionDialog::on_buttonAreaInfo_clicked()
"
" "Alternatively, the area can be defined as a centered square " "with a certain side length. In this case the area has the bounds: " - "[-X/2, -X/2] on both axes, rounding down and bounds included. For " + "[-X/2, +X/2] on both axes, rounding down and bounds included. For " "example a centered square with side 3 will go from -2 to 1 for both " "the X and Z axes." "
" "Important to note is that some filters have a scaling associated with " - "them. This means that the area is not defined in blocks, but on a grid " - "with the given spacing (such as chunks instead of blocks). A scaling " - "of 1:16, for example, means that the aforementioned centered square of " - "side 3 will range from -32 to 31 in block coordinates. (Chunk 1 has " - "blocks 16 to 31.)" + "them. This means the condition only checks on a grid with that spacing. " + "An area with a range from -21 to 21 at scale 1:16 may effectively be " + "expanded to -32 to 31, and get sampled at -32, -16, 0 and 16." "