Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari023 committed Jan 5, 2025
1 parent 10483e7 commit a7a3702
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/java/de/mari_023/ae2wtlib/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
package de.mari_023.ae2wtlib.mixin;

import appeng.util.ReadableNumberConverter;
import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
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.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

import appeng.util.ReadableNumberConverter;

import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler;

@Mixin(Gui.class)
public class GuiMixin {
@Final
@Shadow
private Minecraft minecraft;

@Inject(method = "renderSlot(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/client/DeltaTracker;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;renderItemDecorations(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V"), cancellable = true)
public void restockOverlay(GuiGraphics guiGraphics, int x, int y, DeltaTracker deltaTracker, Player player, ItemStack stack, int seed, CallbackInfo ci) {
public void restockOverlay(GuiGraphics guiGraphics, int x, int y, DeltaTracker deltaTracker, Player player,
ItemStack stack, int seed, CallbackInfo ci) {
if (Minecraft.getInstance().player == null || Minecraft.getInstance().player.isCreative())
return;
CraftingTerminalHandler handler = CraftingTerminalHandler
.getCraftingTerminalHandler(Minecraft.getInstance().player);
if (!handler.isRestockEnabled() || stack.getCount() == 1 || !handler.isRestockAble(stack))
return;
guiGraphics.renderItemDecorations(minecraft.font, stack, x, y, ReadableNumberConverter.format(handler.getAccessibleAmount(stack), 3));
guiGraphics.renderItemDecorations(minecraft.font, stack, x, y,
ReadableNumberConverter.format(handler.getAccessibleAmount(stack), 3));
ci.cancel();
}
}

0 comments on commit a7a3702

Please sign in to comment.