Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve controller textures #8158

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/main/java/appeng/block/networking/ControllerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getSerializedName() {
* have the usual sub-states.
*/
public enum ControllerRenderType implements StringRepresentable {
block, column_x, column_y, column_z, inside_a, inside_b;
block_a, block_b, column_x_a, column_x_b, column_y_a, column_y_b, column_z_a, column_z_b, inside_a, inside_b;

@Override
public String getSerializedName() {
Expand All @@ -77,7 +77,7 @@ public String getSerializedName() {
public ControllerBlock() {
super(metalProps().strength(6));
this.registerDefaultState(this.defaultBlockState().setValue(CONTROLLER_STATE, ControllerBlockState.offline)
.setValue(CONTROLLER_TYPE, ControllerRenderType.block));
.setValue(CONTROLLER_TYPE, ControllerRenderType.block_a)); // TODO this could be block_b theoretically
}

@Override
Expand Down Expand Up @@ -107,7 +107,7 @@ public BlockState updateShape(BlockState state, Direction facing, BlockState fac

private BlockState getControllerType(BlockState baseState, LevelAccessor level, BlockPos pos) {
// Only used for columns, really
ControllerRenderType type = ControllerRenderType.block;
ControllerRenderType type = ControllerRenderType.block_a;

int x = pos.getX();
int y = pos.getY();
Expand All @@ -118,22 +118,40 @@ private BlockState getControllerType(BlockState baseState, LevelAccessor level,
final boolean yy = isController(level, x, y - 1, z) && isController(level, x, y + 1, z);
final boolean zz = isController(level, x, y, z - 1) && isController(level, x, y, z + 1);

// While i'd like this to be based on the blockstate randomization feature, this
// generates an alternating pattern based on level position, so this is not 100% doable with blockstates.
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;

if (xx && !yy && !zz) {
type = ControllerRenderType.column_x;
if (v == 0) {
type = ControllerRenderType.column_x_a;
} else {
type = ControllerRenderType.column_x_b;
}
} else if (!xx && yy && !zz) {
type = ControllerRenderType.column_y;
if (v == 0) {
type = ControllerRenderType.column_y_a;
} else {
type = ControllerRenderType.column_y_b;
}
} else if (!xx && !yy && zz) {
type = ControllerRenderType.column_z;
if (v == 0) {
type = ControllerRenderType.column_z_a;
} else {
type = ControllerRenderType.column_z_b;
}
} else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) {
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;

// While i'd like this to be based on the blockstate randomization feature, this
// generates an alternating pattern based on level position, so this is not 100% doable with blockstates.
if (v == 0) {
type = ControllerRenderType.inside_a;
} else {
type = ControllerRenderType.inside_b;
}
} else {
if (v == 0) {
type = ControllerRenderType.block_a;
} else {
type = ControllerRenderType.block_b;
}
}

return baseState.setValue(CONTROLLER_TYPE, type);
Expand Down
165 changes: 141 additions & 24 deletions src/main/resources/assets/ae2/blockstates/controller.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,119 +2,236 @@
"multipart": [
{
"apply": {
"model": "ae2:block/controller/controller_block_offline"
"model": "ae2:block/controller/controller_block_offline_a"
},
"when": {
"state": "offline",
"type": "block"
"type": "block_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_block_online"
"model": "ae2:block/controller/controller_block_offline_b"
},
"when": {
"state": "offline",
"type": "block_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_block_online_a"
},
"when": {
"state": "online",
"type": "block_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_block_online_b"
},
"when": {
"state": "online",
"type": "block"
"type": "block_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_block_conflicted_a"
},
"when": {
"state": "conflicted",
"type": "block_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_block_conflicted"
"model": "ae2:block/controller/controller_block_conflicted_b"
},
"when": {
"state": "conflicted",
"type": "block"
"type": "block_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_offline",
"model": "ae2:block/controller/controller_column_offline_a",
"x": 90,
"y": 90
},
"when": {
"state": "offline",
"type": "column_x"
"type": "column_x_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_offline"
"model": "ae2:block/controller/controller_column_offline_a"
},
"when": {
"state": "offline",
"type": "column_y"
"type": "column_y_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_offline",
"model": "ae2:block/controller/controller_column_offline_a",
"x": 90
},
"when": {
"state": "offline",
"type": "column_z"
"type": "column_z_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online",
"model": "ae2:block/controller/controller_column_offline_b",
"x": 90,
"y": 90
},
"when": {
"state": "offline",
"type": "column_x_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_offline_b"
},
"when": {
"state": "offline",
"type": "column_y_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_offline_b",
"x": 90
},
"when": {
"state": "offline",
"type": "column_z_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online_a",
"x": 90,
"y": 90
},
"when": {
"state": "online",
"type": "column_x"
"type": "column_x_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online"
"model": "ae2:block/controller/controller_column_online_a"
},
"when": {
"state": "online",
"type": "column_y"
"type": "column_y_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online",
"model": "ae2:block/controller/controller_column_online_a",
"x": 90
},
"when": {
"state": "online",
"type": "column_z"
"type": "column_z_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online_b",
"x": 90,
"y": 90
},
"when": {
"state": "online",
"type": "column_x_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online_b"
},
"when": {
"state": "online",
"type": "column_y_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_online_b",
"x": 90
},
"when": {
"state": "online",
"type": "column_z_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted_a",
"x": 90,
"y": 90
},
"when": {
"state": "conflicted",
"type": "column_x_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted_a"
},
"when": {
"state": "conflicted",
"type": "column_y_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted_a",
"x": 90
},
"when": {
"state": "conflicted",
"type": "column_z_a"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted",
"model": "ae2:block/controller/controller_column_conflicted_b",
"x": 90,
"y": 90
},
"when": {
"state": "conflicted",
"type": "column_x"
"type": "column_x_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted"
"model": "ae2:block/controller/controller_column_conflicted_b"
},
"when": {
"state": "conflicted",
"type": "column_y"
"type": "column_y_b"
}
},
{
"apply": {
"model": "ae2:block/controller/controller_column_conflicted",
"model": "ae2:block/controller/controller_column_conflicted_b",
"x": 90
},
"when": {
"state": "conflicted",
"type": "column_z"
"type": "column_z_b"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "ae2:block/controller/controller_block_lights",
"textures": {
"block": "ae2:block/controller_powered",
"lights": "ae2:block/controller_conflict_a"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "ae2:block/controller/controller_block_lights",
"textures": {
"block": "ae2:block/controller_powered",
"lights": "ae2:block/controller_conflict_b"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "ae2:block/controller"
"all": "ae2:block/controller_a"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "ae2:block/controller_b"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"parent": "ae2:block/controller/controller_block_lights",
"textures": {
"block": "ae2:block/controller_powered",
"lights": "ae2:block/controller_conflict"
"lights": "ae2:block/controller_lights_a"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"parent": "ae2:block/controller/controller_block_lights",
"textures": {
"block": "ae2:block/controller_powered",
"lights": "ae2:block/controller_lights"
"lights": "ae2:block/controller_lights_b"
}
}
Loading