9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

修复1.20-1.21.1光照

This commit is contained in:
XiaoMoMi
2025-07-01 04:51:01 +08:00
parent ab9f4d4596
commit d36a55f747
2 changed files with 8 additions and 1 deletions

View File

@@ -130,8 +130,8 @@ public final class BukkitCustomBlock extends AbstractCustomBlock {
CoreReflections.field$BlockBehaviour$explosionResistance.set(nmsBlock, settings.resistance());
CoreReflections.field$BlockBehaviour$soundType.set(nmsBlock, SoundUtils.toSoundType(settings.sounds()));
// 1.21.2以前要在init cache之前设定 isConditionallyFullOpaque
boolean isConditionallyFullOpaque = canOcclude & useShapeForLightOcclusion;
if (!VersionHelper.isOrAbove1_21_2()) {
boolean isConditionallyFullOpaque = canOcclude & useShapeForLightOcclusion;
CoreReflections.field$BlockStateBase$isConditionallyFullOpaque.set(nmsState, isConditionallyFullOpaque);
}
// init cache
@@ -162,6 +162,9 @@ public final class BukkitCustomBlock extends AbstractCustomBlock {
} else {
CoreReflections.field$BlockStateBase$Cache$propagatesSkylightDown.set(cache, CoreReflections.field$BlockStateBase$Cache$propagatesSkylightDown.getBoolean(CoreReflections.field$BlockStateBase$cache.get(immutableBlockState.vanillaBlockState().handle())));
}
if (!isConditionallyFullOpaque) {
CoreReflections.field$BlockStateBase$opacityIfCached.set(nmsState, blockLight);
}
}
// set fluid later
if (settings.fluidState()) {

View File

@@ -1328,6 +1328,10 @@ public final class CoreReflections {
public static final Field field$BlockStateBase$lightBlock =
ReflectionUtils.getInstanceDeclaredField(clazz$BlockStateBase, int.class, 1);
// 1.20-1.21.1
public static final Field field$BlockStateBase$opacityIfCached =
ReflectionUtils.getInstanceDeclaredField(clazz$BlockStateBase, int.class, 1);
public static final Class<?> clazz$AABB = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"world.phys.AxisAlignedBB",