webbukkit / DynmapBlockScan

Tool to scan post-1.8 MC blocks and JSON model data to automatically generate Dynmap models
63 stars 30 forks source link

[1.10.2] java.util.NoSuchElementException with MCMultiPart #10

Closed LiskoSlayer63 closed 6 years ago

LiskoSlayer63 commented 6 years ago

I'm trying to create a new server based on Forge and BlockScan worked flawlessly when there wasn't any mods that created custom blocks. I added more mods and then BlockScan suddenly started crashing during a startup. I'm not sure which mod causes the crash or is it just BlockScan itself.

I uploaded the crash log here.

EDIT: I managed to track down which mod caused the crash, it was MCMultiPart (v1.4.0). Not sure why it does so, tho. If I understood it right, it creates only one block (?) called "mcmultipart:multipart", is there something special on this one which could crash the BlockScan?

SparxySys commented 6 years ago

Appears to be a bug due to BlockState deserializer making assumptions. Patch below appears to fix the crash

diff --git a/src/main/java/org/dynmap/blockscan/blockstate/BlockState.java b/src/main/java/org/dynmap/blockscan/blockstate/BlockState.java
index 931b36f..01824af 100644
--- a/src/main/java/org/dynmap/blockscan/blockstate/BlockState.java
+++ b/src/main/java/org/dynmap/blockscan/blockstate/BlockState.java
@@ -4,6 +4,7 @@ import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -169,7 +170,8 @@ public class BlockState {
                         else {
                             JsonObject vobj = e.getValue().getAsJsonObject();
                             // If first element is an object (versus a value)
-                            if(vobj.entrySet().iterator().next().getValue().isJsonObject()) {
+                            Iterator<Map.Entry<String, JsonElement>> vobjIterator = vobj.entrySet().iterator();
+                            if(vobjIterator.hasNext() && vobjIterator.next().getValue().isJsonObject()) {
                                 // Assume all subelements are values for key=value test
                                 for (Entry<String, JsonElement> se : vobj.entrySet()) {
                                     bs.forge_variants.put(new BaseCondition(e.getKey() + "=" + se.getKey()), context.deserialize(se.getValue(), ForgeVariantV1List.class));
Zelow79 commented 6 years ago

How do I apply this patch?

SparxySys commented 6 years ago

@Zelow79 Since you do not seem to be familiar with how coding and compiling works, I have attached a jar file with this patch built in for version 1.10.2. DynmapBlockScan-3.0-alpha-1-forge-1.10.2-with-patch.zip Please keep in mind this mod is not at all mature yet and will probably not have the level of functionality you are expecting or hoping for.

Zelow79 commented 6 years ago

If it allows even some of the modded blocks to show up and can still sent over the internet via apache like the last one, I will be fine. Eitherway better to have tried then not at all. Thank you for compiling it for me. Edit: So far it is working as good or better than I could have expected. Thanks again for all your help.

LiskoSlayer63 commented 6 years ago

@DarkSpyro003 Thanks for your patch, it seems to be working now.

Zaphara94 commented 6 years ago

I get this error every time DynmapBlockScan starts up, even after uploading your patch @DarkSpyro003

SparxySys commented 6 years ago

Hello @Zaphara94, This is a different error than what was reported in this issue. I suggest you open an issue of your own. I'm also not the maintainer of this mod, and the mod is in alpha state, so I'm afraid I won't be offering any more support for it for now.

Chemox commented 6 years ago

As the server doesn't have the proper graphical methods initialised it won't work on the server! You'll have to run it on the client and copy over the generated files :)

Zaphara94 commented 6 years ago

Oh sweet, completely did not even think about that @Chemox thank you! ^^

mikeprimm commented 6 years ago

Formal fix built - please check out latest build: http://dynmap.us/builds/DynmapBlockScan/DynmapBlockScan-3.0-alpha-1-forge-1.10.2.jar