-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from BlazingTwist/1.20.1
1.4.0 - allow disable vanilla item counts
- Loading branch information
Showing
8 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/blazingtwist/itemcounts/mixin/DrawContextMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package blazingtwist.itemcounts.mixin; | ||
|
||
import blazingtwist.itemcounts.ItemCounts; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.font.TextRenderer; | ||
import net.minecraft.client.gui.DrawContext; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(DrawContext.class) | ||
public abstract class DrawContextMixin { | ||
|
||
@Redirect( | ||
method = "drawItemInSlot(" + | ||
"Lnet/minecraft/client/font/TextRenderer;" + | ||
"Lnet/minecraft/item/ItemStack;" + | ||
"I" + | ||
"I" + | ||
"Ljava/lang/String;" + | ||
")V", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/gui/DrawContext;" + | ||
"drawText(" + | ||
"Lnet/minecraft/client/font/TextRenderer;" + | ||
"Ljava/lang/String;" + | ||
"I" + | ||
"I" + | ||
"I" + | ||
"Z" + | ||
")I", | ||
remap = false) | ||
) | ||
private int redirectDrawItemSlotText( | ||
DrawContext instance, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow | ||
) { | ||
boolean isCalledFromHotbarRenderItem = ItemCounts.mixin_drawItemCalledFromRenderHotbarItem; | ||
if (ItemCounts.mixin_drawItemCalledFromRenderHotbarItem) { | ||
ItemCounts.mixin_drawItemCalledFromRenderHotbarItem = false; | ||
} | ||
|
||
if (isCalledFromHotbarRenderItem && !ItemCounts.getConfig().show_vanilla_count) { | ||
return 0; | ||
} | ||
|
||
return instance.drawText(textRenderer, text, x, y, color, shadow); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.