Skip to content

Commit

Permalink
feat: add highlights to remnant items
Browse files Browse the repository at this point in the history
  • Loading branch information
AsoDesu committed Dec 19, 2023
1 parent 51770ab commit 090ca54
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.asodev.islandutils.mixins.crafting;

import net.asodev.islandutils.state.MccIslandState;
import net.asodev.islandutils.util.Utils;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FastColor;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(AbstractContainerScreen.class)
public class RemnantHighlightMixin {

@Inject(method = "renderSlot", at = @At("HEAD"))
private void renderSlot(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) {
if (!MccIslandState.isOnline()) return;
if (!slot.hasItem()) return;

List<Component> lore = Utils.getLores(slot.getItem());
if (lore == null) return;
boolean isRemnant = lore.stream().anyMatch(c -> c.getString().contains("This item is the remnant of an item"));
if (!isRemnant) return;

int x = slot.x;
int y = slot.y;
int color = FastColor.ARGB32.color(255, 141, 65, 100);
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(0.0f, 0.0f, 105.0f);
guiGraphics.fill(RenderType.gui(), x, y, x + 16, y + 16, 0, color);
guiGraphics.pose().popPose();
}

}
1 change: 1 addition & 0 deletions src/main/resources/islandutils.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"accessors.SoundManagerAccessor",
"cosmetics.UIMixin",
"crafting.CraftingPacketMixin",
"crafting.RemnantHighlightMixin",
"crafting.ScavengingScreenMixin",
"discord.JoinMCCIMixin",
"network.PacketListenerMixin",
Expand Down

0 comments on commit 090ca54

Please sign in to comment.