11package com .cleanroommc .client .util ;
22
33import com .cleanroommc .client .util .world .DummyWorld ;
4+ import hellfirepvp .modularmachinery .ModularMachinery ;
45import net .minecraft .block .state .IBlockState ;
56import net .minecraft .init .Blocks ;
67import net .minecraft .tileentity .TileEntity ;
1112
1213import javax .annotation .Nonnull ;
1314import javax .vecmath .Vector3f ;
15+ import java .lang .reflect .Field ;
1416import java .util .HashSet ;
1517import java .util .Map ;
1618import java .util .Set ;
19+ import java .util .concurrent .atomic .AtomicReference ;
1720import java .util .function .BiFunction ;
1821import java .util .function .Predicate ;
1922
@@ -37,10 +40,26 @@ public class TrackedDummyWorld extends DummyWorld {
3740
3841 public TrackedDummyWorld () {
3942 proxyWorld = null ;
43+ initAlfheimLightingEngine ();
4044 }
4145
4246 public TrackedDummyWorld (World world ) {
4347 proxyWorld = world ;
48+ initAlfheimLightingEngine ();
49+ }
50+
51+ private void initAlfheimLightingEngine () {
52+ try {
53+ Field lightingEngineField = World .class .getDeclaredField ("alfheim$lightingEngine" );
54+ lightingEngineField .setAccessible (true );
55+
56+ if (lightingEngineField .get (this ) == null ) {
57+ lightingEngineField .set (this , new AtomicReference <>());
58+ }
59+ } catch (NoSuchFieldException ignored ) {
60+ } catch (IllegalAccessException e ) {
61+ ModularMachinery .log .error ("Failed to initialize Alfheim lighting engine: " , e );
62+ }
4463 }
4564
4665 public void setRenderFilter (Predicate <BlockPos > renderFilter ) {
@@ -122,4 +141,4 @@ public Vector3f getMinPos() {
122141 public Vector3f getMaxPos () {
123142 return maxPos ;
124143 }
125- }
144+ }
0 commit comments