From 49ddaa7c81b5b92551fc94991d5fb4249508d601 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Tue, 7 Jan 2020 14:27:48 +0100 Subject: [PATCH] Fix some possible errors if blocks dont contain expected properties --- .../core/mca/extensions/DoorExtension.java | 3 ++- .../mca/extensions/DoublePlantExtension.java | 3 ++- .../mca/extensions/RedstoneExtension.java | 22 +++++++++++++------ .../mca/extensions/WallConnectExtension.java | 10 +++++---- README.md | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoorExtension.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoorExtension.java index 77322e9b..de25dc7f 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoorExtension.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoorExtension.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Map.Entry; +import java.util.Objects; import com.flowpowered.math.vector.Vector3i; import com.google.common.collect.Lists; @@ -50,7 +51,7 @@ public class DoorExtension implements BlockStateExtension { public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { BlockState otherDoor; - boolean isLower = state.getProperties().get("half").equals("lower"); + boolean isLower = Objects.equals(state.getProperties().get("half"), "lower"); if (isLower) { otherDoor = world.getBlockState(pos.add(Direction.UP.toVector())); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoublePlantExtension.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoublePlantExtension.java index 79f9ea5b..32852924 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoublePlantExtension.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoublePlantExtension.java @@ -25,6 +25,7 @@ package de.bluecolored.bluemap.core.mca.extensions; import java.util.Collection; +import java.util.Objects; import com.flowpowered.math.vector.Vector3i; import com.google.common.collect.Lists; @@ -46,7 +47,7 @@ public class DoublePlantExtension implements BlockStateExtension { @Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { - if (state.getProperties().get("half").equals("upper")) { + if (Objects.equals(state.getProperties().get("half"), "upper")) { BlockState otherPlant = world.getBlockState(pos.add(Direction.DOWN.toVector())); return otherPlant.with("half", "upper"); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/RedstoneExtension.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/RedstoneExtension.java index 41090c13..d1175d72 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/RedstoneExtension.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/RedstoneExtension.java @@ -58,20 +58,28 @@ public class RedstoneExtension implements BlockStateExtension { @Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { + BlockState up = world.getBlockState(pos.add(0, 1, 0)); + boolean upBlocking = !up.equals(BlockState.AIR); + state = state - .with("north", connection(world, pos, state, Direction.NORTH)) - .with("east", connection(world, pos, state, Direction.EAST)) - .with("south", connection(world, pos, state, Direction.SOUTH)) - .with("west", connection(world, pos, state, Direction.WEST)); + .with("north", connection(world, pos, upBlocking, Direction.NORTH)) + .with("east", connection(world, pos, upBlocking, Direction.EAST)) + .with("south", connection(world, pos, upBlocking, Direction.SOUTH)) + .with("west", connection(world, pos, upBlocking, Direction.WEST)); return state; } - private String connection(MCAWorld world, Vector3i pos, BlockState state, Direction direction) { - BlockState next = world.getBlockState(pos.add(direction.toVector())); + private String connection(MCAWorld world, Vector3i pos, boolean upBlocking, Direction direction) { + Vector3i directionVector = direction.toVector(); + + BlockState next = world.getBlockState(pos.add(directionVector)); if (CONNECTIBLE.contains(next.getFullId())) return "side"; - //TODO: up + if (!upBlocking) { + BlockState nextup = world.getBlockState(pos.add(directionVector.getX(), directionVector.getY() + 1, directionVector.getZ())); + if (nextup.getFullId().equals("minecraft:redstone_wire")) return "up"; + } return "none"; } diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/WallConnectExtension.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/WallConnectExtension.java index dc2592a8..44526c9a 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/WallConnectExtension.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/WallConnectExtension.java @@ -25,6 +25,7 @@ package de.bluecolored.bluemap.core.mca.extensions; import java.util.HashSet; +import java.util.Objects; import java.util.Set; import com.flowpowered.math.vector.Vector3i; @@ -37,7 +38,8 @@ public class WallConnectExtension extends ConnectSameOrFullBlockExtension { private static final HashSet AFFECTED_BLOCK_IDS = Sets.newHashSet( - "minecraft:cobblestone_wall" + "minecraft:cobblestone_wall", + "minecraft:mossy_cobblestone_wall" ); @Override @@ -45,9 +47,9 @@ public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { state = super.extend(world, pos, state); if ( - state.getProperties().get("north").equals(state.getProperties().get("south")) && - state.getProperties().get("east").equals(state.getProperties().get("west")) && - !state.getProperties().get("north").equals(state.getProperties().get("east")) && + Objects.equals(state.getProperties().get("north"), state.getProperties().get("south")) && + Objects.equals(state.getProperties().get("east"), state.getProperties().get("west")) && + !Objects.equals(state.getProperties().get("north"), state.getProperties().get("east")) && !connectsTo(world, pos.add(Direction.UP.toVector())) ) { return state.with("up", "false"); diff --git a/README.md b/README.md index d43e7738..5bc9a4d8 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ command | permission | description *\[clickable command in /bluemap\]* | bluemap.rendertask.remove | removes the clicked render-task ## Todo / planned features -Here is an *(surely incomplete)* list of things that i want to include in future versions. *(They are not in any specific order. There is no guarantee that any of those things will ever be included.)* +Here is a *(surely incomplete)* list of things that i want to include in future versions. *(They are not in any specific order. There is no guarantee that any of those things will ever be included.)* - render tile-entities (chests, etc..) - render entities