Skip to content

Commit 208a21c

Browse files
committed
base emissive support
1 parent 0eb618d commit 208a21c

3 files changed

Lines changed: 57 additions & 8 deletions

File tree

src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ private ModelBakeResultUpload processTextureBakeResult(int blockId, BlockState b
582582
boolean canBeCorrectlyRendered = true;//This represents if a model can be correctly (perfectly) represented
583583
// i.e. no gaps
584584

585+
//block emission
586+
metadata |= ((long)getBlockLightEmission(blockState))<<(48+7);
587+
585588
this.metadataCache[modelId] = metadata;
586589

587590
uploadPtr += 4*6;
@@ -652,6 +655,39 @@ private ModelBakeResultUpload processTextureBakeResult(int blockId, BlockState b
652655
return uploadResult;
653656
}
654657

658+
private static int getBlockLightEmission(BlockState state) {
659+
boolean isEmissive = state.emissiveRendering(new BlockGetter() {
660+
@Override
661+
public @org.jspecify.annotations.Nullable BlockEntity getBlockEntity(BlockPos pos) {
662+
return null;
663+
}
664+
665+
@Override
666+
public BlockState getBlockState(BlockPos pos) {
667+
return state;
668+
}
669+
670+
@Override
671+
public FluidState getFluidState(BlockPos pos) {
672+
return state.getFluidState();
673+
}
674+
675+
@Override
676+
public int getHeight() {
677+
return 0;
678+
}
679+
680+
@Override
681+
public int getMinY() {
682+
return 0;
683+
}
684+
}, BlockPos.ZERO);
685+
if (isEmissive) {
686+
return 15;//full bright
687+
}
688+
return state.getLightEmission();
689+
}
690+
655691
private static final class BiomeUploadResult implements ResultUploader {
656692
private final MemoryBuffer biomeColourBuffer;
657693
private final MemoryBuffer modelBiomeIndexPairs;

src/main/java/me/cortex/voxy/client/core/model/ModelQueries.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@ public static boolean isDoubleSided(long metadata) {
2222
}
2323

2424
public static long _isDoubleSided(long metadata) {
25-
return ((metadata>>(8*6+2))&1);
25+
return ((metadata>>(8*6+2))&1L);
2626
}
2727

2828
public static boolean isTranslucent(long metadata) {
2929
return ((metadata>>(8*6))&2) != 0;
3030
}
3131

3232
public static long _isTranslucent(long metadata) {
33-
return ((metadata>>(8*6+1))&1);
33+
return ((metadata>>(8*6+1))&1L);
3434
}
3535

3636
public static boolean containsFluid(long metadata) {
3737
return ((metadata>>(8*6))&8) != 0;
3838
}
3939

4040
public static long _containsFluid(long metadata) {
41-
return ((metadata>>(8*6+3))&1);
41+
return ((metadata>>(8*6+3))&1L);
4242
}
4343

4444
public static boolean isFluid(long metadata) {
4545
return ((metadata>>(8*6))&16) != 0;
4646
}
4747

4848
public static long _isFluid(long metadata) {
49-
return ((metadata>>(8*6+4))&1);
49+
return ((metadata>>(8*6+4))&1L);
5050
}
5151

5252
public static boolean isBiomeColoured(long metadata) {
53-
return ((metadata>>(8*6))&1) != 0;
53+
return ((metadata>>(8*6))&1L) != 0;
5454
}
5555

5656
public static long _isBiomeColoured(long metadata) {
57-
return ((metadata>>(8*6))&1);
57+
return ((metadata>>(8*6))&1L);
5858
}
5959

6060
public static long _notIsBiomeColoured(long metadata) {
61-
return (((~metadata)>>(8*6))&1);
61+
return (((~metadata)>>(8*6))&1L);
6262
}
6363

6464
//NOTE: this might need to be moved to per face
@@ -71,6 +71,10 @@ public static boolean isFullyOpaque(long metadata) {
7171
}
7272

7373
public static long _isFullyOpaque(long metadata) {
74-
return ((metadata>>(8*6+6))&1);
74+
return ((metadata>>(8*6+6))&1L);
75+
}
76+
77+
public static long lightEmission(long meta) {
78+
return (meta>>(8*6+7))&0xFL;
7579
}
7680
}

src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,15 @@ private static void meshNonOpaqueFace(int face, long quad, long meta, long neigh
370370
}
371371
}
372372

373+
private static long getQuadLight(long quad, long selfmeta) {
374+
final long BLMSK = 0xFL<<(55+4);//block light mask
375+
long bl = quad&BLMSK;
376+
bl = Math.max(bl, ModelQueries.lightEmission(selfmeta)<<(55+4));
377+
quad &= ~(BLMSK);
378+
quad |= bl;
379+
return quad;
380+
}
381+
373382
private void generateYZOpaqueInnerGeometry(int axis) {
374383
for (int layer = 0; layer < 31; layer++) {
375384
this.blockMesher.auxiliaryPosition = layer;

0 commit comments

Comments
 (0)