@@ -115,21 +115,26 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit
115
115
tryCollect (world , player , be );
116
116
}
117
117
}
118
-
118
+
119
119
@ Override
120
120
public ItemStack getPickStack (WorldView world , BlockPos pos , BlockState state ) {
121
-
121
+
122
122
BlockEntity entity = world .getBlockEntity (pos );
123
123
if (world .isClient () && entity instanceof ShardBlockEntity shardEntity ) {
124
124
Identifier shardId = shardEntity .getShardId ();
125
125
ShardLibrary library = ScatteredShardsAPI .getClientLibrary ();
126
+
127
+ if (shardId == null || library == null ) {
128
+ return super .getPickStack (world , pos , state );
129
+ }
130
+
126
131
return createShardBlock (library , shardId , shardEntity .canInteract (), shardEntity .getGlowSize (), shardEntity .getGlowStrength ());
127
132
} else {
128
-
133
+
129
134
return super .getPickStack (world , pos , state );
130
135
}
131
136
}
132
-
137
+
133
138
/**
134
139
* Creates a shard block
135
140
*
@@ -165,10 +170,10 @@ public static ItemStack createShardBlock(ShardLibrary library, Identifier shardI
165
170
166
171
return stack;*/
167
172
}
168
-
173
+
169
174
public static ItemStack createShardBlock (ShardType shardType , Identifier shardId , Shard shard , boolean canInteract , float glowSize , float glowStrength ) {
170
175
ItemStack stack = new ItemStack (ScatteredShardsContent .SHARD_BLOCK );
171
-
176
+
172
177
NbtCompound blockEntityTag = new NbtCompound ();
173
178
blockEntityTag .putString ("id" , ScatteredShardsContent .SHARD_BLOCK_ID .toString ()); // required, see NbtComponent.CODEC_WITH_ID
174
179
blockEntityTag .putString ("Shard" , shardId .toString ());
0 commit comments