mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Add Starlight to Mods enum, along with an executeIfInstalled method. Use said method in WrappedChunk in place of an if-statement to execute Starlight-dependent code
This commit is contained in:
parent
11e6c3f45a
commit
7fd531199c
2 changed files with 15 additions and 3 deletions
|
@ -12,6 +12,7 @@ import net.minecraftforge.fml.ModList;
|
|||
*/
|
||||
public enum Mods {
|
||||
DYNAMICTREES,
|
||||
STARLIGHT,
|
||||
TCONSTRUCT;
|
||||
|
||||
/**
|
||||
|
@ -38,4 +39,14 @@ public enum Mods {
|
|||
return Optional.of(toRun.get().get());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple hook to execute code if a mod is installed
|
||||
* @param toExecute will be executed only if the mod is loaded
|
||||
*/
|
||||
public void executeIfInstalled(Supplier<Runnable> toExecute) {
|
||||
if (isLoaded()) {
|
||||
toExecute.get().run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import ca.spottedleaf.starlight.common.chunk.ExtendedChunk;
|
|||
|
||||
import ca.spottedleaf.starlight.common.light.StarLightEngine;
|
||||
|
||||
import com.simibubi.create.compat.Mods;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
|
@ -34,7 +35,6 @@ import net.minecraft.world.level.material.Fluid;
|
|||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.ticks.BlackholeTickAccess;
|
||||
import net.minecraft.world.ticks.TickContainerAccess;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public class WrappedChunk extends ChunkAccess {
|
||||
|
||||
|
@ -61,11 +61,12 @@ public class WrappedChunk extends ChunkAccess {
|
|||
for (int i = 0; i < this.sections.length; i++) {
|
||||
sections[i] = new WrappedChunkSection(this, i << 4);
|
||||
}
|
||||
|
||||
// If Starlight is loaded, initialize its NibbleArrays for this chunk to default values
|
||||
if (ModList.get().isLoaded("starlight")) {
|
||||
Mods.STARLIGHT.executeIfInstalled(() -> () -> {
|
||||
((ExtendedChunk)this).setBlockNibbles(StarLightEngine.getFilledEmptyLight(this));
|
||||
((ExtendedChunk)this).setSkyNibbles(StarLightEngine.getFilledEmptyLight(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue