Compare commits

...
Author SHA1 Message Date
063b2242e8 Initial FluidLogged compat (#985)
* Initial FluidLogged compat

* FluidLogged works(probably mostly)

* Make FluidLogged optional

* Remove a leftover print

* Fix fluidlogged fluids rendering incorrectly with shaders on

* Rmemove unused code

* Cleanup unused imports

---------

Co-authored-by: embeddedt <[email protected]>
Co-authored-by: Jason Mitchell <[email protected]>
2025-07-09 10:31:45 -04:00
Rad 577f905dc5 Update README.MD (#981) 2025-07-06 13:56:20 -07:00
Jason MitchellandAlexdoru 071d2d4a39 Add a guard to only init once (#984)
Co-authored-by: Alexdoru <[email protected]>
2025-07-01 10:33:49 -07:00
11 changed files with 209 additions and 27 deletions

No files matched your search

+2 -2
View File
@@ -36,7 +36,7 @@
* FastCraft [Disabled, won't fix]
* BetterFPS [Disabled, won't fix]
* OptimizationsAndTweaks [Disabled, won't fix]
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - use 1.2.2+
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - Use 1.2.2+
* [LWJGL3ify 1.5.4 and below](https://github.com/GTNewHorizons/lwjgl3ify/releases/) - Use the latest version available, 1.5.7+
* [ArchaicFix 0.6.2 and below](https://www.curseforge.com/minecraft/mc-mods/archaicfix/files/all?page=1&pageSize=20) - Use 0.7.0 or above
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
@@ -65,7 +65,7 @@
* Makamys for [Neodymium](https://github.com/makamys/Neodymium) - Various Tessellator -> Quad functionality taken under the LGPL 3
* MCPatcherForge
* Original [MCPatcher](https://bitbucket.org/prupe/mcpatcher/src/master/): Paul Rupe
* [Forge version](https://bitbucket.org/prupe/mcpatcher/src/master/): Mist475 under LGPL 3.0 with default ctm textures for glass and bookshelves by DarkBum under CC-BY-SA
* [Forge version](https://github.com/mist475/MCPatcherForge): Mist475 under LGPL 3.0 with default ctm textures for glass and bookshelves by DarkBum under CC-BY-SA
* HUDCaching
* Created by [Moulberry](https://github.com/Moulberry/MCHUDCaching), backported from [Patcher](https://github.com/Sk1erLLC/Patcher) mod by Alexdoru under the CC-BY-SA-NC 4.0 license
* Angelica
+2
View File
@@ -113,4 +113,6 @@ dependencies {
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation("org.mockito:mockito-core:3.+")
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
compileOnly("mega:fluidlogged-mc1.7.10:0.1.2")
}
+7
View File
@@ -8,6 +8,13 @@ repositories {
includeGroup 'com.falsepattern'
}
}
maven {
name = 'mega'
url = 'https://mvn.falsepattern.com/gtmega_releases/'
content {
includeGroup 'mega'
}
}
exclusiveContent {
forRepository {
ivy {
@@ -32,6 +32,7 @@ public class ModStatus {
public static boolean isThaumcraftLoaded;
public static boolean isThaumicHorizonsLoaded;
public static boolean isBaublesLoaded;
public static boolean isFluidLoggedLoaded;
public static void preInit(){
isBackhandLoaded = Loader.isModLoaded("backhand");
@@ -51,6 +52,7 @@ public class ModStatus {
isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
isThaumicHorizonsLoaded = Loader.isModLoaded("ThaumicHorizons");
isBaublesLoaded = Loader.isModLoaded("Baubles");
isFluidLoggedLoaded = Loader.isModLoaded("fluidlogged");
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
@@ -104,7 +104,7 @@ public enum Mixins {
IRIS_STARTUP(new Builder("Start Iris").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
"shaders.startup.MixinGameSettings"
,"shaders.startup.MixinGuiMainMenu"
,"shaders.startup.MixinMinecraft"
,"shaders.startup.MixinInitRenderer"
,"shaders.startup.MixinAbstractTexture"
,"shaders.startup.MixinTextureAtlasSprite"
@@ -2,6 +2,7 @@ package me.jellysquid.mods.sodium.client.render.chunk.tasks;
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
@@ -36,6 +37,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import org.joml.Vector3d;
import java.util.Map;
@@ -155,6 +157,11 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
for (int relZ = 0; relZ < 16; relZ++) {
for (int relX = 0; relX < 16; relX++) {
Fluid fluid = null;
if (ModStatus.isFluidLoggedLoaded) {
fluid = slice.getFluidRelative(relX + 16, relY + 16, relZ + 16);
}
final Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
// If the block is vanilla air, assume it renders nothing. Don't use isAir because mods
@@ -172,10 +179,18 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
if (rendersOffThread(block)) {
// Do regular block rendering
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
if (ModStatus.isFluidLoggedLoaded) {
if (fluid != null && canRenderInPass(fluid.getBlock(), pass)) {
ChunkRenderManager.setWorldRenderPass(pass);
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(fluid.getBlock(), ExtendedDataHelper.FLUID_RENDER_TYPE);
cache.getBlockRenderer().renderFluidLogged(fluid, renderBlocks, pos, buffers.get(pass), seed);
}
}
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
ChunkRenderManager.setWorldRenderPass(pass);
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), renderBlocks, block, meta, pos, buffers.get(pass), true, seed)) {
@@ -183,6 +198,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
}
}
}
} else {
mainThreadBlocks.enqueue(pos.asLong());
hasMainThreadBlocks = true;
@@ -339,6 +355,6 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
}
private static boolean shouldUseSodiumFluidRendering(Block block) {
return AngelicaConfig.enableSodiumFluidRendering && WorldUtil.isFluidBlock(block);
return AngelicaConfig.enableSodiumFluidRendering && WorldUtil.isFluidBlock(block) && !ModStatus.isFluidLoggedLoaded;
}
}
@@ -32,6 +32,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import java.util.List;
import java.util.Random;
@@ -62,13 +63,54 @@ public class BlockRenderer {
this.occlusionCache = new BlockOcclusionCache();
}
public boolean renderFluidLogged(Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
if (fluid == null) {
return false;
}
Block block = fluid.getBlock();
if (block == null) {
return false;
}
boolean rendered = false;
try {
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
final LightPipeline lighter = this.lighters.getLighter(mode);
TessellatorManager.startCapturing();
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
tess.startDrawingQuads();
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
// is done in subchunk-relative coordinates
tess.setOffset(POS_ZERO);
tess.setTranslation(-pos.x, -pos.y, -pos.z);
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
tess.resetOffset();
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
this.random.setSeed(seed);
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
}
if (!quads.isEmpty()) rendered = true;
} finally {
TessellatorManager.cleanup();
}
return rendered;
}
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPos pos, ChunkModelBuffers buffers, boolean cull, long seed) {
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
final LightPipeline lighter = this.lighters.getLighter(mode);
boolean rendered = false;
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
boolean rendered = false;
final QuadProvider model = ((ModeledBlock) block).getModel();
if (model != null) {
@@ -3,13 +3,16 @@ package me.jellysquid.mods.sodium.client.world;
import java.util.Arrays;
import com.gtnewhorizons.angelica.api.IBlockAccessExtended;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import cpw.mods.fml.common.Optional;
import lombok.Getter;
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSectionCache;
import mega.fluidlogged.api.FLBlockAccess;
import net.minecraft.block.Block;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.init.Blocks;
@@ -24,6 +27,8 @@ import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import org.jetbrains.annotations.Nullable;
/**
* Takes a slice of world state (block states, biome and light data arrays) and copies the data for use in off-thread
@@ -35,7 +40,8 @@ import net.minecraftforge.common.util.ForgeDirection;
*
* Object pooling should be used to avoid huge allocations as this class contains many large arrays.
*/
public class WorldSlice implements IBlockAccessExtended {
@Optional.Interface(iface = "mega.fluidlogged.api.FLBlockAccess", modid = "fluidlogged")
public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
private static final EnumSkyBlock[] LIGHT_TYPES = EnumSkyBlock.values();
// The number of blocks on each axis in a section.
@@ -68,6 +74,7 @@ public class WorldSlice implements IBlockAccessExtended {
// Local Section->BlockState table.
private final Block[][] blockArrays;
private final Fluid[][] fluidArrays;
private final int[][] metadataArrays;
// Local Section->Light table
@@ -145,6 +152,12 @@ public class WorldSlice implements IBlockAccessExtended {
this.biomeData = new BiomeGenBase[SECTION_TABLE_ARRAY_SIZE][];
this.lightArrays = new NibbleArray[SECTION_TABLE_ARRAY_SIZE][LIGHT_TYPES.length];
if (ModStatus.isFluidLoggedLoaded) {
this.fluidArrays = new Fluid[SECTION_TABLE_ARRAY_SIZE][];
} else {
this.fluidArrays = null;
}
for (int x = 0; x < SECTION_LENGTH; x++) {
for (int y = 0; y < SECTION_LENGTH; y++) {
for (int z = 0; z < SECTION_LENGTH; z++) {
@@ -152,6 +165,10 @@ public class WorldSlice implements IBlockAccessExtended {
this.blockArrays[i] = new Block[SECTION_BLOCK_COUNT];
Arrays.fill(this.blockArrays[i], Blocks.air);
this.metadataArrays[i] = new int[SECTION_BLOCK_COUNT];
if (ModStatus.isFluidLoggedLoaded && this.fluidArrays != null) {
this.fluidArrays[i] = new Fluid[SECTION_BLOCK_COUNT];
}
}
}
}
@@ -175,6 +192,11 @@ public class WorldSlice implements IBlockAccessExtended {
final ClonedChunkSection section = this.sections[idx];
this.unpackBlockData(this.blockArrays[idx], this.metadataArrays[idx], section, context.getVolume());
if (ModStatus.isFluidLoggedLoaded) {
this.unpackFluidLoggedData(this.fluidArrays[idx], section, context.getVolume());
}
this.biomeData[idx] = section.getBiomeData();
this.lightArrays[idx][EnumSkyBlock.Block.ordinal()] = section.getLightArray(EnumSkyBlock.Block);
@@ -191,8 +213,8 @@ public class WorldSlice implements IBlockAccessExtended {
return (15 << 20) | (min << 4);
}
final int skyBrightness = this.getSkyBlockTypeBrightness(net.minecraft.world.EnumSkyBlock.Sky, x, y, z);
int blockBrightness = this.getSkyBlockTypeBrightness(net.minecraft.world.EnumSkyBlock.Block, x, y, z);
final int skyBrightness = this.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z);
int blockBrightness = this.getSkyBlockTypeBrightness(EnumSkyBlock.Block, x, y, z);
if (blockBrightness < min) {
blockBrightness = min;
@@ -265,6 +287,14 @@ public class WorldSlice implements IBlockAccessExtended {
return getBlock(x, y, z).isSideSolid(this, x, y, z, side);
}
private void unpackFluidLoggedData(Fluid[] fluids, ClonedChunkSection section, StructureBoundingBox box) {
if (this.origin.equals(section.getPosition())) {
this.unpackFluidLoggedDataZ(fluids, section);
} else {
this.unpackFluidLoggedDataR(fluids, section, box);
}
}
private void unpackBlockData(Block[] blocks, int[] metas, ClonedChunkSection section, StructureBoundingBox box) {
if (this.origin.equals(section.getPosition())) {
this.unpackBlockDataZ(blocks, metas, section);
@@ -273,6 +303,48 @@ public class WorldSlice implements IBlockAccessExtended {
}
}
private void unpackFluidLoggedDataR(Fluid[] fluids, ClonedChunkSection section, StructureBoundingBox box) {
final ChunkSectionPos pos = section.getPosition();
final int minBlockX = Math.max(box.minX, pos.getMinX());
final int maxBlockX = Math.min(box.maxX, pos.getMaxX());
final int minBlockY = Math.max(box.minY, pos.getMinY());
final int maxBlockY = Math.min(box.maxY, pos.getMaxY());
final int minBlockZ = Math.max(box.minZ, pos.getMinZ());
final int maxBlockZ = Math.min(box.maxZ, pos.getMaxZ());
copyFluids(fluids, section, minBlockY, maxBlockY, minBlockZ, maxBlockZ, minBlockX, maxBlockX);
}
private void unpackFluidLoggedDataZ(Fluid[] fluids, ClonedChunkSection section) {
// TODO: Look into a faster copy for this?
final ChunkSectionPos pos = section.getPosition();
final int minBlockX = pos.getMinX();
final int maxBlockX = pos.getMaxX();
final int minBlockY = pos.getMinY();
final int maxBlockY = pos.getMaxY();
final int minBlockZ = pos.getMinZ();
final int maxBlockZ = pos.getMaxZ();
// TODO: Can this be optimized?
copyFluids(fluids, section, minBlockY, maxBlockY, minBlockZ, maxBlockZ, minBlockX, maxBlockX);
}
private static void copyFluids(Fluid[] fluids, ClonedChunkSection section, int minBlockY, int maxBlockY, int minBlockZ, int maxBlockZ, int minBlockX, int maxBlockX) {
for (int y = minBlockY; y <= maxBlockY; y++) {
for (int z = minBlockZ; z <= maxBlockZ; z++) {
for (int x = minBlockX; x <= maxBlockX; x++) {
final int blockIdx = getLocalBlockIndex(x & 15, y & 15, z & 15);
fluids[blockIdx] = section.getFluid(x & 15, y & 15, z & 15);
}
}
}
}
private static void copyBlocks(Block[] blocks, int[] metas, ClonedChunkSection section, int minBlockY, int maxBlockY, int minBlockZ, int maxBlockZ, int minBlockX, int maxBlockX) {
for (int y = minBlockY; y <= maxBlockY; y++) {
@@ -419,4 +491,23 @@ public class WorldSlice implements IBlockAccessExtended {
z >= box.minZ &&
z <= box.maxZ;
}
public @Nullable Fluid fl$getFluid(int x, int y, int z) {
if (!blockBoxContains(this.volume, x, y, z)) {
return null;
}
final int relX = x - this.baseX;
final int relY = y - this.baseY;
final int relZ = z - this.baseZ;
return this.fluidArrays[getLocalSectionIndex(relX >> 4, relY >> 4, relZ >> 4)][getLocalBlockIndex(relX & 15, relY & 15, relZ & 15)];
}
public Fluid getFluidRelative(int x, int y, int z) {
return this.fluidArrays[getLocalSectionIndex(x >> 4, y >> 4, z >> 4)][getLocalBlockIndex(x & 15, y & 15, z & 15)];
}
public void fl$setFluid(int x, int y, int z, @Nullable Fluid fluid) {
throw new UnsupportedOperationException("Cannot set fluids in a world slice. WorldSlice is read-only");
}
}
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
import lombok.Getter;
import mega.fluidlogged.internal.mixin.hook.FLSubChunk;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.EnumSkyBlock;
@@ -15,6 +16,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.fluids.Fluid;
import java.util.concurrent.atomic.AtomicInteger;
@@ -102,6 +104,14 @@ public class ClonedChunkSection {
return data.getBlockByExtId(x, y, z);
}
public Fluid getFluid(int x, int y, int z) {
if (ModStatus.isFluidLoggedLoaded) {
return ((FLSubChunk) data).fl$getFluid(x, y, z);
}
return null;
}
public int getBlockMetadata(int x, int y, int z) {
return data.getExtBlockMetadata(x, y, z);
}
@@ -1,18 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.shaders.startup;
import net.coderbot.iris.Iris;
import net.minecraft.client.gui.GuiMainMenu;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiMainMenu.class)
public class MixinGuiMainMenu {
@Inject(method = "initGui", at = @At("RETURN"))
public void angelica$shadersOnLoadingComplete(CallbackInfo ci) {
Iris.onLoadingComplete();
}
}
@@ -0,0 +1,30 @@
package com.gtnewhorizons.angelica.mixins.early.shaders.startup;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.coderbot.iris.Iris;
import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public class MixinMinecraft {
@Unique
private static boolean angelica$hasFirstInit;
@Inject(method = "startGame",
at = @At(value = "INVOKE",
remap = false,
shift = At.Shift.BEFORE,
target = "Lcpw/mods/fml/client/SplashProgress;clearVanillaResources(Lnet/minecraft/client/renderer/texture/TextureManager;Lnet/minecraft/util/ResourceLocation;)V"))
public void angelica$shadersOnLoadingComplete(CallbackInfo ci) {
if (!angelica$hasFirstInit && GLStateManager.isMainThread()) {
angelica$hasFirstInit = true;
Iris.onLoadingComplete();
}
}
}