Skip to content

Commit

Permalink
fix compat with radon by adding a config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticpasta1 committed Jul 31, 2023
1 parent b7347fe commit 3759413
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 15 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ dependencies {
implementation fg.deobf("curse.maven:spark-361579:4057111")
implementation fg.deobf("curse.maven:artifacts-forge-312353:${artifacts_version}")
implementation fg.deobf("curse.maven:expandability-forge-465066:${expandability_version}")
//implementation fg.deobf("curse.maven:ctov_forge-623908:4601067")
//implementation fg.deobf("curse.maven:alt_current-548115:4406066")
implementation fg.deobf("curse.maven:radon-forge-596879:3822783")

implementation fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
implementation fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mystic/atlantis/Atlantis.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mystic.atlantis;

import com.mystic.atlantis.entities.blockbenchentities.*;
import net.minecraftforge.fml.ModLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -96,6 +97,10 @@ public static ResourceKey<Level> getOverworldKey() {
return ResourceKey.create(Registry.DIMENSION_REGISTRY, OVERWORLD_ID);
}

public static boolean ifRadon() {
return ModList.get().isLoaded("phospher");
}

public void onInitialize(IEventBus bus) {
GeckoLib.initialize();
GeckoLibMod.DISABLE_IN_DEV = true;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/mystic/atlantis/config/AtlantisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class AtlantisConfig implements ConfigData {
public ForgeConfigSpec.BooleanValue turnOnDimensionalHaste;
public ForgeConfigSpec.DoubleValue waterVisibility;
public ForgeConfigSpec.BooleanValue shouldCitiesGenerate;
public ForgeConfigSpec.BooleanValue shouldHavePerBiomeLighting;



Expand All @@ -47,5 +48,6 @@ private AtlantisConfig(ForgeConfigSpec.Builder builder) {
this.turnOnDimensionalHaste = builder.comment("Should Dimension Wide Haste Be On?").define("turnOnDimensionalHaste", true);
this.waterVisibility = builder.comment("How far is visibility in Water?").defineInRange("waterVisibility", 120.0d, 1.0d, 200.0d);
this.shouldCitiesGenerate = builder.comment("Can Atlantean Cities generate? (Warning may cause slight lag when generating!)").define("shouldCitiesGenerate", false);
this.shouldHavePerBiomeLighting = builder.comment("Should Per Biome Lighting for Atlantis be on? (Warning Radon will cause it to be always 0 in every biome)").define("shouldHavePerBiomeLighting", false);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mystic.atlantis.lighting;

import com.mystic.atlantis.config.AtlantisConfig;
import com.mystic.atlantis.event.ACommonFEvents;

import net.minecraft.core.BlockPos;
Expand All @@ -22,20 +23,22 @@ public AtlantisChunkSkylightProvider(LightChunkGetter chunkProvider) {
protected int computeLevelFromNeighbor(long sourceId, long targetId, int level) {
int propagatedLevel = super.computeLevelFromNeighbor(sourceId, targetId, level);

BlockPos blockPos = BlockPos.of(targetId);
ChunkPos chunkPos = new ChunkPos(blockPos);
if (AtlantisConfig.INSTANCE.shouldHavePerBiomeLighting.get()) {
BlockPos blockPos = BlockPos.of(targetId);
ChunkPos chunkPos = new ChunkPos(blockPos);

BlockGetter blockGetter = chunkSource.getChunkForLighting(chunkPos.x, chunkPos.z);
if (blockGetter instanceof ChunkAccess chunkAccess) {
Holder<Biome> biome = chunkAccess.getNoiseBiome(
QuartPos.fromBlock(blockPos.getX()),
QuartPos.fromBlock(blockPos.getY()),
QuartPos.fromBlock(blockPos.getZ())
);
if(biome.unwrapKey().isPresent()) {
if (ACommonFEvents.map != null) {
if (ACommonFEvents.map.containsKey(biome.unwrapKey().get().location())) {
return Math.min(ACommonFEvents.map.get(biome.unwrapKey().get().location()), propagatedLevel);
BlockGetter blockGetter = chunkSource.getChunkForLighting(chunkPos.x, chunkPos.z);
if (blockGetter instanceof ChunkAccess chunkAccess) {
Holder<Biome> biome = chunkAccess.getNoiseBiome(
QuartPos.fromBlock(blockPos.getX()),
QuartPos.fromBlock(blockPos.getY()),
QuartPos.fromBlock(blockPos.getZ())
);
if (biome.unwrapKey().isPresent()) {
if (ACommonFEvents.map != null) {
if (ACommonFEvents.map.containsKey(biome.unwrapKey().get().location())) {
return Math.min(ACommonFEvents.map.get(biome.unwrapKey().get().location()), propagatedLevel);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mystic.atlantis.mixin;

import com.mystic.atlantis.dimension.DimensionAtlantis;
import com.mystic.atlantis.event.ACommonFEvents;
import net.caffeinemc.phosphor.mixin.chunk.light.MixinChunkSkyLightProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.QuartPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.lighting.SkyLightEngine;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(value = {SkyLightEngine.class}, priority = 2000)
public abstract class SkyLightEngineRadonFix {

/**
* @author Mysticpasta1
* @reason fix radon messing with my per biome lighting code!
*/
@Overwrite
public int computeLevelFromNeighbor(long fromId, long toId, int currentLevel) {
if(chunkSource.getLevel() instanceof Level level) {
if (DimensionAtlantis.isAtlantisDimension(level)) {
int propagatedLevel = getPropagatedLevel(fromId, null, toId, currentLevel);

BlockPos blockPos = BlockPos.of(toId);
ChunkPos chunkPos = new ChunkPos(blockPos);

BlockGetter blockGetter = chunkSource.getChunkForLighting(chunkPos.x, chunkPos.z);
if (blockGetter instanceof ChunkAccess chunkAccess) {
Holder<Biome> biome = chunkAccess.getNoiseBiome(
QuartPos.fromBlock(blockPos.getX()),
QuartPos.fromBlock(blockPos.getY()),
QuartPos.fromBlock(blockPos.getZ())
);
if (biome.unwrapKey().isPresent()) {
if (ACommonFEvents.map != null) {
if (ACommonFEvents.map.containsKey(biome.unwrapKey().get().location())) {
return Math.min(ACommonFEvents.map.get(biome.unwrapKey().get().location()), propagatedLevel);
}
}
}
}
}
}
return this.getPropagatedLevel(fromId, null, toId, currentLevel);
}
}
1 change: 1 addition & 0 deletions src/main/resources/atlantis.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"RedstoneAccessor",
"RedstoneWireBlockMixin",
"RenderBubblesMixin",
"SkyLightEngineRadonFix",
"WorldLightManagerMixin"
],
"client": [
Expand Down

0 comments on commit 3759413

Please sign in to comment.