File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/main/java/cn/nukkit/item Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 12
12
import cn .nukkit .math .BlockFace ;
13
13
import cn .nukkit .math .Vector3 ;
14
14
import cn .nukkit .nbt .NBTIO ;
15
+ import cn .nukkit .nbt .tag .ByteTag ;
15
16
import cn .nukkit .nbt .tag .CompoundTag ;
16
17
import cn .nukkit .nbt .tag .IntTag ;
17
18
import cn .nukkit .nbt .tag .ListTag ;
@@ -1008,7 +1009,28 @@ public int getToughness() {
1008
1009
}
1009
1010
1010
1011
public boolean isUnbreakable () {
1011
- return false ;
1012
+ if (!(this instanceof ItemDurable )) {
1013
+ return false ;
1014
+ }
1015
+
1016
+ Tag tag = this .getNamedTagEntry ("Unbreakable" );
1017
+ return tag instanceof ByteTag && ((ByteTag ) tag ).data > 0 ;
1018
+ }
1019
+
1020
+ public Item setUnbreakable (boolean value ) {
1021
+ if (!(this instanceof ItemDurable )) {
1022
+ return this ;
1023
+ }
1024
+
1025
+ CompoundTag tag = this .getNamedTag ();
1026
+ if (tag == null ) tag = new CompoundTag ();
1027
+
1028
+ this .setNamedTag (tag .putByte ("Unbreakable" , value ? 1 : 0 ));
1029
+ return this ;
1030
+ }
1031
+
1032
+ public Item setUnbreakable () {
1033
+ return this .setUnbreakable (true );
1012
1034
}
1013
1035
1014
1036
public boolean onUse (Player player , int ticksUsed ) {
You can’t perform that action at this time.
0 commit comments