Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package vazkii.patchouli.mixin.client;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.world.inventory.Slot;
import vazkii.patchouli.client.handler.TooltipHandler;

@Mixin(AbstractContainerScreen.class)
public class MixinAbstractContainerScreen{

@Shadow
Slot hoveredSlot;

@Inject(at = @At("HEAD"), method = "renderTooltip(Lnet/minecraft/client/gui/GuiGraphics;II)V")
public void patchouli_onRenderTooltip(GuiGraphics guiGraphics, int x, int y, CallbackInfo info) {
if (((AbstractContainerScreen) (Object) this).getMenu().getCarried().isEmpty() && hoveredSlot != null && hoveredSlot.hasItem()) {
TooltipHandler.onTooltip(guiGraphics, this.hoveredSlot.getItem(), x, y);
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion Fabric/src/main/resources/patchouli_fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"client": [
"client.MixinGameRenderer",
"client.MixinMinecraft",
"client.MixinGuiGraphics"
"client.MixinAbstractContainerScreen"
],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package vazkii.patchouli.client.handler;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.datafixers.util.Pair;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -59,34 +57,45 @@ public static void onTooltip(GuiGraphics graphics, ItemStack stack, int mouseX,
int x = tooltipX - 34;
RenderSystem.disableDepthTest();

graphics.fill(x - 4, tooltipY - 4, x + 20, tooltipY + 26, 0x44000000);
graphics.fill(x - 6, tooltipY - 6, x + 22, tooltipY + 28, 0x44000000);
graphics.fill(RenderType.guiOverlay(),x - 4, tooltipY - 4, x + 20, tooltipY + 26, 0x44000000);
graphics.fill(RenderType.guiOverlay(),x - 6, tooltipY - 6, x + 22, tooltipY + 28, 0x44000000);

if (PatchouliConfig.get().useShiftForQuickLookup() ? Screen.hasShiftDown() : Screen.hasControlDown()) {
lexiconLookupTime += ClientTicker.delta;

int cx = x + 8;
int cy = tooltipY + 8;
float r = 12;
float requiredTime = PatchouliConfig.get().quickLookupTime();
float angles = lexiconLookupTime / requiredTime * 360F;
float requiredTime = Math.max(PatchouliConfig.get().quickLookupTime(),0);
float angles = Math.min(lexiconLookupTime / (requiredTime>1F?requiredTime-1F:requiredTime),1F) * 360F;

RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

BufferBuilder buf = Tesselator.getInstance().getBuilder();
buf.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
final float a = 0.5F + 0.2F * ((float) Math.cos(ClientTicker.total / 10) * 0.5F + 0.5F);

float a = 0.5F + 0.2F * ((float) Math.cos(ClientTicker.total / 10) * 0.5F + 0.5F);
buf.vertex(cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex();
VertexConsumer buf = graphics.bufferSource().getBuffer(RenderType.guiOverlay());
final double PI_mul = Math.PI/ 180F;
for (float i = 1 ; i < angles; i+=2) { //to render in guiOverlay buffer [has DrawMode.QUAD]
float ti=i-90;
buf.vertex( cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex();//base vertex
double rad = ti-- * PI_mul; buf.vertex(cx + Math.cos(rad) * r,cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
rad = ti-- * PI_mul; buf.vertex(cx + Math.cos(rad) * r,cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
rad = ti * PI_mul; buf.vertex(cx + Math.cos(rad) * r,cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
}
graphics.flush();

/*BufferBuilder buf = Tesselator.getInstance().getBuilder();
buf.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
buf.vertex(cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex();
for (float i = angles; i > 0; i--) {
double rad = (i - 90) / 180F * Math.PI;
buf.vertex(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
}

buf.vertex(cx, cy, 0).color(0F, 1F, 0F, 0F).endVertex();
Tesselator.getInstance().end();
Tesselator.getInstance().end();*/


RenderSystem.disableBlend();

Expand Down