Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/net/f3rr3/reshaped/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@
import net.f3rr3.reshaped.client.gui.RadialMenuScreen;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.GraphicsMode;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;

import java.util.List;

public class ClientTickHandler {
private static GraphicsMode lastGraphicsMode;

public static void register() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player == null || client.world == null) return;

GraphicsMode currentMode = MinecraftClient.getInstance().options.getGraphicsMode().getValue();
if (lastGraphicsMode != currentMode) {
lastGraphicsMode = currentMode;
ReshapedClient.refreshVariantRenderLayers();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move render-layer remap out of in-world tick

ReshapedClient.refreshVariantRenderLayers() is now called from END_CLIENT_TICK after client.world is non-null, which means it remaps blocks via BlockRenderLayerMap.putBlock while a world is already loaded. Fabric’s BlockRenderLayerMap contract requires these mappings to be done before world load/rendering, so changing graphics mode in-game can trigger unsupported remaps that lead to renderer-dependent glitches or instability instead of a safe layer update.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you setup an issue about this?

}

// If a screen is already open, we don't need to do anything here
// The RadialMenuScreen itself handles closing if the key is released
if (client.currentScreen != null) return;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/f3rr3/reshaped/client/ReshapedClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static Set<Integer> getMatrixGroupSizes() {
return sizes;
}

private static void registerVariantRenderLayers() {
public static void refreshVariantRenderLayers() {
if (Reshaped.MATRIX == null) return;

// Mixed blocks can contain any material (including translucent ones like glass),
Expand All @@ -59,7 +59,6 @@ private static void registerVariantRenderLayers() {
for (Map.Entry<Block, List<Block>> entry : Reshaped.MATRIX.getMatrix().entrySet()) {
Block baseBlock = entry.getKey();
RenderLayer baseLayer = RenderLayers.getBlockLayer(baseBlock.getDefaultState());
if (baseLayer == RenderLayer.getSolid()) continue;

for (Block variant : entry.getValue()) {
BlockRenderLayerMap.INSTANCE.putBlock(variant, baseLayer);
Expand Down Expand Up @@ -121,7 +120,7 @@ public void reload(ResourceManager manager) {
}
});

registerVariantRenderLayers();
refreshVariantRenderLayers();
registerVariantColorProviders();
}

Expand Down
Loading
Loading