Update code style

This commit is contained in:
MichaelPriebe 2020-12-17 01:16:24 -05:00
parent 917c4ddfd6
commit 881ed5deca
2 changed files with 48 additions and 51 deletions

View File

@ -25,73 +25,80 @@ public class RedstonePlacementRule extends BlockPlacementRule {
public short blockRefresh(@NotNull Instance instance, @NotNull BlockPosition blockPosition, short currentId) { public short blockRefresh(@NotNull Instance instance, @NotNull BlockPosition blockPosition, short currentId) {
BlockUtils block = new BlockUtils(instance, blockPosition); BlockUtils block = new BlockUtils(instance, blockPosition);
String pEast = "none"; String east = "none";
String pNorth = "none"; String north = "none";
String power = "0"; String power = "0";
String pSouth = "none"; String south = "none";
String pWest = "none"; String west = "none";
// TODO Block should have method isRedstone, as redstone connects to more than itself.
final BlockUtils blockNorth = block.north();
final BlockUtils blockSouth = block.south();
final BlockUtils blockEast = block.east();
final BlockUtils blockWest = block.west();
int connected = 0; int connected = 0;
BlockUtils north = block.north(); if (blockNorth.equals(Block.REDSTONE_WIRE) || blockNorth.below().equals(Block.REDSTONE_WIRE)) {
BlockUtils south = block.south();
BlockUtils east = block.east();
BlockUtils west = block.west();
// TODO: Block should have method isRedstone, as redstone connects to more than itself.
if (north.equals(Block.REDSTONE_WIRE) || north.below().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pNorth = "side"; north = "side";
} }
if (south.equals(Block.REDSTONE_WIRE) || south.below().equals(Block.REDSTONE_WIRE)) { if (blockSouth.equals(Block.REDSTONE_WIRE) || blockSouth.below().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pSouth = "side"; south = "side";
} }
if (east.equals(Block.REDSTONE_WIRE) || east.below().equals(Block.REDSTONE_WIRE)) { if (blockEast.equals(Block.REDSTONE_WIRE) || blockEast.below().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pEast = "side"; east = "side";
} }
if (west.equals(Block.REDSTONE_WIRE) || west.below().equals(Block.REDSTONE_WIRE)) { if (blockWest.equals(Block.REDSTONE_WIRE) || blockWest.below().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pWest = "side"; west = "side";
} }
if (north.above().equals(Block.REDSTONE_WIRE)) { if (blockNorth.above().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pNorth = "up"; north = "up";
} }
if (east.above().equals(Block.REDSTONE_WIRE)) { if (blockSouth.above().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pEast = "up"; south = "up";
} }
if (south.above().equals(Block.REDSTONE_WIRE)) { if (blockEast.above().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pSouth = "up"; east = "up";
} }
if (west.above().equals(Block.REDSTONE_WIRE)) { if (blockWest.above().equals(Block.REDSTONE_WIRE)) {
connected++; connected++;
pWest = "up"; west = "up";
} }
if (connected == 0) { if (connected == 0) {
pNorth = "side"; north = "side";
pEast = "side"; south = "side";
pSouth = "side"; east = "side";
pWest = "side"; west = "side";
} else if (connected == 1) { } else if (connected == 1) {
if (!pNorth.equals("none")) pSouth = "side"; if (!north.equals("none")) {
if (!pSouth.equals("none")) pNorth = "side"; south = "side";
if (!pEast.equals("none")) pWest = "side"; }
if (!pWest.equals("none")) pEast = "side"; if (!south.equals("none")) {
north = "side";
}
if (!east.equals("none")) {
west = "side";
}
if (!west.equals("none")) {
east = "side";
}
} }
// TODO power // TODO power
final String[] properties = { final String[] properties = {
"east=" + pEast, "east=" + east,
"north=" + pNorth, "north=" + north,
"power=" + power, "power=" + power,
"south=" + pSouth, "south=" + south,
"west=" + pWest}; "west=" + west};
return Block.REDSTONE_WIRE.withProperties(properties); return Block.REDSTONE_WIRE.withProperties(properties);
} }
@ -101,14 +108,4 @@ public class RedstonePlacementRule extends BlockPlacementRule {
return getBlockId(); return getBlockId();
} }
private boolean isRedstone(Instance instance, int x, int y, int z) {
final short blockStateId = instance.getBlockStateId(x, y, z);
return Block.fromStateId(blockStateId) == Block.REDSTONE_WIRE;
}
private boolean isAir(Instance instance, int x, int y, int z) {
final short blockStateId = instance.getBlockStateId(x, y, z);
return Block.fromStateId(blockStateId) == Block.AIR;
}
} }

View File

@ -28,7 +28,7 @@ public class BlockUtils {
} }
public BlockUtils north() { public BlockUtils north() {
return getRelativeTo(0, 0 , -1); return getRelativeTo(0, 0, -1);
} }
public BlockUtils east() { public BlockUtils east() {
@ -40,7 +40,7 @@ public class BlockUtils {
} }
public BlockUtils west() { public BlockUtils west() {
return getRelativeTo(-1, 0 , 0); return getRelativeTo(-1, 0, 0);
} }
public Block getBlock() { public Block getBlock() {