Skip to content

Commit

Permalink
Don't try to tint items that have foil
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Oct 30, 2024
1 parent 1dae4b0 commit a5509aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.NonNullList;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
Expand Down Expand Up @@ -227,6 +228,11 @@ private static void renderItem(
float redTint, float greenTint, float blueTint, float alphaTint
) {
if (!stack.isEmpty()) {
// Our tinting doesn't support foil since uses a combined vertex consumer
if (stack.hasFoil()) {
stack.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, false);
}

RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
Expand Down Expand Up @@ -264,7 +270,12 @@ private static void renderItem(
Lighting.setupFor3DItems();
}
} catch (Throwable throwable) {
LoggerFactory.getLogger(GameCraftingBeeHandler.class).error("error", throwable);
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item");
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered");
crashreportcategory.setDetail("Item Type", () -> String.valueOf(stack.getItem()));
crashreportcategory.setDetail("Item Components", () -> String.valueOf(stack.getComponents()));
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(stack.hasFoil()));
throw new ReportedException(crashreport);
}

graphics.pose().popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void register(IGamePhase game, EventRegistrar events) throws GameExceptio

events.listen(GamePhaseEvents.START, this::start);
events.listen(GamePhaseEvents.TICK, () -> tickRunning(game));
events.listen(GamePhaseEvents.DESTROY, () -> bars.values().forEach(b -> b.bar().close()));
events.listen(GamePhaseEvents.STOP, reason -> bars.values().forEach(b -> b.bar().close()));

events.listen(GamePlayerEvents.CRAFT, this::onCraft);
Expand Down

0 comments on commit a5509aa

Please sign in to comment.