File size: 3,299 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package net.minecraft.client.gui.components;

import javax.annotation.Nullable;
import net.minecraft.client.gui.ComponentPath;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public abstract class ImageWidget extends AbstractWidget {
    ImageWidget(int p_275550_, int p_275723_, int p_301266_, int p_297426_) {
        super(p_275550_, p_275723_, p_301266_, p_297426_, CommonComponents.EMPTY);
    }

    public static ImageWidget texture(int p_298293_, int p_301221_, ResourceLocation p_299739_, int p_297694_, int p_300459_) {
        return new ImageWidget.Texture(0, 0, p_298293_, p_301221_, p_299739_, p_297694_, p_300459_);
    }

    public static ImageWidget sprite(int p_299633_, int p_299377_, ResourceLocation p_298615_) {
        return new ImageWidget.Sprite(0, 0, p_299633_, p_299377_, p_298615_);
    }

    @Override
    protected void updateWidgetNarration(NarrationElementOutput p_275454_) {
    }

    @Override
    public void playDownSound(SoundManager p_297959_) {
    }

    @Override
    public boolean isActive() {
        return false;
    }

    @Nullable
    @Override
    public ComponentPath nextFocusPath(FocusNavigationEvent p_298071_) {
        return null;
    }

    @OnlyIn(Dist.CLIENT)
    static class Sprite extends ImageWidget {
        private final ResourceLocation sprite;

        public Sprite(int p_299930_, int p_297218_, int p_298462_, int p_297563_, ResourceLocation p_299269_) {
            super(p_299930_, p_297218_, p_298462_, p_297563_);
            this.sprite = p_299269_;
        }

        @Override
        public void renderWidget(GuiGraphics p_298082_, int p_297761_, int p_298881_, float p_300382_) {
            p_298082_.blitSprite(RenderType::guiTextured, this.sprite, this.getX(), this.getY(), this.getWidth(), this.getHeight());
        }
    }

    @OnlyIn(Dist.CLIENT)
    static class Texture extends ImageWidget {
        private final ResourceLocation texture;
        private final int textureWidth;
        private final int textureHeight;

        public Texture(int p_299083_, int p_301299_, int p_299901_, int p_299822_, ResourceLocation p_299550_, int p_298841_, int p_297816_) {
            super(p_299083_, p_301299_, p_299901_, p_299822_);
            this.texture = p_299550_;
            this.textureWidth = p_298841_;
            this.textureHeight = p_297816_;
        }

        @Override
        protected void renderWidget(GuiGraphics p_301123_, int p_301197_, int p_299250_, float p_300781_) {
            p_301123_.blit(
                RenderType::guiTextured,
                this.texture,
                this.getX(),
                this.getY(),
                0.0F,
                0.0F,
                this.getWidth(),
                this.getHeight(),
                this.textureWidth,
                this.textureHeight
            );
        }
    }
}