Skip to content

Commit

Permalink
fix atlas and sprite bar scissoring
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Dec 5, 2024
1 parent 042a315 commit 7727d33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import mcp.mobius.waila.api.data.FluidData.FluidDescriptionContext;
import mcp.mobius.waila.api.data.FluidData.FluidDescriptor;
import net.minecraft.client.Minecraft;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions;
import net.neoforged.neoforge.fluids.FluidStack;
Expand All @@ -20,7 +20,7 @@ public void describeFluid(FluidDescriptionContext<Fluid> ctx, FluidDescription d
var extensions = IClientFluidTypeExtensions.of(type);

desc.name(type.getDescription(stack))
.sprite(Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(extensions.getStillTexture(stack)))
.sprite(Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(extensions.getStillTexture(stack)))
.tint(extensions.getTintColor(stack));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ public void render(GuiGraphics ctx, int x, int y, DeltaTracker delta) {

BarComponent.renderBar(matrices, x, y, BarComponent.WIDTH, BarComponent.V0_BG, BarComponent.U1, BarComponent.V1_BG, 0xFFAAAAAA);

var mx = (int) (x + BarComponent.WIDTH * ratio);
var my = y + BarComponent.HEIGHT;
ctx.enableScissor(x + 1, y + 1, mx - 1, my - 1);

matrices.pushPose();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR);
RenderSystem.setShaderTexture(0, texture);

var mx = (int) (x + BarComponent.WIDTH * ratio);
var my = y + BarComponent.HEIGHT;

ctx.enableScissor(x + 1, y + 1, mx - 1, my - 1);

var a = WailaHelper.getAlpha(spriteTint);
var r = WailaHelper.getRed(spriteTint);
var g = WailaHelper.getGreen(spriteTint);
Expand Down

0 comments on commit 7727d33

Please sign in to comment.