From 485e6c529dec7e98982c70638559b5236bf20b14 Mon Sep 17 00:00:00 2001 From: Snownee <1850986885@qq.com> Date: Mon, 18 May 2020 23:57:49 +0800 Subject: [PATCH] Implement IHaveColorHandler on WindowInABlockBlock https://discordapp.com/channels/620934202875183104/689866656914210897/700713829407129620 --- .../partialWindows/WindowInABlockBlock.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockBlock.java b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockBlock.java index f913a6bb1..a38ffafbd 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockBlock.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockBlock.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import com.simibubi.create.foundation.block.IHaveColorHandler; import com.simibubi.create.foundation.block.IHaveCustomBlockModel; import com.simibubi.create.foundation.block.IHaveNoBlockItem; import com.simibubi.create.foundation.block.ITE; @@ -15,6 +16,8 @@ import net.minecraft.block.FourWayBlock; import net.minecraft.block.PaneBlock; import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -47,7 +50,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class WindowInABlockBlock extends PaneBlock - implements ITE, IHaveNoBlockItem, IHaveCustomBlockModel { + implements ITE, IHaveNoBlockItem, IHaveCustomBlockModel, IHaveColorHandler { public WindowInABlockBlock() { super(Properties.create(Material.ROCK)); @@ -210,6 +213,7 @@ public class WindowInABlockBlock extends PaneBlock return Blocks.AIR.getDefaultState(); } + @Override @OnlyIn(Dist.CLIENT) public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { return false; @@ -226,4 +230,16 @@ public class WindowInABlockBlock extends PaneBlock return WindowInABlockTileEntity.class; } + @Override + @OnlyIn(Dist.CLIENT) + public IBlockColor getColorHandler() { + return (state, world, pos, index) -> { + try { + BlockState surrounding = getSurroundingBlockState(world, pos); + return Minecraft.getInstance().getBlockColors().getColor(surrounding, world, pos, index); + } catch (Exception e) {} + return -1; + }; + } + }