From ec012d9fd61d59106cc2bdd1aa2e016cb4cc84c7 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 1 Sep 2024 15:04:24 -0500 Subject: [PATCH] Fix glass panes not affecting beacon colors --- .../block/IBlockStateWrapper.java | 8 ++++++- .../chunk/IChunkWrapper.java | 21 ++++++++++--------- .../LightingTestBlockStateWrapper.java | 6 +++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/block/IBlockStateWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/block/IBlockStateWrapper.java index 1d14d1b37..e83b74e4c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/block/IBlockStateWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/block/IBlockStateWrapper.java @@ -47,9 +47,15 @@ public interface IBlockStateWrapper extends IDhApiBlockStateWrapper byte getMaterialId(); boolean isBeaconBlock(); + /** IE a glass block that can affect the beacon beam color */ + boolean isBeaconTintBlock(); + /** + * The blocks used by a beacon's base + * IE Iron, diamond, gold, etc. + */ boolean isBeaconBaseBlock(); Color getMapColor(); - boolean isGlassBlock(); + Color getBeaconTintColor(); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java index b5109b94a..56cc08a78 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java @@ -20,12 +20,15 @@ package com.seibel.distanthorizons.core.wrapperInterfaces.chunk; import com.seibel.distanthorizons.core.generation.AdjacentChunkHolder; +import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO; +import com.seibel.distanthorizons.core.util.ColorUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable; @@ -410,7 +413,7 @@ public interface IChunkWrapper extends IBindable int red = 0; int green = 0; int blue = 0; - boolean glassBlockFound = false; + boolean beaconTintBlockFound = false; IChunkWrapper centerChunk = chunkHolder.getByBlockPos(beaconPos.getX(), beaconPos.getZ()); int maxY = centerChunk.getMaxNonEmptyHeight(); @@ -422,25 +425,23 @@ public interface IChunkWrapper extends IBindable return null; } - if (block.isGlassBlock() - // ignore invisible blocks (which have pure black as their map color, luckily black stained-glass is actually extremely dark gray) - && !block.getMapColor().equals(Color.BLACK)) + if (block.isBeaconTintBlock()) { - red += block.getMapColor().getRed(); - green += block.getMapColor().getGreen(); - blue += block.getMapColor().getBlue(); + red += block.getBeaconTintColor().getRed(); + green += block.getBeaconTintColor().getGreen(); + blue += block.getBeaconTintColor().getBlue(); - if (glassBlockFound) + if (beaconTintBlockFound) { red /= 2; green /= 2; blue /= 2; } - glassBlockFound = true; + beaconTintBlockFound = true; } } - return glassBlockFound ? new Color(red, green, blue) : Color.WHITE; + return beaconTintBlockFound ? new Color(red, green, blue) : Color.WHITE; } diff --git a/core/src/test/java/testItems/lightingEngine/LightingTestBlockStateWrapper.java b/core/src/test/java/testItems/lightingEngine/LightingTestBlockStateWrapper.java index a46f50fc3..cb5a719a3 100644 --- a/core/src/test/java/testItems/lightingEngine/LightingTestBlockStateWrapper.java +++ b/core/src/test/java/testItems/lightingEngine/LightingTestBlockStateWrapper.java @@ -114,8 +114,8 @@ public class LightingTestBlockStateWrapper implements IBlockStateWrapper @Override public Color getMapColor() { throw new UnsupportedOperationException("Not Implemented"); } @Override - public boolean isGlassBlock() { throw new UnsupportedOperationException("Not Implemented"); } - - + public boolean isBeaconTintBlock() { throw new UnsupportedOperationException("Not Implemented"); } + @Override + public Color getBeaconTintColor() { throw new UnsupportedOperationException("Not Implemented"); } }