This commit is contained in:
parent
f38f6fbced
commit
5258a235b5
@ -5,6 +5,8 @@ import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlock
|
||||
import com.thebrokenrail.energonrelics.mixin.RenderPhaseAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
@ -22,6 +24,8 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntity> {
|
||||
public HighlightBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
@ -45,16 +49,21 @@ public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntit
|
||||
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack));
|
||||
if (!contains) {
|
||||
renderCuboid(matrices, vertexConsumers.getBuffer(UNSELECTED_LAYER));
|
||||
renderCuboid(entity, matrices, vertexConsumers.getBuffer(UNSELECTED_LAYER));
|
||||
} else {
|
||||
renderCuboid(matrices, vertexConsumers.getBuffer(SELECTED_LAYER));
|
||||
renderCuboid(entity, matrices, vertexConsumers.getBuffer(SELECTED_LAYER));
|
||||
}
|
||||
}
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
protected static void renderCuboid(MatrixStack matrices, VertexConsumer consumer) {
|
||||
private static boolean shouldDrawSide(BlockEntity entity, Direction side) {
|
||||
BlockState state = entity.getCachedState();
|
||||
return Block.shouldDrawSide(state, Objects.requireNonNull(entity.getWorld()), entity.getPos(), side);
|
||||
}
|
||||
|
||||
protected static void renderCuboid(BlockEntity entity, MatrixStack matrices, VertexConsumer consumer) {
|
||||
float sizeX = 1f;
|
||||
float sizeY = 1f;
|
||||
float sizeZ = 1f;
|
||||
@ -62,6 +71,7 @@ public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntit
|
||||
matrices.translate(0.5d, 0.5d, 0.5d);
|
||||
|
||||
for (Direction side : Direction.values()) {
|
||||
if (shouldDrawSide(entity, side)) {
|
||||
matrices.push();
|
||||
|
||||
multiply(matrices, side);
|
||||
@ -76,6 +86,7 @@ public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntit
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void vertex(VertexConsumer consumer, Matrix4f model, float x, float y, float z) {
|
||||
consumer.vertex(model, x, y, z).color(1f, 1f, 1f, 1f).next();
|
||||
|
@ -67,7 +67,7 @@ public class HolographicSkyBlockEntityRenderer extends HighlightBlockEntityRende
|
||||
if (entity instanceof HolographicSkyBlockEntity && entity.getCachedState().get(HolographicSkyBlock.POWERED)) {
|
||||
matrixStack.push();
|
||||
Matrix4f matrix4f = matrixStack.peek().getModel();
|
||||
renderCuboid(matrixStack, vertexConsumerProvider.getBuffer(LAYER));
|
||||
renderCuboid(entity, matrixStack, vertexConsumerProvider.getBuffer(LAYER));
|
||||
matrixStack.pop();
|
||||
}
|
||||
super.render(entity, f, matrixStack, vertexConsumerProvider, i, j);
|
||||
|
Reference in New Issue
Block a user