-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
BlockInfo.java
35 lines (31 loc) · 1.07 KB
/
BlockInfo.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
package nallar.tickthreading.util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class BlockInfo {
public final int id;
public final int meta;
public final Block type;
public final String name;
public BlockInfo(final int id, final int meta) {
this.id = id;
this.meta = meta;
Block type;
this.type = type = Block.blocksList[id];
Item item = type == null ? null : Item.itemsList[id];
ItemStack itemType = item == null ? null : new ItemStack(id, 1, meta);
String name = itemType == null ? (type == null ? "unknown" : type.getLocalizedName()) : item.getItemDisplayName(itemType);
String preTranslateName = "item." + name;
String localizedName = StatCollector.translateToLocal(preTranslateName);
//noinspection StringEquality
if (localizedName != null && localizedName != preTranslateName) {
name = localizedName;
}
this.name = name;
}
@Override
public String toString() {
return id + ':' + meta + ", " + name;
}
}