/
DrawableAnimated.java
60 lines (50 loc) · 1.39 KB
/
DrawableAnimated.java
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
package mezz.jei.gui;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.ITickTimer;
import net.minecraft.client.Minecraft;
public class DrawableAnimated implements IDrawableAnimated {
private final IDrawableStatic drawable;
private final ITickTimer tickTimer;
private final StartDirection startDirection;
public DrawableAnimated(IDrawableStatic drawable, ITickTimer tickTimer, StartDirection startDirection) {
this.drawable = drawable;
this.tickTimer = tickTimer;
this.startDirection = startDirection;
}
@Override
public int getWidth() {
return drawable.getWidth();
}
@Override
public int getHeight() {
return drawable.getHeight();
}
@Override
public void draw(Minecraft minecraft) {
draw(minecraft, 0, 0);
}
@Override
public void draw(Minecraft minecraft, int xOffset, int yOffset) {
int maskLeft = 0;
int maskRight = 0;
int maskTop = 0;
int maskBottom = 0;
int animationValue = tickTimer.getValue();
switch (startDirection) {
case TOP:
maskBottom = animationValue;
break;
case BOTTOM:
maskTop = animationValue;
break;
case LEFT:
maskRight = animationValue;
break;
case RIGHT:
maskLeft = animationValue;
break;
}
drawable.draw(minecraft, xOffset, yOffset, maskTop, maskBottom, maskLeft, maskRight);
}
}