Skip to content

Commit 00eddc5

Browse files
committed
Fix some loot tables being empty and blocks list resolution
1 parent 3a77832 commit 00eddc5

14 files changed

Lines changed: 131 additions & 227 deletions

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver
88
- Semantic Versioning: https://semver.org/spec/v2.0.0.html
99

1010

11+
## [0.2.0] - 2025-12-28
12+
### Added
13+
- Add Igloo structure retrieval to VanillaStructureProvider (as test case)
14+
- Add structure preview for those providing structure schematic data
15+
- Add biome, dimension, rarity information to StructureInfo and display in GUI
16+
17+
### Fixed
18+
- Fix loot table resolution vanilla provider (some loot tables were missing)
19+
20+
### Changed
21+
- Change hardcoded block->item mapping to handle GuiBlocksWindow better
22+
23+
1124
## [0.1.1] - 2025-12-27
1225
### Added
1326
- Keybind handler (`KeybindHandler`) to open the scanner GUI (default: P key)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414

1515
apply plugin: 'net.minecraftforge.gradle.forge'
1616

17-
version = "0.1.1"
17+
version = "0.2.0"
1818
group = "com.simplestructurescanner"
1919
archivesBaseName = "simplestructurescanner"
2020

src/main/java/com/simplestructurescanner/SimpleStructureScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class SimpleStructureScanner {
2020
public static final String MODID = "simplestructurescanner";
2121
public static final String NAME = "Simple Structure Scanner";
22-
public static final String VERSION = "0.1.1";
22+
public static final String VERSION = "0.2.0";
2323

2424
public static final Logger LOGGER = LogManager.getLogger(MODID);
2525

src/main/java/com/simplestructurescanner/client/event/ClientRenderEvents.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
107107
// Calculate dimensions
108108
int lineHeight = mc.fontRenderer.FONT_HEIGHT;
109109
int maxWidth = 0;
110-
for (String line : lines) {
111-
maxWidth = Math.max(maxWidth, mc.fontRenderer.getStringWidth(line));
112-
}
110+
for (String line : lines) maxWidth = Math.max(maxWidth, mc.fontRenderer.getStringWidth(line));
113111

114112
int boxW = maxWidth + paddingInternal * 2 + 8; // Extra 8 for color indicator
115113
int boxH = lines.size() * lineHeight + (lines.size() - 1) * lineSpacing + paddingInternal * 2;

src/main/java/com/simplestructurescanner/client/gui/GuiLootWindow.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,25 @@ private void resolveLootTables() {
101101
simulationCount = LootTableResolver.getSimulationCount();
102102

103103
for (LootEntry entry : lootEntries) {
104+
List<LootItem> entryLoot = new ArrayList<>();
105+
106+
// Try to resolve from loot table ID first
104107
if (entry.lootTableId != null) {
105-
resolvedLoot.add(LootTableResolver.resolveLootTableWithSimulation(
106-
world, entry.lootTableId, mc.player));
108+
entryLoot = LootTableResolver.resolveLootTableWithSimulation(
109+
world, entry.lootTableId, mc.player);
107110
}
108-
109-
if (entry.possibleDrops != null) {
110-
List<LootItem> directItems = new ArrayList<>();
111+
112+
// If loot table resolution failed or wasn't available, use possibleDrops as fallback
113+
if (entryLoot.isEmpty() && entry.possibleDrops != null && !entry.possibleDrops.isEmpty()) {
111114
for (ItemStack stack : entry.possibleDrops) {
112115
int count = stack.getCount();
113116
stack = stack.copy();
114117
stack.setCount(1);
115-
directItems.add(new LootItem(stack, count * simulationCount));
118+
entryLoot.add(new LootItem(stack, count * simulationCount));
116119
}
117-
resolvedLoot.add(directItems);
118120
}
121+
122+
resolvedLoot.add(entryLoot);
119123
}
120124
}
121125

src/main/java/com/simplestructurescanner/client/gui/GuiStructureScanner.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ public void initGui() {
100100
String lastStructure = ModConfig.getClientLastSelectedStructure();
101101
if (lastStructure != null && !lastStructure.isEmpty()) {
102102
ResourceLocation id = new ResourceLocation(lastStructure);
103-
if (StructureProviderRegistry.getStructureInfo(id) != null) {
104-
selectStructure(id);
105-
}
103+
if (StructureProviderRegistry.getStructureInfo(id) != null) selectStructure(id);
106104
}
107105

108106
// Restore modal windows if they were hidden for navigation
@@ -547,11 +545,9 @@ private void buildPreviewRenderer(List<StructureLayer> layers) {
547545
for (int x = 0; x < layer.width; x++) {
548546
for (int z = 0; z < layer.depth; z++) {
549547
IBlockState state = layer.getBlockState(x, z);
550-
if (state == null || state.getBlock() == Blocks.AIR) continue;
551-
if (state.getBlock() == Blocks.STRUCTURE_VOID) continue;
548+
if (state == null || state.getBlock() == Blocks.AIR || state.getBlock() == Blocks.STRUCTURE_VOID) continue;
552549

553-
BlockPos pos = new BlockPos(x, y, z);
554-
previewRenderer.getWorld().addBlock(pos, state);
550+
previewRenderer.getWorld().addBlock(new BlockPos(x, y, z), state);
555551
}
556552
}
557553
}
@@ -719,20 +715,6 @@ private void applyFilter() {
719715
}
720716
}
721717

722-
// Sort: selected first, then tracked, then searchable, then alphabetically
723-
ResourceLocation currentSelected = parent.selected;
724-
filteredStructures.sort(Comparator
725-
.<ResourceLocation, Integer>comparing(id -> id.equals(currentSelected) ? 0 : 1)
726-
.thenComparing(id -> StructureSearchManager.isTracked(id) ? 0 : 1)
727-
.thenComparing(id -> StructureProviderRegistry.canBeSearched(id) ? 0 : 1)
728-
.thenComparing(id -> {
729-
if (ClientSettings.i18nNames) {
730-
StructureInfo info = StructureProviderRegistry.getStructureInfo(id);
731-
return info != null ? I18n.format(info.getDisplayName()) : id.getPath();
732-
}
733-
return id.toString();
734-
}));
735-
736718
// Clamp scroll
737719
float maxScroll = getMaxScroll();
738720
if (scrollOffset > maxScroll) scrollOffset = maxScroll;
@@ -836,11 +818,10 @@ public void draw(int mouseX, int mouseY) {
836818
int visibleStart = (int) (scrollOffset / entryHeight);
837819
int visibleEnd = Math.min(filteredStructures.size(), visibleStart + (height / entryHeight) + 2);
838820

839-
// FIXME: list needs to be sorted by name with current search at the top
821+
// FIXME: list needs to be sorted by name with currently tracked at the top
840822

841823
for (int i = visibleStart; i < visibleEnd; i++) {
842824
int entryY = y + (i * entryHeight) - (int) scrollOffset;
843-
844825
if (entryY + entryHeight < y || entryY > y + height) continue;
845826

846827
ResourceLocation id = filteredStructures.get(i);

src/main/java/com/simplestructurescanner/client/render/DummyChunkProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ public Chunk getLoadedChunk(int x, int z) {
3535
@Override
3636
public Chunk provideChunk(int x, int z) {
3737
long chunkKey = ChunkPos.asLong(x, z);
38-
if (loadedChunks.containsKey(chunkKey)) {
39-
return loadedChunks.get(chunkKey);
40-
}
38+
if (loadedChunks.containsKey(chunkKey)) return loadedChunks.get(chunkKey);
4139

4240
Chunk chunk = new Chunk(world, x, z);
4341
loadedChunks.put(chunkKey, chunk);

src/main/java/com/simplestructurescanner/client/render/DummyWorld.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public boolean setBlockState(@Nonnull BlockPos pos, @Nonnull IBlockState newStat
107107
@Nonnull
108108
@Override
109109
public IBlockState getBlockState(@Nonnull BlockPos pos) {
110-
if (!renderedBlocks.contains(pos)) {
111-
return Blocks.AIR.getDefaultState();
112-
}
110+
if (!renderedBlocks.contains(pos)) return Blocks.AIR.getDefaultState();
113111

114112
return super.getBlockState(pos);
115113
}

src/main/java/com/simplestructurescanner/client/render/StructurePreviewRenderer.java

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ public class StructurePreviewRenderer {
3939
private int backgroundColor = 0xFF1A1A1A;
4040

4141
// Isometric camera settings
42+
private enum LightingMode {
43+
STRUCTURE,
44+
WORLD
45+
}
46+
4247
private static final float ISOMETRIC_PITCH = 30f;
4348
private static final float ROTATION_SPEED = 20f;
49+
private static final float ZOOM_FACTOR = 0.75f;
50+
private static final LightingMode LIGHTING_MODE = LightingMode.STRUCTURE;
4451

4552
public StructurePreviewRenderer() {
4653
this.world = new DummyWorld();
@@ -150,9 +157,7 @@ public void render(float guiX, float guiY, float guiWidth, float guiHeight) {
150157

151158
// === RESTORE STATE ===
152159
// Disable scissor
153-
if (!wasScissor) {
154-
GL11.glDisable(GL11.GL_SCISSOR_TEST);
155-
}
160+
if (!wasScissor) GL11.glDisable(GL11.GL_SCISSOR_TEST);
156161

157162
// Restore viewport
158163
GlStateManager.viewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3));
@@ -169,57 +174,15 @@ public void render(float guiX, float guiY, float guiWidth, float guiHeight) {
169174

170175
// Restore texture binding
171176
GlStateManager.bindTexture(oldTexture);
172-
173-
// Restore blend state
174-
if (wasBlend) {
175-
GlStateManager.enableBlend();
176-
} else {
177-
GlStateManager.disableBlend();
178-
}
179177
GL11.glBlendFunc(oldBlendSrc, oldBlendDst);
180-
181-
// Restore depth
182-
if (wasDepth) {
183-
GlStateManager.enableDepth();
184-
} else {
185-
GlStateManager.disableDepth();
186-
}
187-
188-
// Restore cull
189-
if (wasCull) {
190-
GlStateManager.enableCull();
191-
} else {
192-
GlStateManager.disableCull();
193-
}
194-
195-
// Restore lighting
196-
if (wasLighting) {
197-
GlStateManager.enableLighting();
198-
} else {
199-
GlStateManager.disableLighting();
200-
}
201-
202-
// Restore alpha
203-
if (wasAlpha) {
204-
GlStateManager.enableAlpha();
205-
} else {
206-
GlStateManager.disableAlpha();
207-
}
208-
209-
// Restore rescale
210-
if (wasRescale) {
211-
GlStateManager.enableRescaleNormal();
212-
} else {
213-
GlStateManager.disableRescaleNormal();
214-
}
215-
216-
// Restore color
178+
if (wasBlend) GlStateManager.enableBlend(); else GlStateManager.disableBlend();
179+
if (wasDepth) GlStateManager.enableDepth(); else GlStateManager.disableDepth();
180+
if (wasCull) GlStateManager.enableCull(); else GlStateManager.disableCull();
181+
if (wasLighting) GlStateManager.enableLighting(); else GlStateManager.disableLighting();
182+
if (wasAlpha) GlStateManager.enableAlpha(); else GlStateManager.disableAlpha();
183+
if (wasRescale) GlStateManager.enableRescaleNormal(); else GlStateManager.disableRescaleNormal();
217184
GlStateManager.color(colorBuf.get(0), colorBuf.get(1), colorBuf.get(2), colorBuf.get(3));
218-
219-
// Restore depth mask
220185
GlStateManager.depthMask(true);
221-
222-
// Disable item lighting that block rendering may have enabled
223186
RenderHelper.disableStandardItemLighting();
224187
}
225188

src/main/java/com/simplestructurescanner/searching/StructureSearchManager.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,15 @@ private static void loadFromConfig() {
5858

5959
private static void saveToConfig() {
6060
List<String> ids = new ArrayList<>();
61-
for (ResourceLocation loc : searchedStructures) {
62-
ids.add(loc.toString());
63-
}
61+
for (ResourceLocation loc : searchedStructures) ids.add(loc.toString());
6462
ModConfig.setClientTrackedIds(ids);
6563
}
6664

6765
private static void assignColor(ResourceLocation id) {
6866
if (!structureColors.containsKey(id)) {
6967
// Find the first available color index
7068
int colorIndex = 0;
71-
while (usedColorIndices.contains(colorIndex)) {
72-
colorIndex++;
73-
}
69+
while (usedColorIndices.contains(colorIndex)) colorIndex++;
7470
usedColorIndices.add(colorIndex);
7571
structureColorIndices.put(id, colorIndex);
7672
structureColors.put(id, COLORS[colorIndex % COLORS.length]);
@@ -79,9 +75,7 @@ private static void assignColor(ResourceLocation id) {
7975

8076
private static void freeColor(ResourceLocation id) {
8177
Integer colorIndex = structureColorIndices.remove(id);
82-
if (colorIndex != null) {
83-
usedColorIndices.remove(colorIndex);
84-
}
78+
if (colorIndex != null) usedColorIndices.remove(colorIndex);
8579
structureColors.remove(id);
8680
}
8781

@@ -131,9 +125,7 @@ public static void stopTracking(ResourceLocation id) {
131125
* on the next client tick.
132126
*/
133127
public static void requestSearch(ResourceLocation id) {
134-
if (searchedStructures.contains(id)) {
135-
pendingSearches.add(id);
136-
}
128+
if (searchedStructures.contains(id)) pendingSearches.add(id);
137129
}
138130

139131
/**

0 commit comments

Comments
 (0)