Skip to content

Commit eada008

Browse files
committed
Merge PR #3389 by @pollend - block family rotation fix
2 parents c42e530 + e792579 commit eada008

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

engine/src/main/java/org/terasology/world/block/family/AbstractBlockFamily.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public boolean hasCategory(String category) {
7272

7373
@Override
7474
public String toString() {
75-
return "BlockFamily[" + uri.toString() + "]";
75+
String familyType = "";
76+
RegisterBlockFamily registerInfo = this.getClass().getAnnotation(RegisterBlockFamily.class);
77+
if (registerInfo != null) {
78+
familyType = registerInfo.value();
79+
}
80+
return "BlockFamily[" + familyType + "," + uri.toString() + "]";
7681
}
7782
}

engine/src/main/java/org/terasology/world/block/family/FreeformFamily.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FreeformFamily extends AbstractBlockFamily {
4141
private static final Logger logger = LoggerFactory.getLogger(FreeformFamily.class);
4242

4343
private Map<Side, Block> blocks = Maps.newEnumMap(Side.class);
44-
private Block block;
44+
private Block archetypeBlock;
4545

4646
public FreeformFamily(BlockFamilyDefinition definition, BlockShape shape, BlockBuilderHelper blockBuilder) {
4747
super(definition, shape, blockBuilder);
@@ -52,11 +52,11 @@ public FreeformFamily(BlockFamilyDefinition definition, BlockShape shape, BlockB
5252
uri = new BlockUri(definition.getUrn(), shape.getUrn());
5353
}
5454
if (shape.isCollisionYawSymmetric()) {
55-
block = blockBuilder.constructSimpleBlock(definition, shape, uri, this);
55+
archetypeBlock = blockBuilder.constructSimpleBlock(definition, shape, uri, this);
5656
} else {
5757
for (Rotation rot : Rotation.horizontalRotations()) {
5858
Side side = rot.rotate(Side.FRONT);
59-
block = blockBuilder.constructTransformedBlock(definition, shape, side.toString().toLowerCase(Locale.ENGLISH), rot,
59+
Block block = blockBuilder.constructTransformedBlock(definition, shape, side.toString().toLowerCase(Locale.ENGLISH), rot,
6060
new BlockUri(uri, new Name(side.name())), this);
6161
if (block == null) {
6262
throw new IllegalArgumentException("Missing block for side: " + side.toString());
@@ -76,7 +76,7 @@ public FreeformFamily(BlockFamilyDefinition blockFamilyDefinition, BlockBuilderH
7676

7777
@Override
7878
public Block getBlockForPlacement(Vector3i location, Side attachmentSide, Side direction) {
79-
if (block == null) {
79+
if (archetypeBlock == null) {
8080
if (attachmentSide.isHorizontal()) {
8181
return blocks.get(attachmentSide);
8282
}
@@ -86,15 +86,15 @@ public Block getBlockForPlacement(Vector3i location, Side attachmentSide, Side d
8686
return blocks.get(Side.FRONT);
8787
}
8888
}
89-
return block;
89+
return archetypeBlock;
9090
}
9191

9292
@Override
9393
public Block getArchetypeBlock() {
94-
if (block == null) {
94+
if (archetypeBlock == null) {
9595
return blocks.get(this.getArchetypeSide());
9696
}
97-
return block;
97+
return archetypeBlock;
9898
}
9999

100100
protected Side getArchetypeSide() {
@@ -103,7 +103,7 @@ protected Side getArchetypeSide() {
103103

104104
@Override
105105
public Block getBlockFor(BlockUri blockUri) {
106-
if (block == null && getURI().equals(blockUri.getFamilyUri())) {
106+
if (archetypeBlock == null && getURI().equals(blockUri.getFamilyUri())) {
107107
try {
108108
Side side = Side.valueOf(blockUri.getIdentifier().toString().toUpperCase(Locale.ENGLISH));
109109
return blocks.get(side);
@@ -113,15 +113,15 @@ public Block getBlockFor(BlockUri blockUri) {
113113
}
114114

115115
}
116-
return block;
116+
return archetypeBlock;
117117
}
118118

119119
@Override
120120
public Iterable<Block> getBlocks() {
121-
if (block == null) {
121+
if (archetypeBlock == null) {
122122
return blocks.values();
123123
}
124-
return Arrays.asList(block);
124+
return Arrays.asList(archetypeBlock);
125125
}
126126

127127
}

0 commit comments

Comments
 (0)