blob: 746485581b8c8777165d6d1e199dce8bc2dd7997 (
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
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
|
#pragma once
/*
class WrittenBookItem extends Item {
public static final int TITLE_LENGTH = 16;
public static final int PAGE_LENGTH = 256;
public static final int MAX_PAGES = 50;
public static final String TAG_TITLE = "title";
public static final String TAG_AUTHOR = "author";
public static final String TAG_PAGES = "pages";
public WrittenBookItem(int id) {
super(id);
setMaxStackSize(1);
}
public static boolean makeSureTagIsValid(CompoundTag bookTag) {
if (!WritingBookItem.makeSureTagIsValid(bookTag)) {
return false;
}
if (!bookTag.contains(TAG_TITLE)) {
return false;
}
String title = bookTag.getString(TAG_TITLE);
if (title == null || title.length() > TITLE_LENGTH) {
return false;
}
if (!bookTag.contains(TAG_AUTHOR)) {
return false;
}
return true;
}
@Override
public String getHoverName(ItemInstance itemInstance) {
if (itemInstance.hasTag()) {
CompoundTag itemTag = itemInstance.getTag();
StringTag titleTag = (StringTag) itemTag.get(TAG_TITLE);
if (titleTag != null) {
return titleTag.toString();
}
}
return super.getHoverName(itemInstance);
}
@Override
public void appendHoverText(ItemInstance itemInstance, Player player, List<String> lines, boolean advanced) {
if (itemInstance.hasTag()) {
CompoundTag itemTag = itemInstance.getTag();
StringTag authorTag = (StringTag) itemTag.get(TAG_AUTHOR);
if (authorTag != null) {
lines.add(ChatFormatting.GRAY + String.format(I18n.get("book.byAuthor", authorTag.data)));
}
}
}
@Override
public ItemInstance use(ItemInstance itemInstance, Level level, Player player) {
player.openItemInstanceGui(itemInstance);
return itemInstance;
}
@Override
public boolean shouldOverrideMultiplayerNBT() {
return true;
}
@Override
public boolean isFoil(ItemInstance itemInstance) {
return true;
}
};
*/
|