Fix some possible errors if blocks dont contain expected properties

This commit is contained in:
Blue (Lukas Rieger) 2020-01-07 14:27:48 +01:00
parent 1c44bd2ac4
commit 49ddaa7c81
5 changed files with 26 additions and 14 deletions

View File

@ -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()));

View File

@ -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");

View File

@ -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";
}

View File

@ -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<String> 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");

View File

@ -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