From b00d64183d16424418107f39091b0e6261bb0895 Mon Sep 17 00:00:00 2001 From: Pelotrio <45769595+Pelotrio@users.noreply.github.com> Date: Tue, 6 Oct 2026 01:01:13 +0200 Subject: [PATCH 1/3] The mod's small items: fluids and energy per face, and a language reload without the icon archive - A block whose faces expose fluids or energy differently showed the amounts of the handler without a side, or of one largest face, and grouped faces by what they do alone, so separate storages doing the same merged. Faces now group by their tanks (fluid and capacity, empty ones too) or energy amounts as well, and where they differ, each group shows its own tanks as fluid facts within the section's budget, or its amounts; the largest-face fallback and its "Read through" row are gone. A side that cannot be read leaves the contents shown. - Companion's quick reload of a language file marked the icon archive changed, which captured every model and texture again (about 8 s). The language alone now only has the catalog captured again for its names; textures put in place still mark the archive. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../totaldebug/client/TotalDebugClient.java | 11 ++- .../client/resource/ResourceReloads.java | 6 +- .../inspection/InspectionReaders.java | 1 - .../totaldebug/inspection/SideReader.java | 98 +++++++++++++++---- .../totaldebug/inspection/StorageReader.java | 59 ++++------- .../totaldebug/inspection/SideReaderTest.java | 24 +++++ 6 files changed, 136 insertions(+), 63 deletions(-) diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java index 704da092e..aa9e01998 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java @@ -187,9 +187,18 @@ public static Optional current() { */ public void resourcesReloaded() { this.resources.resourcesChanged(); + languageReloaded(); + this.packStacks.republish(); + } + + /** + * The language was reloaded alone, as Companion's quick reload of a language file does. Only translated names + * changed, which the catalog captures again; the snapshot's models and textures and the packs did not, and capturing + * them again would take seconds. Client thread only. + */ + public void languageReloaded() { this.catalogs.recapture(); this.companionApp.announceInventory(); - this.packStacks.republish(); } /** diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/resource/ResourceReloads.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/resource/ResourceReloads.java index a967908a3..c857ced03 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/resource/ResourceReloads.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/resource/ResourceReloads.java @@ -109,8 +109,10 @@ private static CompletableFuture reloadResources(String managedPack, Set EntityReader.read(target, facts)); facts.guarded("Block state", () -> BlockStateReader.read(target, facts)); StorageReader.read(target, facts); - SideReader.read(target, facts); facts.guarded("Capabilities", () -> CapabilityReader.read(target, facts)); facts.guarded("NBT", () -> NbtReader.read(target, facts)); } diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java index e3b48f522..cabf64534 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java @@ -1,5 +1,6 @@ package com.github.minecraft_ta.totaldebug.inspection; +import com.github.minecraft_ta.totaldebug.protocol.execution.FactSection; import com.github.minecraft_ta.totaldebug.script.ScriptFacts; import com.github.minecraft_ta.totaldebug.script.ScriptTarget; import net.minecraft.core.Direction; @@ -10,6 +11,7 @@ import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.items.IItemHandler; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; @@ -34,6 +36,32 @@ public final class SideReader { record Group(String label, V view) { } + /** + * What a side exposes of fluids or energy: its tanks, each with its fluid and capacity, or the energy's amounts, such + * as {@code 1,200 / 10,000 FE: takes}, and what it does, such as {@code Water: takes, 1 empty tank}. Sides group by + * all of it, so faces of separate storages stay apart. + */ + record Exposed(List tanks, String amounts, String access) { + static final Exposed NONE = new Exposed(List.of(), NOT_EXPOSED, NOT_EXPOSED); + + boolean same(Exposed other) { + if (!this.amounts.equals(other.amounts) || !this.access.equals(other.access) || this.tanks.size() != other.tanks.size()) { + return false; + } + for (int index = 0; index < this.tanks.size(); index++) { + if (!this.tanks.get(index).same(other.tanks.get(index))) return false; + } + return true; + } + } + + /** A tank as a side exposes it: its fluid, which may be empty, and its capacity. */ + record Tank(FluidStack fluid, int capacity) { + boolean same(Tank other) { + return FluidStack.matches(this.fluid, other.fluid) && this.capacity == other.capacity; + } + } + /** A slot as a side exposes it; {@code takes} and {@code gives} are null where its state cannot tell. */ record Slot(ItemStack stack, Boolean takes, Boolean gives) { boolean same(Slot other) { @@ -45,13 +73,14 @@ boolean same(Slot other) { private SideReader() { } - /** The rows for a block's fluids and energy, after their contents. Items are reported with their contents. */ - public static void read(ScriptTarget target, ScriptFacts facts) { - if (!(target instanceof ScriptTarget.PlacedBlock block)) return; - facts.guarded("Fluids", () -> report(groups(block, Capabilities.FluidHandler.BLOCK, SideReader::fluids, - NOT_EXPOSED, String::equals), "Fluids", facts)); - facts.guarded("Energy", () -> report(groups(block, Capabilities.EnergyStorage.BLOCK, SideReader::energy, - NOT_EXPOSED, String::equals), "Energy", facts)); + /** The fluids the block exposes without a side and through each face, grouped; one group when all sides are alike. */ + static List> fluids(ScriptTarget.PlacedBlock block) { + return groups(block, Capabilities.FluidHandler.BLOCK, SideReader::fluids, Exposed.NONE, Exposed::same); + } + + /** The energy the block exposes without a side and through each face, grouped; one group when all sides are alike. */ + static List> energy(ScriptTarget.PlacedBlock block) { + return groups(block, Capabilities.EnergyStorage.BLOCK, SideReader::energy, Exposed.NONE, Exposed::same); } /** The slots the block exposes without a side and through each face, grouped; one group when all sides are alike. */ @@ -71,9 +100,29 @@ static void writeItems(Group> group, ScriptFacts.Section section, int } } - private static void report(List> groups, String section, ScriptFacts facts) { - if (groups.size() == 1 && groups.getFirst().view().equals(NOT_EXPOSED)) return; - for (Group group : groups) facts.section(section).text(group.label(), group.view()); + /** + * Writes the rows of fluids or energy after their contents: when all sides are alike, what they do, the contents + * above being theirs; otherwise each group's own tanks or amounts and what it does, as no one side's contents are the + * block's. The groups share the section's facts, as slots do. + */ + static void write(List> groups, String section, ScriptFacts facts) { + if (groups.size() == 1) { + String access = groups.getFirst().view().access(); + if (!access.equals(NOT_EXPOSED)) facts.section(section).text(groups.getFirst().label(), access); + return; + } + int perGroup = Math.max(1, FactSection.MAX_FACTS / groups.size() - 2); + ScriptFacts.Section rows = facts.section(section); + if (groups.stream().anyMatch(group -> group.view().tanks().size() > perGroup)) { + rows.text("Tanks", "first " + perGroup + " of each side shown"); + } + for (Group group : groups) { + Exposed view = group.view(); + for (Tank tank : view.tanks().subList(0, Math.min(perGroup, view.tanks().size()))) { + rows.fluid(group.label(), tank.fluid(), tank.capacity()); + } + rows.text(group.label(), view.tanks().isEmpty() ? view.amounts() : view.access()); + } } private static List> groups(ScriptTarget.PlacedBlock block, BlockCapability capability, @@ -138,13 +187,15 @@ private static boolean sameSlots(List first, List second) { return true; } - /** Each tank's fluid and what it does, such as {@code Water: takes and gives}, then the empty tanks. */ - private static String fluids(IFluidHandler handler) { - if (handler.getTanks() == 0) return NOT_EXPOSED; - List tanks = new ArrayList<>(); + /** Each tank with its fluid and capacity, and what each does, such as {@code Water: takes}, then the empty tanks. */ + private static Exposed fluids(IFluidHandler handler) { + if (handler.getTanks() == 0) return Exposed.NONE; + List tanks = new ArrayList<>(); + List access = new ArrayList<>(); int empty = 0; for (int tank = 0; tank < Math.min(handler.getTanks(), StorageReader.MAX_TANKS); tank++) { FluidStack fluid = handler.getFluidInTank(tank); + tanks.add(new Tank(fluid.copy(), handler.getTankCapacity(tank))); if (fluid.isEmpty()) { empty++; continue; @@ -153,19 +204,26 @@ private static String fluids(IFluidHandler handler) { Boolean takes = fluid.getAmount() >= handler.getTankCapacity(tank) ? null : handler.fill(fluid.copyWithAmount(Integer.MAX_VALUE), IFluidHandler.FluidAction.SIMULATE) > 0; boolean gives = !handler.drain(fluid.copyWithAmount(Integer.MAX_VALUE), IFluidHandler.FluidAction.SIMULATE).isEmpty(); - tanks.add(fluid.getHoverName().getString() + ": " + access(takes, gives).toLowerCase(Locale.ROOT)); + access.add(fluid.getHoverName().getString() + ": " + access(takes, gives).toLowerCase(Locale.ROOT)); } - if (empty > 0) tanks.add(empty + (empty == 1 ? " empty tank" : " empty tanks")); - return String.join(", ", tanks); + if (empty > 0) access.add(empty + (empty == 1 ? " empty tank" : " empty tanks")); + return new Exposed(tanks, "", String.join(", ", access)); } /** Simulates with the largest amount, since storages converting units round a small amount down to nothing. */ - private static String energy(IEnergyStorage storage) { + private static Exposed energy(IEnergyStorage storage) { int stored = storage.getEnergyStored(); - if (storage.getMaxEnergyStored() <= 0) return "No capacity"; + if (storage.getMaxEnergyStored() <= 0) return new Exposed(List.of(), "No capacity", "No capacity"); Boolean takes = stored >= storage.getMaxEnergyStored() ? null : storage.receiveEnergy(Integer.MAX_VALUE, true) > 0; Boolean gives = stored == 0 ? null : storage.extractEnergy(Integer.MAX_VALUE, true) > 0; - return access(takes, gives); + String access = access(takes, gives); + return new Exposed(List.of(), amounts(stored, storage.getMaxEnergyStored(), "FE") + ": " + access.toLowerCase(Locale.ROOT), access); + } + + /** An amount of a capacity, such as {@code 4,000 / 8,000 mB}. */ + static String amounts(long amount, long capacity, String unit) { + NumberFormat format = NumberFormat.getIntegerInstance(); + return format.format(amount) + " / " + format.format(capacity) + " " + unit; } /** What something takes and gives in words; a part its state cannot tell is left out and the state named. */ diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java index 047fac2f0..4ed836c0b 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java @@ -20,14 +20,14 @@ import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.items.IItemHandler; +import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; -import java.util.function.ToIntFunction; /** * Built-in reader for what a block or entity holds, through NeoForge's item, fluid and energy capabilities, read - * without a side. A block that only exposes a handler through its faces is read through the face exposing the most. - * When a block's faces expose its slots differently, the slots are shown per side as {@link SideReader} groups them. + * without a side, with what the sides do after it. When a block's faces expose its contents differently, each group of + * faces {@link SideReader} finds is shown with its own contents instead. * No chunk is loaded and containers whose loot is not generated yet are not read, because reading their slots would * generate it. Each part is read independently, so one failing handler does not hide the others. */ @@ -35,10 +35,6 @@ public final class StorageReader { public static final int MAX_SLOTS = 96; public static final int MAX_TANKS = 32; - /** A block's handler and the face it was read through, which is null for the handler without a side. */ - record Found(T handler, Direction face) { - } - private StorageReader() { } @@ -62,10 +58,9 @@ private static void readBlock(ScriptTarget.PlacedBlock block, ScriptFacts facts) facts.section("Items").text("Contents", pending); return; } - Found found = contents(block, Capabilities.ItemHandler.BLOCK, IItemHandler::getSlots); List>> sides = SideReader.items(block); if (sides.size() == 1) { - items(block.blockEntity(), () -> through(block, "Items", found, facts), facts); + items(block.blockEntity(), () -> handler(block, Capabilities.ItemHandler.BLOCK, null), facts); return; } // Each group shows its slots, the contents among them, and all groups share the section's facts. @@ -78,10 +73,22 @@ private static void readBlock(ScriptTarget.PlacedBlock block, ScriptFacts facts) SideReader.writeItems(group, section, perGroup); } }); - facts.guarded("Fluids", () -> fluids(through(block, "Fluids", - contents(block, Capabilities.FluidHandler.BLOCK, IFluidHandler::getTanks), facts), facts)); - facts.guarded("Energy", () -> energy(through(block, "Energy", - contents(block, Capabilities.EnergyStorage.BLOCK, IEnergyStorage::getMaxEnergyStored), facts), facts)); + facts.guarded("Fluids", () -> sided("Fluids", () -> SideReader.fluids(block), + () -> fluids(handler(block, Capabilities.FluidHandler.BLOCK, null), facts), facts)); + facts.guarded("Energy", () -> sided("Energy", () -> SideReader.energy(block), + () -> energy(handler(block, Capabilities.EnergyStorage.BLOCK, null), facts), facts)); + } + + /** + * The contents without a side and what the sides do, or where the sides differ, each one's rows with its own amounts, + * the block having no contents of its own to show. Sides that cannot be read leave the contents shown. + */ + private static void sided(String section, Supplier>> read, Runnable contents, + ScriptFacts facts) { + List> sides = new ArrayList<>(); + facts.guarded(section, () -> sides.addAll(read.get())); + if (sides.size() <= 1) contents.run(); + SideReader.write(sides, section, facts); } private static void readEntity(Entity entity, ScriptFacts facts) { @@ -107,24 +114,6 @@ private static void energyWithFlags(IEnergyStorage storage, ScriptFacts facts) { } } - /** - * The block's handler without a side, or when it has none, the handler of the face whose {@code size} is largest. - * The handler is null when no face exposes one either. - */ - static Found contents(ScriptTarget.PlacedBlock block, BlockCapability capability, - ToIntFunction size) { - T unsided = handler(block, capability, null); - if (unsided != null) return new Found<>(unsided, null); - Found best = new Found<>(null, null); - for (Direction face : Direction.values()) { - T handler = handler(block, capability, face); - if (handler != null && (best.handler() == null || size.applyAsInt(handler) > size.applyAsInt(best.handler()))) { - best = new Found<>(handler, face); - } - } - return best; - } - /** The block's handler through {@code face}; a double chest whose other half is not loaded has no item handler. */ static T handler(ScriptTarget.PlacedBlock block, BlockCapability capability, Direction face) { if (capability == Capabilities.ItemHandler.BLOCK && otherChestHalfUnloaded(block.level(), block.pos(), block.state())) { @@ -139,14 +128,6 @@ static String unreadableItems(ScriptTarget.PlacedBlock block) { return pending != null ? pending : otherChestHalfUnreadable(block.level(), block.pos(), block.state()); } - /** The found handler, noting the face it was read through when it is not the handler without a side. */ - private static T through(ScriptTarget.PlacedBlock block, String section, Found found, ScriptFacts facts) { - if (found.handler() != null && found.face() != null) { - facts.section(section).text("Read through", Faces.name(found.face(), Faces.facing(block.state()))); - } - return found.handler(); - } - /** * Reports the slots of {@code owner}'s item handler, unless {@code owner} is a container whose loot is not * generated yet; then the handler is never requested, because reading any slot would generate the loot. diff --git a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java index 8704703da..dd51932e1 100644 --- a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java +++ b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java @@ -5,6 +5,7 @@ import java.util.EnumMap; import java.util.List; +import java.util.Locale; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -54,6 +55,29 @@ void aBlockWithoutFacingUsesCompassNames() { ), SideReader.group("closed", faces, null, String::equals)); } + @Test + void facesOfSeparateStoragesThatDoTheSameStayApartWithTheirAmounts() { + SideReader.Exposed input = new SideReader.Exposed(List.of(), "1,000 / 8,000 FE: takes and gives", "Takes and gives"); + SideReader.Exposed output = new SideReader.Exposed(List.of(), "6,000 / 8,000 FE: takes and gives", "Takes and gives"); + Map faces = new EnumMap<>(Direction.class); + for (Direction face : Direction.values()) faces.put(face, face == Direction.DOWN ? output : input); + + assertEquals(List.of(SideReader.Exposed.NONE, input, output), + SideReader.group(SideReader.Exposed.NONE, faces, null, SideReader.Exposed::same).stream() + .map(SideReader.Group::view).toList()); + } + + @Test + void amountsAreGroupedNumbersOfTheirCapacity() { + Locale before = Locale.getDefault(); + Locale.setDefault(Locale.ROOT); + try { + assertEquals("4,000 / 8,000 mB", SideReader.amounts(4_000, 8_000, "mB")); + } finally { + Locale.setDefault(before); + } + } + @Test void accessNamesWhatTheStateCannotTell() { assertEquals("Takes and gives", SideReader.access(true, true)); From 1e1fa193743cf5778a6887eb53e177369f8751c0 Mon Sep 17 00:00:00 2001 From: Pelotrio <45769595+Pelotrio@users.noreply.github.com> Date: Tue, 6 Oct 2026 01:08:30 +0200 Subject: [PATCH 2/3] Sides that could not be read write nothing; a language reload republishes the packs' titles Co-Authored-By: Claude Opus 5.5 (1M context) --- .../minecraft_ta/totaldebug/client/TotalDebugClient.java | 4 ++-- .../minecraft_ta/totaldebug/inspection/SideReader.java | 1 + .../totaldebug/inspection/SideReaderTest.java | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java index aa9e01998..74e1d28e0 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/client/TotalDebugClient.java @@ -188,17 +188,17 @@ public static Optional current() { public void resourcesReloaded() { this.resources.resourcesChanged(); languageReloaded(); - this.packStacks.republish(); } /** * The language was reloaded alone, as Companion's quick reload of a language file does. Only translated names - * changed, which the catalog captures again; the snapshot's models and textures and the packs did not, and capturing + * changed, which the catalog and the packs' titles hold; the snapshot's models and textures did not, and capturing * them again would take seconds. Client thread only. */ public void languageReloaded() { this.catalogs.recapture(); this.companionApp.announceInventory(); + this.packStacks.republish(); } /** diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java index cabf64534..159fa140f 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java @@ -106,6 +106,7 @@ static void writeItems(Group> group, ScriptFacts.Section section, int * block's. The groups share the section's facts, as slots do. */ static void write(List> groups, String section, ScriptFacts facts) { + if (groups.isEmpty()) return; if (groups.size() == 1) { String access = groups.getFirst().view().access(); if (!access.equals(NOT_EXPOSED)) facts.section(section).text(groups.getFirst().label(), access); diff --git a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java index dd51932e1..13eaae0d2 100644 --- a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java +++ b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java @@ -1,5 +1,6 @@ package com.github.minecraft_ta.totaldebug.inspection; +import com.github.minecraft_ta.totaldebug.script.ScriptFacts; import net.minecraft.core.Direction; import org.junit.jupiter.api.Test; @@ -67,6 +68,13 @@ void facesOfSeparateStoragesThatDoTheSameStayApartWithTheirAmounts() { .map(SideReader.Group::view).toList()); } + @Test + void sidesThatCouldNotBeReadWriteNothing() { + ScriptFacts facts = new ScriptFacts(message -> { }); + SideReader.write(List.of(), "Fluids", facts); + assertEquals(List.of(), facts.snapshot()); + } + @Test void amountsAreGroupedNumbersOfTheirCapacity() { Locale before = Locale.getDefault(); From f0beec9639822e402e1b7be366bf1e0a44696de7 Mon Sep 17 00:00:00 2001 From: Pelotrio <45769595+Pelotrio@users.noreply.github.com> Date: Tue, 6 Oct 2026 01:21:56 +0200 Subject: [PATCH 3/3] A failing side read is reported once Co-Authored-By: Claude Opus 5.5 (1M context) --- .../minecraft_ta/totaldebug/inspection/SideReader.java | 1 - .../minecraft_ta/totaldebug/inspection/StorageReader.java | 8 +++----- .../totaldebug/inspection/SideReaderTest.java | 8 -------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java index 159fa140f..cabf64534 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/SideReader.java @@ -106,7 +106,6 @@ static void writeItems(Group> group, ScriptFacts.Section section, int * block's. The groups share the section's facts, as slots do. */ static void write(List> groups, String section, ScriptFacts facts) { - if (groups.isEmpty()) return; if (groups.size() == 1) { String access = groups.getFirst().view().access(); if (!access.equals(NOT_EXPOSED)) facts.section(section).text(groups.getFirst().label(), access); diff --git a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java index 4ed836c0b..07080338c 100644 --- a/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java +++ b/mod/src/main/java/com/github/minecraft_ta/totaldebug/inspection/StorageReader.java @@ -20,7 +20,6 @@ import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.items.IItemHandler; -import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -81,13 +80,12 @@ private static void readBlock(ScriptTarget.PlacedBlock block, ScriptFacts facts) /** * The contents without a side and what the sides do, or where the sides differ, each one's rows with its own amounts, - * the block having no contents of its own to show. Sides that cannot be read leave the contents shown. + * the block having no contents of its own to show. */ private static void sided(String section, Supplier>> read, Runnable contents, ScriptFacts facts) { - List> sides = new ArrayList<>(); - facts.guarded(section, () -> sides.addAll(read.get())); - if (sides.size() <= 1) contents.run(); + List> sides = read.get(); + if (sides.size() == 1) contents.run(); SideReader.write(sides, section, facts); } diff --git a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java index 13eaae0d2..dd51932e1 100644 --- a/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java +++ b/mod/src/test/java/com/github/minecraft_ta/totaldebug/inspection/SideReaderTest.java @@ -1,6 +1,5 @@ package com.github.minecraft_ta.totaldebug.inspection; -import com.github.minecraft_ta.totaldebug.script.ScriptFacts; import net.minecraft.core.Direction; import org.junit.jupiter.api.Test; @@ -68,13 +67,6 @@ void facesOfSeparateStoragesThatDoTheSameStayApartWithTheirAmounts() { .map(SideReader.Group::view).toList()); } - @Test - void sidesThatCouldNotBeReadWriteNothing() { - ScriptFacts facts = new ScriptFacts(message -> { }); - SideReader.write(List.of(), "Fluids", facts); - assertEquals(List.of(), facts.snapshot()); - } - @Test void amountsAreGroupedNumbersOfTheirCapacity() { Locale before = Locale.getDefault();