Skip to content
This repository was archived by the owner on Aug 31, 2026. It is now read-only.

Commit 8e7694c

Browse files
committed
Deposit a crystal into what this world knows
- one-way crossing: a crystal fills a body's set, never the reverse - skip an address with no world and report landed of total - no new packet: the deposit syncs the way a beacon always has
1 parent d805b3a commit 8e7694c

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

src/main/java/zmaster587/advancedRocketry/tile/multiblock/TileObservatory.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import zmaster587.advancedRocketry.item.IDataItem;
3131
import zmaster587.advancedRocketry.item.ItemAsteroidChip;
3232
import zmaster587.advancedRocketry.item.ItemMemoryCrystal;
33+
import zmaster587.advancedRocketry.navigation.CrystalEntry;
3334
import zmaster587.advancedRocketry.space.GalacticCoord;
3435
import zmaster587.advancedRocketry.tile.hatch.TileDataBus;
3536
import zmaster587.advancedRocketry.universe.RegionScan;
@@ -117,6 +118,7 @@ public class TileObservatory extends TileMultiPowerConsumer implements IModularI
117118
private static final byte ABORT_SCAN = 20;
118119
private static final byte PASSIVE_SWEEP = 21;
119120
private static final byte TOGGLE_WHOLE_SYSTEM = 22;
121+
private static final byte UPLOAD_CRYSTAL = 23;
120122
/** Progress id of the region-scan bar; the machine's own bar keeps id 0. */
121123
private static final int PROGRESS_SCAN = 1;
122124
/**
@@ -748,6 +750,12 @@ public List<ModuleBase> getModules(int ID, EntityPlayer player) {
748750
zmaster587.libVulpes.inventory.TextureResources.buttonBuild,
749751
LibVulpes.proxy.getLocalizedString("msg.observetory.scan.abort.tooltip"), 40, 18));
750752
}
753+
// Reading a crystal INTO this world, the reverse of the survey that fills one. It costs
754+
// no power and no data: the knowledge already exists, it is being put down here.
755+
modules.add(new ModuleButton(100, 142, 10,
756+
LibVulpes.proxy.getLocalizedString("msg.observetory.upload.button"), this,
757+
zmaster587.libVulpes.inventory.TextureResources.buttonBuild,
758+
LibVulpes.proxy.getLocalizedString("msg.observetory.upload.tooltip"), 64, 18));
751759
modules.add(new ModuleButton(166, 42, 8,
752760
LibVulpes.proxy.getLocalizedString(passive
753761
? "msg.observetory.scan.mode.passive" : "msg.observetory.scan.mode.active"),
@@ -1186,6 +1194,41 @@ public void onInventoryButtonPressed(int buttonId) {
11861194
if (buttonId == 9) {
11871195
PacketHandler.sendToServer(new PacketMachine(this, TOGGLE_WHOLE_SYSTEM));
11881196
}
1197+
if (buttonId == 10) {
1198+
PacketHandler.sendToServer(new PacketMachine(this, UPLOAD_CRYSTAL));
1199+
}
1200+
}
1201+
1202+
/**
1203+
* Read the crystal in the machine into the KNOWLEDGE OF THIS BODY: what somebody carried here
1204+
* becomes what a launch pad standing here may be aimed at.
1205+
*
1206+
* <p>This is the one sanctioned crossing between the two discovery systems, and it goes one way.
1207+
* A crystal deposits into a body's set; a body's set never feeds a crystal, a console, or a jump
1208+
* target.</p>
1209+
*
1210+
* <p><b>An address without a world is skipped, and the count says so.</b> A procedural body
1211+
* carries no dimension until somebody descends to it, so a survey of unvisited space writes
1212+
* addresses that tier-1 has nothing to fly to yet - and an upload that silently did nothing
1213+
* would be indistinguishable from a broken button. Re-surveying such a system after somebody has
1214+
* landed there records the world it now has.</p>
1215+
*
1216+
* @return {@code {landed, total}}
1217+
*/
1218+
private int[] uploadCrystalHere() {
1219+
ItemStack crystal = getStackInSlot(SLOT_CRYSTAL);
1220+
if (!ItemMemoryCrystal.isCrystal(crystal)) {
1221+
return new int[] {0, 0};
1222+
}
1223+
List<CrystalEntry> entries = ItemMemoryCrystal.memoryOf(crystal).list();
1224+
Set<Integer> landed = new HashSet<>();
1225+
for (CrystalEntry entry : entries) {
1226+
if (entry.namesBody()) {
1227+
landed.add(entry.dimId());
1228+
}
1229+
}
1230+
teachThisBody(landed);
1231+
return new int[] {landed.size(), entries.size()};
11891232
}
11901233

11911234

@@ -1259,6 +1302,11 @@ else if (id == TOGGLE_WHOLE_SYSTEM) {
12591302
player.openGui(LibVulpes.instance, GuiHandler.guiId.MODULARNOINV.ordinal(),
12601303
getWorld(), pos.getX(), pos.getY(), pos.getZ());
12611304
}
1305+
else if (id == UPLOAD_CRYSTAL) {
1306+
int[] result = uploadCrystalHere();
1307+
player.sendMessage(new net.minecraft.util.text.TextComponentTranslation(
1308+
"msg.observetory.upload.result", result[0], result[1]));
1309+
}
12621310
else if (id == START_SCAN || id == ABORT_SCAN || id == PASSIVE_SWEEP) {
12631311
if (id == ABORT_SCAN) {
12641312
abortRegionScan();

src/main/resources/assets/advancedrocketry/lang/en_US.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ msg.observetory.scan.obscured=Dust in the way - coordinates only:
430430
msg.observetory.scan.idle=Idle
431431
msg.observetory.scan.abort=Stop
432432
msg.observetory.scan.abort.tooltip=Stop the survey. Everything already resolved is already on the crystal.
433+
msg.observetory.upload.button=Deposit
434+
msg.observetory.upload.tooltip=Read the crystal into what is known ON THIS WORLD, so a launch pad here can be aimed at it. An address of a world nobody has landed on yet has nothing to fly to and is skipped.
435+
msg.observetory.upload.result=Deposited %s of %s addresses into local knowledge.
433436
msg.observetory.scan.mode.active=Deep
434437
msg.observetory.scan.mode.passive=Local
435438
msg.observetory.scan.mode.tooltip=Local watches the neighbourhood and has its data ready; deep looks at a chosen distant region. One at a time - an instrument staring into deep space cannot see what is close.

src/main/resources/assets/advancedrocketry/lang/ru_RU.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ msg.observetory.scan.obscured=Мешает пыль — только коорд
263263
msg.observetory.scan.idle=Простаивает
264264
msg.observetory.scan.abort=Стоп
265265
msg.observetory.scan.abort.tooltip=Прервать обзор. Всё, что уже разрешено, уже лежит в кристалле.
266+
msg.observetory.upload.button=Выгрузить
267+
msg.observetory.upload.tooltip=Прочитать кристалл в то, что известно НА ЭТОМ МИРЕ, чтобы отсюда мог целиться пусковой стол. Адрес мира, на который ещё никто не садился, лететь некуда — он пропускается.
268+
msg.observetory.upload.result=В местное знание внесено адресов: %s из %s.
266269
msg.observetory.scan.mode.active=Даль
267270
msg.observetory.scan.mode.passive=Округа
268271
msg.observetory.scan.mode.tooltip=Округа наблюдает соседние ячейки и держит данные наготове; даль смотрит на выбранную далёкую область. Одно за раз — инструмент, вглядывающийся в глубокий космос, не видит того, что рядом.

0 commit comments

Comments
 (0)