16
16
import net .minecraftforge .registries .ForgeRegistries ;
17
17
18
18
import vazkii .akashictome .network .MessageUnmorphTome ;
19
- import vazkii .arl . util . ItemNBTHelper ;
19
+ import vazkii .akashictome . network . NetworkHandler ;
20
20
21
21
import java .util .HashMap ;
22
22
import java .util .Locale ;
@@ -36,8 +36,8 @@ public final class MorphingHandler {
36
36
@ SubscribeEvent
37
37
public void onPlayerLeftClick (PlayerInteractEvent .LeftClickEmpty event ) {
38
38
ItemStack stack = event .getItemStack ();
39
- if (!stack .isEmpty () && isAkashicTome (stack ) && stack .getItem () != ModItems . tome ) {
40
- AkashicTome .sendToServer (new MessageUnmorphTome ());
39
+ if (!stack .isEmpty () && isAkashicTome (stack ) && ! stack .is ( Registries . TOME . get ()) ) {
40
+ NetworkHandler .sendToServer (new MessageUnmorphTome ());
41
41
}
42
42
}
43
43
@@ -48,9 +48,9 @@ public void onItemDropped(ItemTossEvent event) {
48
48
49
49
ItemEntity e = event .getEntity ();
50
50
ItemStack stack = e .getItem ();
51
- if (!stack .isEmpty () && isAkashicTome (stack ) && stack .getItem () != ModItems . tome ) {
51
+ if (!stack .isEmpty () && isAkashicTome (stack ) && ! stack .is ( Registries . TOME . get ()) ) {
52
52
CompoundTag morphData = stack .getTag ().getCompound (TAG_TOME_DATA ).copy ();
53
- String currentMod = ItemNBTHelper .getString (stack , TAG_ITEM_DEFINED_MOD , getModFromStack (stack ));
53
+ String currentMod = NBTUtils .getString (stack , TAG_ITEM_DEFINED_MOD , getModFromStack (stack ));
54
54
55
55
ItemStack morph = makeMorphedStack (stack , MINECRAFT , morphData );
56
56
CompoundTag newMorphData = morph .getTag ().getCompound (TAG_TOME_DATA );
@@ -98,7 +98,7 @@ public static String getModOrAlias(String mod) {
98
98
return aliases .getOrDefault (mod , mod );
99
99
}
100
100
101
- public static boolean doesStackHaveModAttached (ItemStack stack , String mod ) {
101
+ public static boolean doesStackHaveModAttached (ItemStack stack , String mod ) { //TODO what was this used for?
102
102
if (!stack .hasTag ())
103
103
return false ;
104
104
@@ -111,7 +111,7 @@ public static ItemStack getShiftStackForMod(ItemStack stack, String mod) {
111
111
return stack ;
112
112
113
113
String currentMod = getModFromStack (stack );
114
- String defined = ItemNBTHelper .getString (stack , TAG_ITEM_DEFINED_MOD , "" );
114
+ String defined = NBTUtils .getString (stack , TAG_ITEM_DEFINED_MOD , "" );
115
115
if (!defined .isEmpty ())
116
116
currentMod = defined ;
117
117
@@ -124,7 +124,7 @@ public static ItemStack getShiftStackForMod(ItemStack stack, String mod) {
124
124
125
125
public static ItemStack makeMorphedStack (ItemStack currentStack , String targetMod , CompoundTag morphData ) {
126
126
String currentMod = getModFromStack (currentStack );
127
- String defined = ItemNBTHelper .getString (currentStack , TAG_ITEM_DEFINED_MOD , "" );
127
+ String defined = NBTUtils .getString (currentStack , TAG_ITEM_DEFINED_MOD , "" );
128
128
if (!defined .isEmpty ())
129
129
currentMod = defined ;
130
130
@@ -139,14 +139,14 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo
139
139
140
140
ItemStack stack ;
141
141
if (targetMod .equals (MINECRAFT ))
142
- stack = new ItemStack (ModItems . tome );
142
+ stack = new ItemStack (Registries . TOME . get () );
143
143
else {
144
144
CompoundTag targetCmp = morphData .getCompound (targetMod );
145
145
morphData .remove (targetMod );
146
146
147
147
stack = ItemStack .of (targetCmp );
148
148
if (stack .isEmpty ())
149
- stack = new ItemStack (ModItems . tome );
149
+ stack = new ItemStack (Registries . TOME . get () );
150
150
}
151
151
152
152
if (!stack .hasTag ())
@@ -156,7 +156,7 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo
156
156
stackCmp .put (TAG_TOME_DATA , morphData );
157
157
stackCmp .putBoolean (TAG_MORPHING , true );
158
158
159
- if (stack .getItem () != ModItems . tome ) {
159
+ if (! stack .is ( Registries . TOME . get ()) ) {
160
160
CompoundTag displayName = new CompoundTag ();
161
161
CompoundTag ogDisplayName = displayName ;
162
162
displayName .putString ("text" , Component .Serializer .toJson (stack .getHoverName ()));
@@ -166,6 +166,7 @@ public static ItemStack makeMorphedStack(ItemStack currentStack, String targetMo
166
166
else
167
167
stackCmp .put (TAG_TOME_DISPLAY_NAME , displayName );
168
168
169
+
169
170
MutableComponent rawComp = Component .Serializer .fromJson (displayName .getString ("text" ));
170
171
if (rawComp == null ) {
171
172
stackCmp .put (TAG_TOME_DISPLAY_NAME , displayName );
@@ -197,7 +198,7 @@ public static boolean isAkashicTome(ItemStack stack) {
197
198
if (stack .isEmpty ())
198
199
return false ;
199
200
200
- if (stack .getItem () == ModItems . tome )
201
+ if (stack .is ( Registries . TOME . get ()) )
201
202
return true ;
202
203
203
204
return stack .hasTag () && stack .getTag ().getBoolean (TAG_MORPHING );
0 commit comments