This repository has been archived by the owner on May 14, 2022. It is now read-only.
/
NBTTagInteger.java
99 lines (86 loc) · 2.23 KB
/
NBTTagInteger.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
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
/*
* Copyright (C) 2017 The MoonLake Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.minecraft.moonlake.nbt;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
/**
* <h1>NBTTagInteger</h1>
* NBT 标签整数类型数据
*
* @version 1.0
* @author Month_Light
* @see NBTTagNumber
* @see Integer
*/
public class NBTTagInteger extends NBTTagNumber<Integer> {
/**
* NBT 标签整数类型数据构造函数
*/
public NBTTagInteger() {
this(0);
}
/**
* NBT 标签整数类型数据构造函数
*
* @param value 值
*/
public NBTTagInteger(int value) {
this("", value);
}
/**
* NBT 标签整数类型数据构造函数
*
* @param name 特殊名
*/
public NBTTagInteger(String name) {
this(name, 0);
}
/**
* NBT 标签整数类型数据构造函数
*
* @param name 特殊名
* @param value 值
*/
public NBTTagInteger(String name, Integer value) {
super(name, value);
}
/**
* 设置此 NBT 标签整数数据的值
*
* @param value 新值
*/
public void set(int value) {
super.value = value;
}
@Override
public NBTType getType() {
return NBTType.INTEGER;
}
@Override
public void read(DataInput input) throws IOException {
super.value = input.readInt();
}
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(value);
}
@Override
public NBTTagInteger clone() {
return new NBTTagInteger(getName(), value);
}
}