forked from FiniteReality/embeddium
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement proper Sodium biome blending & entity distance sliders
- Loading branch information
Showing
12 changed files
with
123 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/me/jellysquid/mods/sodium/client/world/SodiumBlockAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.jellysquid.mods.sodium.client.world; | ||
|
||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.biome.BiomeColorHelper; | ||
|
||
/** | ||
* Contains extensions to the vanilla {@link IBlockAccess}. | ||
*/ | ||
public interface SodiumBlockAccess extends IBlockAccess { | ||
int getBlockTint(BlockPos pos, BiomeColorHelper.ColorResolver resolver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinBiomeColorHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package me.jellysquid.mods.sodium.mixin.features.chunk_rendering; | ||
|
||
import me.jellysquid.mods.sodium.client.SodiumClientMod; | ||
import me.jellysquid.mods.sodium.client.world.SodiumBlockAccess; | ||
import me.jellysquid.mods.sodium.client.world.WorldSlice; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.BiomeColorHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(value = BiomeColorHelper.class, priority = 1200) | ||
public class MixinBiomeColorHelper { | ||
/** | ||
* @author embeddedt | ||
* @reason reduce allocation rate, use Sodium's biome cache, use configurable biome blending | ||
*/ | ||
@Overwrite | ||
private static int getColorAtPos(IBlockAccess blockAccess, BlockPos pos, BiomeColorHelper.ColorResolver colorResolver) | ||
{ | ||
if (blockAccess instanceof SodiumBlockAccess) { | ||
// Use Sodium's more efficient biome cache | ||
return ((SodiumBlockAccess)blockAccess).getBlockTint(pos, colorResolver); | ||
} | ||
int radius = SodiumClientMod.options().quality.biomeBlendRadius; | ||
if (radius == 0) { | ||
return colorResolver.getColorAtPos(blockAccess.getBiome(pos), pos); | ||
} else { | ||
int blockCount = (radius * 2 + 1) * (radius * 2 + 1); | ||
|
||
int i = 0; | ||
int j = 0; | ||
int k = 0; | ||
|
||
BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); | ||
|
||
for(int z = -radius; z <= radius; z++) { | ||
for(int x = -radius; x <= radius; x++) { | ||
mutablePos.setPos(pos.getX() + x, pos.getY(), pos.getZ() + z); | ||
int l = colorResolver.getColorAtPos(blockAccess.getBiome(mutablePos), mutablePos); | ||
i += (l & 16711680) >> 16; | ||
j += (l & 65280) >> 8; | ||
k += l & 255; | ||
} | ||
} | ||
|
||
return (i / blockCount & 255) << 16 | (j / blockCount & 255) << 8 | k / blockCount & 255; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters