From 0fe7cf94a9072ed8014bfc272cfc1ecfb64530da Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 2 Jul 2020 16:41:19 +0200 Subject: [PATCH 1/5] Add texture-key check. Fixes #53 --- .../bluemap/core/resourcepack/BlockModelResource.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/BlockModelResource.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/BlockModelResource.java index 13e767a0..47fce7ad 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/BlockModelResource.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/BlockModelResource.java @@ -269,7 +269,6 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements for (Entry entry : config.getNode("textures").getChildrenMap().entrySet()) { if (entry.getKey().equals(JSON_COMMENT)) continue; - textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString(null)); } @@ -426,6 +425,8 @@ private Vector4f readVector4f(ConfigurationNode node) throws ParseResourceExcept } private Texture getTexture(String key) throws NoSuchElementException, FileNotFoundException, IOException { + if (key.isEmpty() || key.equals("#")) throw new NoSuchElementException("Empty texture key or name!"); + if (key.charAt(0) == '#') { String value = textures.get(key.substring(1)); if (value == null) throw new NoSuchElementException("There is no texture defined for the key " + key); From a2cefd78aa4d73c6382bee17ebea730fe12a657f Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 2 Jul 2020 17:11:38 +0200 Subject: [PATCH 2/5] Change command requirements for base command. Fixes #52 --- .../bluemap/common/plugin/commands/Commands.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java index 8fc439a5..4b53a890 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java @@ -87,7 +87,7 @@ public void init() { // commands LiteralCommandNode baseCommand = literal("bluemap") - .requires(requirements("bluemap.status")) + .requires(requirementsUnloaded("bluemap.status")) .executes(this::statusCommand) .build(); @@ -277,6 +277,11 @@ private Optional parseUUID(String uuidString) { public int statusCommand(CommandContext context) { CommandSource source = commandSourceInterface.apply(context.getSource()); + if (!plugin.isLoaded()) { + source.sendMessage(Text.of(TextColor.RED, "BlueMap is not loaded! Try /bluemap reload")); + return 0; + } + source.sendMessages(helper.createStatusMessage()); return 1; } From 53093a43ff7ac1bbae3b7c2818995ea1410bf271 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 2 Jul 2020 17:14:16 +0200 Subject: [PATCH 3/5] Fix map name being compared instead of map-id. Fixes #51 --- .../de/bluecolored/bluemap/common/plugin/commands/Commands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java index 4b53a890..3404c6bb 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java @@ -255,7 +255,7 @@ private Optional parseWorld(String worldName) { private Optional parseMap(String mapId) { for (MapType map : plugin.getMapTypes()) { - if (map.getName().equalsIgnoreCase(mapId)) { + if (map.getId().equalsIgnoreCase(mapId)) { return Optional.of(map); } } From 4c65c475ddf1c2f109f3a82f7bd298c29e1b0fbb Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 2 Jul 2020 17:20:27 +0200 Subject: [PATCH 4/5] Fix possible NPE when loading render-manager state. Fixes #46 --- .../main/java/de/bluecolored/bluemap/common/RenderManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/RenderManager.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/RenderManager.java index 7c9935e0..53f1ac9c 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/RenderManager.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/RenderManager.java @@ -265,7 +265,7 @@ public void readState(DataInputStream in, Collection mapTypes) throws I tiles.add(tile); } - createTickets(mapType, tiles); + if (mapType != null) createTickets(mapType, tiles); } //read tasks From 4fbd785b3e32a61eb8b0b3685d698a3768b6f5e6 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 2 Jul 2020 17:37:58 +0200 Subject: [PATCH 5/5] Catch exception when a model defines a collapsed face. Fixes #43 --- .../hires/blockmodel/ResourceModelBuilder.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/hires/blockmodel/ResourceModelBuilder.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/hires/blockmodel/ResourceModelBuilder.java index 3acc10de..b5515cd4 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/hires/blockmodel/ResourceModelBuilder.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/hires/blockmodel/ResourceModelBuilder.java @@ -189,8 +189,17 @@ private void createElementFace(BlockStateModel model, TransformedBlockModelResou Texture texture = face.getTexture(); int textureId = texture.getId(); - ExtendedFace f1 = new ExtendedFace(c0, c1, c2, uvs[0], uvs[1], uvs[2], textureId); - ExtendedFace f2 = new ExtendedFace(c0, c2, c3, uvs[0], uvs[2], uvs[3], textureId); + ExtendedFace f1; + ExtendedFace f2; + + try { + f1 = new ExtendedFace(c0, c1, c2, uvs[0], uvs[1], uvs[2], textureId); + f2 = new ExtendedFace(c0, c2, c3, uvs[0], uvs[2], uvs[3], textureId); + } catch (ArithmeticException ex) { + // This error is thrown when a model defined a face that has no surface (all 3 points are on one line) + // we catch it here and simply ignore the face + return; + } //tint the face Vector3f color = Vector3f.ONE;