Skip to content

Commit

Permalink
Mysterious Cube and Quartz Glass fixes for FramedBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Jan 31, 2025
1 parent 163276d commit b8b8ba6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
34 changes: 22 additions & 12 deletions src/main/java/appeng/client/render/model/GlassBakedModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import appeng.decorative.solid.GlassState;
import appeng.decorative.solid.QuartzGlassBlock;

class GlassBakedModel implements IDynamicBakedModel {
public class GlassBakedModel implements IDynamicBakedModel {
private static final ChunkRenderTypeSet RENDER_TYPES = ChunkRenderTypeSet.of(RenderType.CUTOUT);

// This unlisted property is used to determine the actual block that should be
Expand Down Expand Up @@ -178,16 +178,16 @@ private static int makeBitmask(BlockAndTintGetter level, BlockState state, Block

int bitmask = 0;

if (!isGlassBlock(level, state, pos, face, up)) {
if (!isGlassBlock(level, state, pos, face, up, face)) {
bitmask |= 1;
}
if (!isGlassBlock(level, state, pos, face, right)) {
if (!isGlassBlock(level, state, pos, face, right, face)) {
bitmask |= 2;
}
if (!isGlassBlock(level, state, pos, face, down)) {
if (!isGlassBlock(level, state, pos, face, down, face)) {
bitmask |= 4;
}
if (!isGlassBlock(level, state, pos, face, left)) {
if (!isGlassBlock(level, state, pos, face, left, face)) {
bitmask |= 8;
}
return bitmask;
Expand Down Expand Up @@ -275,22 +275,32 @@ private static GlassState getGlassState(BlockAndTintGetter level, BlockState sta
}
boolean[] adjacentGlassBlocks = new boolean[6];
for (Direction facing : Direction.values()) {
adjacentGlassBlocks[facing.get3DDataValue()] = isGlassBlock(level, state, pos, facing.getOpposite(),
facing);
adjacentGlassBlocks[facing.get3DDataValue()] = isGlassBlock(level, state, pos, facing,
facing, facing.getOpposite());
}
return new GlassState(masks, adjacentGlassBlocks);
}

/**
* Checks if the given block is a glass block.
*
* @param face Face of the glass that we are currently checking for.
* @param adjDir Direction in which to check.
* @param queryingFace Face of the glass that is currently performing the check.
* @param adjFace Face of the glass that we are currently checking for.
* @param adjDir Direction in which to check.
*/
private static boolean isGlassBlock(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction face,
Direction adjDir) {
private static boolean isGlassBlock(BlockAndTintGetter level, BlockState state, BlockPos pos,
Direction queryingFace, Direction adjDir, Direction adjFace) {
var adjacentPos = pos.relative(adjDir);
return level.getBlockState(adjacentPos).getAppearance(level, adjacentPos, face, state, pos)
var adjacentState = level.getBlockState(adjacentPos);
// Checks that the adjacent block is indeed glass
if (!(adjacentState.getAppearance(level, adjacentPos, adjFace, state, pos)
.getBlock() instanceof QuartzGlassBlock)) {
return false;
}
// Checks that the current block is also glass, in other words that the adjacent block would connect to us.
// This ensures consistency between this block and the adjacent block deciding to connect or not.
// This is important for advanced use cases such as FramedBlocks.
return state.getAppearance(level, pos, queryingFace, adjacentState, adjacentPos)
.getBlock() instanceof QuartzGlassBlock;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/appeng/core/AppEngClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import appeng.client.render.effects.MatterCannonFX;
import appeng.client.render.effects.ParticleTypes;
import appeng.client.render.effects.VibrantFX;
import appeng.client.render.model.GlassBakedModel;
import appeng.client.render.overlay.OverlayManager;
import appeng.client.render.tesr.ChargerBlockEntityRenderer;
import appeng.client.render.tesr.ChestBlockEntityRenderer;
Expand Down Expand Up @@ -201,6 +202,7 @@ public AppEngClient(IEventBus modEventBus, ModContainer container) {
private void enqueueImcMessages(InterModEnqueueEvent event) {
// Our new light-mode UI doesn't play nice with darkmodeeverywhere
InterModComms.sendTo("darkmodeeverywhere", "dme-shaderblacklist", () -> "appeng.");
InterModComms.sendTo("framedblocks", "add_ct_property", () -> GlassBakedModel.GLASS_STATE);
}

private void registerDimensionSpecialEffects(RegisterDimensionSpecialEffectsEvent event) {
Expand Down
38 changes: 30 additions & 8 deletions src/main/resources/assets/ae2/models/block/mysterious_cube.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
"render_type": "cutout",
"elements": [
{
"from": [0.01, 0.01, 0.01],
"to": [15.99, 15.99, 15.99],
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": { "uv": [0, 0, 16, 16], "texture": "#core" },
"east": { "uv": [0, 0, 16, 16], "texture": "#core" },
"south": { "uv": [0, 0, 16, 16], "texture": "#core" },
"west": { "uv": [0, 0, 16, 16], "texture": "#core" },
"up": { "uv": [16, 0, 0, 16], "texture": "#core" },
"down": { "uv": [16, 0, 0, 16], "texture": "#core" }
"north": {
"uv": [0, 0, 16, 16],
"texture": "#core",
"cullface": "north"
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#core",
"cullface": "east"
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#core",
"cullface": "south"
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#core",
"cullface": "west"
},
"up": { "uv": [16, 0, 0, 16], "texture": "#core", "cullface": "up" },
"down": { "uv": [16, 0, 0, 16], "texture": "#core", "cullface": "down" }
}
},
{
Expand All @@ -28,31 +44,37 @@
"north": {
"uv": [0, 0, 16, 16],
"texture": "#side",
"cullface": "north",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#side",
"cullface": "east",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#side",
"cullface": "south",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#side",
"cullface": "west",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
},
"up": {
"uv": [16, 0, 0, 16],
"texture": "#top",
"cullface": "up",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
},
"down": {
"uv": [16, 0, 0, 16],
"texture": "#bottom",
"cullface": "down",
"neoforge_data": { "block_light": 15, "sky_light": 15 }
}
}
Expand Down

0 comments on commit b8b8ba6

Please sign in to comment.