aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hype/bbsentials/mixins/ItemRendererMixin.java
blob: d0d32909b2c9ccec6f9c8a3d8ce99611aafbcf96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package de.hype.bbsentials.mixins;

import de.hype.bbsentials.chat.Chat;
import de.hype.bbsentials.client.BBsentials;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ItemRenderer.class)
public class ItemRendererMixin {
    @Shadow
    @Final
    private MinecraftClient client;

    @Inject(method = "renderItem", at = @At("HEAD"), cancellable = true)
    private void renderItemMixin(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) {
        if (BBsentials.config.highlightitem) {
            setCustomName(stack, BBsentials.bbserver.getItemName());
        }
    }

    @Unique
    private void setCustomName(ItemStack stack, String triggerName) {
        String temp = stack.getName().getString();
        if ((!temp.contains("Splash")) && temp.contains(triggerName)) {
            String tem2 = stack.getNbt().getString("Display");
            Chat.sendPrivateMessageToSelf(tem2);
            stack.setCustomName(Text.literal("§6(Bingo Splash) " + temp));
        }
    }
}