diff --git a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java index 195d76386..f275c7816 100644 --- a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java +++ b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java @@ -127,7 +127,7 @@ public FakeLevel(final IFakeLevelBlockGetter levelSource, @Nullable final Scoreboard scoreboard, final boolean overrideBeLevel) { - super(new FakeLevelData(clientLevel().getLevelData(), lightProvider), + super(new FakeLevelData(clientLevel()::getLevelData, lightProvider), clientLevel().dimension(), clientLevel().registryAccess(), clientLevel().dimensionTypeRegistration(), @@ -145,6 +145,7 @@ public FakeLevel(final IFakeLevelBlockGetter levelSource, this.lightEngine = new FakeLevelLightEngine(this); setRealLevel(clientLevel()); + ((FakeLevelData) getLevelData()).vanillaLevelData = realLevel()::getLevelData; } // ======================================== @@ -170,7 +171,6 @@ public void setRealLevel(final Level realLevel) } this.realLevel = realLevel; - ((FakeLevelData) this.getLevelData()).vanillaLevelData = realLevel == null ? null : realLevel.getLevelData(); } public Level realLevel() diff --git a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelData.java b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelData.java index b99e7a8c3..6b8a37055 100644 --- a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelData.java +++ b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelData.java @@ -4,16 +4,17 @@ import net.minecraft.world.level.GameRules; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.WritableLevelData; +import java.util.function.Supplier; /** * Porting: class is relatively small, just check super class manually (all of missing methods are/were just aliases) */ public class FakeLevelData implements WritableLevelData { - protected LevelData vanillaLevelData; + protected Supplier vanillaLevelData; protected final IFakeLevelLightProvider lightProvider; - protected FakeLevelData(final LevelData vanillaLevelData, final IFakeLevelLightProvider lightProvider) + protected FakeLevelData(final Supplier vanillaLevelData, final IFakeLevelLightProvider lightProvider) { this.vanillaLevelData = vanillaLevelData; this.lightProvider = lightProvider; @@ -46,13 +47,13 @@ public float getSpawnAngle() @Override public long getGameTime() { - return vanillaLevelData.getGameTime(); + return vanillaLevelData.get().getGameTime(); } @Override public long getDayTime() { - return lightProvider.forceOwnLightLevel() ? lightProvider.getDayTime() : vanillaLevelData.getDayTime(); + return lightProvider.forceOwnLightLevel() ? lightProvider.getDayTime() : vanillaLevelData.get().getDayTime(); } @Override @@ -82,7 +83,7 @@ public boolean isHardcore() @Override public GameRules getGameRules() { - return vanillaLevelData.getGameRules(); + return vanillaLevelData.get().getGameRules(); } @Override