Skip to content

Commit 525cd31

Browse files
committed
Add state to Geoscanner return
1 parent 057dcbd commit 525cd31

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GeoScannerPeripheral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static List<Map<String, Object>> scan(Level level, BlockPos center, int
7373
ResourceLocation name = BuiltInRegistries.BLOCK.getKey(block);
7474
data.put("name", name == null ? "unknown" : name.toString());
7575
data.put("tags", LuaConverter.getHolderTags(block.builtInRegistryHolder()));
76-
data.put("state", ScanUtils.serializeState(state));
76+
data.put("state", LuaConverter.serializeState(state));
7777

7878
result.add(data);
7979
});

src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.world.item.Item;
2525
import net.minecraft.world.item.ItemStack;
2626
import net.minecraft.world.level.Level;
27+
import net.minecraft.world.level.block.state.BlockState;
2728
import net.minecraft.world.level.block.state.properties.Property;
2829
import net.minecraft.world.level.material.Fluid;
2930
import net.neoforged.neoforge.common.IShearable;
@@ -102,6 +103,16 @@ public static Object stateToObject(Comparable<?> blockStateValue) {
102103
}
103104
}
104105

106+
public static Map<String, String> serializeState(BlockState state){
107+
Map<String, String> map = new HashMap<>();
108+
109+
state.getValues().forEach(((prop, val) -> {
110+
map.put(prop.getName(), val.toString());
111+
}));
112+
113+
return map;
114+
}
115+
105116
public static Object posToObject(BlockPos pos) {
106117
if (pos == null) {
107118
return null;

src/main/java/de/srendi/advancedperipherals/common/util/ScanUtils.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,4 @@ public static void traverseBlocks(Level world, BlockPos center, int radius, BiCo
4040
}
4141
}
4242
}
43-
44-
public static Map<String, String> serializeState(BlockState state){
45-
Map<String, String> map = new HashMap<>();
46-
47-
state.getValues().forEach(((prop, val) -> {
48-
map.put(prop.getName(), val.toString());
49-
}));
50-
51-
return map;
52-
}
5343
}

0 commit comments

Comments
 (0)