Use Angelica/Celeritas AO when Angelica is present (#440)

Co-authored-by: Armisael <193531144+Armisael5@users.noreply.github.com>
This commit is contained in:
ah-OOG-ahandArmisael authored and GitHub committed 2026-11-03 14:46:32 -05:00
1 parent 725392ab26
commit 70a7fd81ab
9 files changed
+166 -6

No files matched your search

@@ -34,6 +34,7 @@ import com.gtnewhorizon.gtnhlib.network.PacketMessageAboveHotbar;
import com.gtnewhorizon.gtnhlib.network.PacketViewDistance;
import com.gtnewhorizon.gtnhlib.teams.TeamAdminCommand;
import com.gtnewhorizon.gtnhlib.teams.TeamCommand;
import com.gtnewhorizon.gtnhlib.test.block.BlockLightUnderStair;
import com.gtnewhorizon.gtnhlib.test.block.BlockRngTest;
import com.gtnewhorizon.gtnhlib.test.block.BlockTest;
import com.gtnewhorizon.gtnhlib.test.block.BlockTestAo;
@@ -74,6 +75,7 @@ public class CommonProxy {
GTNHLib.info("GTNHLib version " + Tags.VERSION + " loaded.");
if (GTNHLibConfig.enableTestBlocks) {
BlockLightUnderStair.register();
BlockTest.register();
BlockTestAo.register();
BlockTestLectern.register();
@@ -0,0 +1,30 @@
package com.gtnewhorizon.gtnhlib.client.model;
import net.minecraft.client.renderer.Tessellator;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
class AngelicaHelper {
/// This method doesn't need to mess with [com.gtnewhorizons.angelica.api.ExtCeleritasRenderBlocks] because that
/// only affects [net.minecraft.client.renderer.RenderBlocks] methods, which we don't use.
static void initAngelicaLighting(Tessellator tesselator) {
if (!(tesselator instanceof StateAwareTessellator saTess)) return;
saTess.angelica$setAppliedAo(true);
}
static void quadAngelicaLighting(Tessellator tesselator, boolean ao, boolean noDirectionalShading) {
if (!(tesselator instanceof StateAwareTessellator saTess)) return;
saTess.angelica$setAppliedAo(ao);
saTess.angelica$setNoDirectionalShading(noDirectionalShading);
}
static void resetAngelicaLighting(Tessellator tesselator) {
if (!(tesselator instanceof StateAwareTessellator saTess)) return;
saTess.angelica$setAppliedAo(false);
saTess.angelica$setNoDirectionalShading(false);
}
}
@@ -5,6 +5,7 @@ import static com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8.unpac
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8.unpackZ;
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.DIRECTIONS;
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.VALUES;
import static com.gtnewhorizon.gtnhlib.compat.Mods.ANGELICA;
import static java.lang.Float.intBitsToFloat;
import static java.lang.Math.max;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
@@ -86,6 +87,8 @@ public class ModelISBRH implements ISimpleBlockRenderingHandler, IItemRenderer {
worldContext.set(wrappedContext, x, y, z, RAND);
final int meta = wrappedContext.getBlockMetadata(x, y, z);
if (ANGELICA) AngelicaHelper.initAngelicaLighting(tesselator);
final BakedModel model = ModelRegistry.getBakedModel(worldContext);
int color = model.getColor(world, x, y, z, block, meta, RAND);
@@ -125,11 +128,26 @@ public class ModelISBRH implements ISimpleBlockRenderingHandler, IItemRenderer {
final int lm = getLightMap(block, quad, quad.getLightFace(), world, x, y, z, renderer);
tesselator.setBrightness(lm);
final float shade = quad.hasDirectionalShading() ? diffuseLight(quad.getComputedFaceNormal()) : 1;
if (ANGELICA) {
AngelicaHelper.quadAngelicaLighting(
tesselator,
quad.hasAmbientOcclusion(),
!quad.hasDirectionalShading());
}
final float shade;
if (ANGELICA && quad.hasAmbientOcclusion()) {
shade = 1;
} else {
shade = quad.hasDirectionalShading() ? diffuseLight(quad.getComputedFaceNormal()) : 1;
}
tesselator.setColorOpaque_F(r * shade, g * shade, b * shade);
renderQuad(quad, x, y, z, tesselator, renderer.overrideBlockTexture);
}
}
if (ANGELICA) AngelicaHelper.resetAngelicaLighting(tesselator);
worldContext.reset();
return rendered;
}
@@ -67,11 +67,10 @@ public interface ModelQuadView extends ModelPrimitiveView {
*/
boolean isTransparent();
/**
* Not to be confused with ambient occlusion AKA smooth lighting When true, allows this quad to multiply its
* brightness based on the direction it's facing. When this is false, each face derives its brightness directly from
* the light value it's facing without multiplying it.
*/
/// Not to be confused with ambient occlusion AKA smooth lighting. When true, allows this quad to multiply its
/// brightness based on the direction it's facing. When this is false, each face derives its brightness directly
/// from
/// the light value it's facing without multiplying it.
boolean hasDirectionalShading();
/**
@@ -0,0 +1,45 @@
package com.gtnewhorizon.gtnhlib.test.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.gtnewhorizon.gtnhlib.blockstate.properties.DirectionBlockProperty;
import com.gtnewhorizon.gtnhlib.blockstate.properties.DirectionBlockProperty.AbstractDirectionBlockProperty;
import com.gtnewhorizon.gtnhlib.blockstate.registry.BlockPropertyRegistry;
import com.gtnewhorizon.gtnhlib.util.DirectionUtil;
import cpw.mods.fml.common.registry.GameRegistry;
public class BlockLightUnderStair extends Block {
public final AbstractDirectionBlockProperty FACING_PROP = (AbstractDirectionBlockProperty) DirectionBlockProperty
.facing();
public BlockLightUnderStair() {
super(Material.wood);
}
public static void register() {
final var testBlock = new BlockLightUnderStair();
testBlock.setBlockName("light_under_stair");
GameRegistry.registerBlock(testBlock, "light_under_stair");
BlockPropertyRegistry.registerBlockItemProperty(testBlock, testBlock.FACING_PROP, ForgeDirection.EAST);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void onBlockPlacedBy(World worldIn, int x, int y, int z, EntityLivingBase placer, ItemStack itemIn) {
var dir = DirectionUtil.yawToDirection(placer.rotationYaw);
worldIn.setBlockMetadataWithNotify(x, y, z, FACING_PROP.getMeta(dir, 0), 2);
}
}
@@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "gtnhlib:blocks/light_test_stairs", "y": 270, "uvlock": true },
"facing=south": { "model": "gtnhlib:blocks/light_test_stairs", "y": 90, "uvlock": true },
"facing=west": { "model": "gtnhlib:blocks/light_test_stairs", "y": 0, "uvlock": true },
"facing=east": { "model": "gtnhlib:blocks/light_test_stairs", "y": 180, "uvlock": true }
}
}
@@ -1,4 +1,5 @@
# Test block names
tile.light_under_stair.name=Directional Shading Test Block
tile.model_test.name=Test Block
tile.model_test_tint.name=Test Block (Tint)
tile.model_test_tint_mul.name=Test Block (Tint Mul)
@@ -0,0 +1,8 @@
{
"parent": "gtnhlib:blocks/light_under_stair",
"textures": {
"bottom": "minecraft:planks_oak",
"side": "minecraft:planks_oak",
"top": "minecraft:planks_oak"
}
}
@@ -0,0 +1,49 @@
{
"parent": "block/block",
"display": {
"gui": {
"rotation": [ 30, 135, 0 ],
"translation": [ 0, 0, 0],
"scale":[ 0.625, 0.625, 0.625 ]
},
"head": {
"rotation": [ 0, -90, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 1, 1, 1 ]
},
"thirdperson_lefthand": {
"rotation": [ 75, -135, 0 ],
"translation": [ 0, 2.5, 0],
"scale": [ 0.375, 0.375, 0.375 ]
}
},
"textures": {
"particle": "#side"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 8, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" },
"north": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" }
},
"shade": false
},
{
"from": [ 8, 8, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up" },
"north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side" },
"east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" }
}
}
]
}