mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +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
56fd2e0a63
commit
3415ba97ac
2 changed files with 15 additions and 3 deletions
|
@ -12,6 +12,7 @@ import net.minecraftforge.fml.ModList;
|
||||||
*/
|
*/
|
||||||
public enum Mods {
|
public enum Mods {
|
||||||
DYNAMICTREES,
|
DYNAMICTREES,
|
||||||
|
STARLIGHT,
|
||||||
TCONSTRUCT;
|
TCONSTRUCT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,4 +39,14 @@ public enum Mods {
|
||||||
return Optional.of(toRun.get().get());
|
return Optional.of(toRun.get().get());
|
||||||
return Optional.empty();
|
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 ca.spottedleaf.starlight.common.light.StarLightEngine;
|
||||||
|
|
||||||
|
import com.simibubi.create.compat.Mods;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
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.level.material.FluidState;
|
||||||
import net.minecraft.world.ticks.BlackholeTickAccess;
|
import net.minecraft.world.ticks.BlackholeTickAccess;
|
||||||
import net.minecraft.world.ticks.TickContainerAccess;
|
import net.minecraft.world.ticks.TickContainerAccess;
|
||||||
import net.minecraftforge.fml.ModList;
|
|
||||||
|
|
||||||
public class WrappedChunk extends ChunkAccess {
|
public class WrappedChunk extends ChunkAccess {
|
||||||
|
|
||||||
|
@ -61,11 +61,12 @@ public class WrappedChunk extends ChunkAccess {
|
||||||
for (int i = 0; i < this.sections.length; i++) {
|
for (int i = 0; i < this.sections.length; i++) {
|
||||||
sections[i] = new WrappedChunkSection(this, i << 4);
|
sections[i] = new WrappedChunkSection(this, i << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Starlight is loaded, initialize its NibbleArrays for this chunk to default values
|
// 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).setBlockNibbles(StarLightEngine.getFilledEmptyLight(this));
|
||||||
((ExtendedChunk)this).setSkyNibbles(StarLightEngine.getFilledEmptyLight(this));
|
((ExtendedChunk)this).setSkyNibbles(StarLightEngine.getFilledEmptyLight(this));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue