Skip to content

Commit 871d6ff

Browse files
committed
* Fixed slate rendering, scroll rendering, inline pattern rendering (partially)
1 parent 7987ab5 commit 871d6ff

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Common/src/main/java/at/petrak/hexcasting/client/render/WorldlyPatternRenderHelpers.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import com.mojang.blaze3d.vertex.PoseStack;
1010
import com.mojang.math.Axis;
1111
import net.minecraft.client.renderer.LevelRenderer;
12+
import net.minecraft.client.renderer.LightTexture;
1213
import net.minecraft.client.renderer.MultiBufferSource;
14+
import net.minecraft.core.Direction;
1315
import net.minecraft.core.Vec3i;
1416
import net.minecraft.world.level.block.state.BlockState;
1517
import net.minecraft.world.level.block.state.properties.AttachFace;
@@ -52,7 +54,7 @@ public static void renderPatternForScroll(HexPattern pattern, EntityWallScroll s
5254
ps.pushPose();
5355
ps.translate(-blockSize / 2f, -blockSize / 2f, 1f / 32f);
5456
// there's almost certainly a better way to do this, but we're just flipping the y and z axes to fix normals
55-
ps.last().normal().mul(new Matrix3f(1, 0, 0, 0, 0, 1, 0, 1, 0));
57+
// no need for this anymore :D
5658
renderPattern(pattern, showStrokeOrder ? READABLE_SCROLL_SETTINGS : SCROLL_SETTINGS,
5759
showStrokeOrder ? PatternColors.READABLE_SCROLL_COLORS : PatternColors.DEFAULT_PATTERN_COLOR,
5860
scroll.getPos().hashCode(), ps, bufSource, null, null, light, blockSize);
@@ -61,7 +63,7 @@ public static void renderPatternForScroll(HexPattern pattern, EntityWallScroll s
6163

6264
private static final int[] WALL_ROTATIONS = {180, 270, 0, 90};
6365
private static final Vec3i[] SLATE_FACINGS = {new Vec3i(0, -1, 0), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1), new Vec3i(0, -1 , 1)};
64-
private static final Vec3[] WALL_NORMALS = {new Vec3(0, 0, -1), new Vec3(-1, 0, 0), new Vec3(0, 0, -1), new Vec3(-1, 0, 0)};
66+
private static final Vec3[] WALL_NORMALS = {new Vec3(0, 0, 1), new Vec3(-1, 0, 0), new Vec3(0, 0, -1), new Vec3(1, 0, 0)};
6567
private static final Vec3i[] SLATE_FLOORCEIL_FACINGS = {new Vec3i(0,0,0), new Vec3i(1,0,0), new Vec3i(1,0,1), new Vec3i(0,0,1)};
6668

6769
public static void renderPatternForSlate(BlockEntitySlate tile, HexPattern pattern, PoseStack ps, MultiBufferSource buffer, int light, BlockState bs)
@@ -89,12 +91,17 @@ public static void renderPatternForSlate(BlockEntitySlate tile, HexPattern patte
8991
ps.mulPose(Axis.YP.rotationDegrees(facing*-90));
9092
ps.mulPose(Axis.XP.rotationDegrees(90 * (isOnCeiling ? -1 : 1)));
9193
if(isOnCeiling) ps.translate(0,-1,1);
94+
95+
// Set the normal for floor/ceiling slates so lighting is correct
96+
// Floor faces up, ceiling faces down
97+
normal = isOnCeiling ? new Vec3(0, -1, 0) : new Vec3(0, 1, 0);
9298
}
9399

100+
int actualLight = LevelRenderer.getLightColor(tile.getLevel(), tile.getBlockPos().relative(Direction.getNearest(normal)));
94101
renderPattern(pattern,
95-
wombly ? WORLDLY_SETTINGS_WOBBLY : WORLDLY_SETTINGS,
96-
wombly ? PatternColors.SLATE_WOBBLY_PURPLE_COLOR : PatternColors.DEFAULT_PATTERN_COLOR,
97-
tile.getBlockPos().hashCode(), ps, buffer, normal, null, light, 1);
102+
wombly ? WORLDLY_SETTINGS_WOBBLY : WORLDLY_SETTINGS,
103+
wombly ? PatternColors.SLATE_WOBBLY_PURPLE_COLOR : PatternColors.DEFAULT_PATTERN_COLOR,
104+
tile.getBlockPos().hashCode(), ps, buffer, normal, null, actualLight, 1);
98105
ps.popPose();
99106
}
100107

Common/src/main/java/at/petrak/hexcasting/interop/inline/InlinePatternRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.samsthenerd.inline.api.client.InlineRenderer;
66
import com.samsthenerd.inline.impl.InlineStyle;
77
import net.minecraft.client.gui.GuiGraphics;
8+
import net.minecraft.client.renderer.LightTexture;
89
import net.minecraft.network.chat.Style;
910
import net.minecraft.resources.ResourceLocation;
1011

@@ -61,7 +62,8 @@ public int render(InlinePatternData data, GuiGraphics drawContext, int index, St
6162
drawContext.pose().pushPose();
6263
drawContext.pose().translate(isGlowy ? -1f : 0, isGlowy ? -1.5f : -0.5f, 0f);
6364
int color = trContext.usableColor();
64-
PatternRenderer.renderPattern(data.pattern, drawContext.pose(), new PatternRenderer.WorldlyBits(drawContext.bufferSource(), trContext.light(), null),
65+
boolean isFlat = InlineRenderer.isFlat(drawContext.pose(), trContext.layerType());
66+
PatternRenderer.renderPattern(data.pattern, drawContext.pose(), !isFlat ? new PatternRenderer.WorldlyBits(drawContext.bufferSource(), trContext.light(), null) : null,
6567
isGlowy ? INLINE_SETTINGS_GLOWY : INLINE_SETTINGS,
6668
isGlowy ? new PatternColors(color, 0xFF_000000 | glowyParentColor) : PatternColors.singleStroke(color),
6769
0, INLINE_TEXTURE_RES);

0 commit comments

Comments
 (0)