Skip to content

Commit 49ddaa7

Browse files
committed
Fix some possible errors if blocks dont contain expected properties
1 parent 1c44bd2 commit 49ddaa7

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoorExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import java.util.Collection;
2828
import java.util.Map.Entry;
29+
import java.util.Objects;
2930

3031
import com.flowpowered.math.vector.Vector3i;
3132
import com.google.common.collect.Lists;
@@ -50,7 +51,7 @@ public class DoorExtension implements BlockStateExtension {
5051
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {
5152
BlockState otherDoor;
5253

53-
boolean isLower = state.getProperties().get("half").equals("lower");
54+
boolean isLower = Objects.equals(state.getProperties().get("half"), "lower");
5455

5556
if (isLower) {
5657
otherDoor = world.getBlockState(pos.add(Direction.UP.toVector()));

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/DoublePlantExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package de.bluecolored.bluemap.core.mca.extensions;
2626

2727
import java.util.Collection;
28+
import java.util.Objects;
2829

2930
import com.flowpowered.math.vector.Vector3i;
3031
import com.google.common.collect.Lists;
@@ -46,7 +47,7 @@ public class DoublePlantExtension implements BlockStateExtension {
4647

4748
@Override
4849
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {
49-
if (state.getProperties().get("half").equals("upper")) {
50+
if (Objects.equals(state.getProperties().get("half"), "upper")) {
5051
BlockState otherPlant = world.getBlockState(pos.add(Direction.DOWN.toVector()));
5152

5253
return otherPlant.with("half", "upper");

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/RedstoneExtension.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,28 @@ public class RedstoneExtension implements BlockStateExtension {
5858

5959
@Override
6060
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {
61+
BlockState up = world.getBlockState(pos.add(0, 1, 0));
62+
boolean upBlocking = !up.equals(BlockState.AIR);
63+
6164
state = state
62-
.with("north", connection(world, pos, state, Direction.NORTH))
63-
.with("east", connection(world, pos, state, Direction.EAST))
64-
.with("south", connection(world, pos, state, Direction.SOUTH))
65-
.with("west", connection(world, pos, state, Direction.WEST));
65+
.with("north", connection(world, pos, upBlocking, Direction.NORTH))
66+
.with("east", connection(world, pos, upBlocking, Direction.EAST))
67+
.with("south", connection(world, pos, upBlocking, Direction.SOUTH))
68+
.with("west", connection(world, pos, upBlocking, Direction.WEST));
6669

6770
return state;
6871
}
6972

70-
private String connection(MCAWorld world, Vector3i pos, BlockState state, Direction direction) {
71-
BlockState next = world.getBlockState(pos.add(direction.toVector()));
73+
private String connection(MCAWorld world, Vector3i pos, boolean upBlocking, Direction direction) {
74+
Vector3i directionVector = direction.toVector();
75+
76+
BlockState next = world.getBlockState(pos.add(directionVector));
7277
if (CONNECTIBLE.contains(next.getFullId())) return "side";
7378

74-
//TODO: up
79+
if (!upBlocking) {
80+
BlockState nextup = world.getBlockState(pos.add(directionVector.getX(), directionVector.getY() + 1, directionVector.getZ()));
81+
if (nextup.getFullId().equals("minecraft:redstone_wire")) return "up";
82+
}
7583

7684
return "none";
7785
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/extensions/WallConnectExtension.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package de.bluecolored.bluemap.core.mca.extensions;
2626

2727
import java.util.HashSet;
28+
import java.util.Objects;
2829
import java.util.Set;
2930

3031
import com.flowpowered.math.vector.Vector3i;
@@ -37,17 +38,18 @@
3738
public class WallConnectExtension extends ConnectSameOrFullBlockExtension {
3839

3940
private static final HashSet<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
40-
"minecraft:cobblestone_wall"
41+
"minecraft:cobblestone_wall",
42+
"minecraft:mossy_cobblestone_wall"
4143
);
4244

4345
@Override
4446
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {
4547
state = super.extend(world, pos, state);
4648

4749
if (
48-
state.getProperties().get("north").equals(state.getProperties().get("south")) &&
49-
state.getProperties().get("east").equals(state.getProperties().get("west")) &&
50-
!state.getProperties().get("north").equals(state.getProperties().get("east")) &&
50+
Objects.equals(state.getProperties().get("north"), state.getProperties().get("south")) &&
51+
Objects.equals(state.getProperties().get("east"), state.getProperties().get("west")) &&
52+
!Objects.equals(state.getProperties().get("north"), state.getProperties().get("east")) &&
5153
!connectsTo(world, pos.add(Direction.UP.toVector()))
5254
) {
5355
return state.with("up", "false");

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ command | permission | description
7575
*\[clickable command in /bluemap\]* | bluemap.rendertask.remove | removes the clicked render-task
7676

7777
## Todo / planned features
78-
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.)*
78+
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.)*
7979

8080
- render tile-entities (chests, etc..)
8181
- render entities

0 commit comments

Comments
 (0)