IconAbsolute.java
2.88 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.client.util.render;
import com.mumfrey.liteloader.util.render.IconTextured;
import net.minecraft.util.ResourceLocation;
public class IconAbsolute implements IconTextured
{
private ResourceLocation textureResource;
private String displayText;
private int texMapSize = 256;
private int width;
private int height;
private int uPos, vPos;
private float uCoord;
private float uCoord2;
private float vCoord;
private float vCoord2;
public IconAbsolute(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, float uCoord2,
float vCoord2)
{
this(textureResource, displayText, width, height, uCoord, vCoord, uCoord2, vCoord2, 256);
}
public IconAbsolute(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, float uCoord2,
float vCoord2, int texMapSize)
{
this.textureResource = textureResource;
this.displayText = displayText;
this.width = width;
this.height = height;
this.uPos = (int)uCoord;
this.vPos = (int)vCoord;
this.texMapSize = texMapSize;
this.uCoord = uCoord / this.texMapSize;
this.uCoord2 = uCoord2 / this.texMapSize;
this.vCoord = vCoord / this.texMapSize;
this.vCoord2 = vCoord2 / this.texMapSize;
}
@Override
public String getDisplayText()
{
return this.displayText;
}
@Override
public ResourceLocation getTextureResource()
{
return this.textureResource;
}
@Override
public int getIconWidth()
{
return this.width;
}
@Override
public int getIconHeight()
{
return this.height;
}
@Override
public int getUPos()
{
return this.uPos;
}
@Override
public int getVPos()
{
return this.vPos;
}
@Override
public float getMinU()
{
return this.uCoord;
}
@Override
public float getMaxU()
{
return this.uCoord2 - Float.MIN_VALUE;
}
@Override
public float getInterpolatedU(double slice)
{
float uSize = this.uCoord2 - this.uCoord;
return this.uCoord + uSize * ((float)slice / 16.0F) - Float.MIN_VALUE;
}
@Override
public float getMinV()
{
return this.vCoord;
}
@Override
public float getMaxV()
{
return this.vCoord2 - Float.MIN_VALUE;
}
@Override
public float getInterpolatedV(double slice)
{
float vSize = this.vCoord2 - this.vCoord;
return this.vCoord + vSize * ((float)slice / 16.0F) - Float.MIN_VALUE;
}
@Override
public String getIconName()
{
return this.displayText;
}
}