Skip to content

Commit

Permalink
fix: Only write BalmData if we actually have data #73
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Feb 16, 2024
1 parent 59c52d8 commit 818b578
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ private void load(CompoundTag compound, CallbackInfo callbackInfo) {

@Inject(method = "saveWithoutId(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;", at = @At("HEAD"))
private void saveWithoutId(CompoundTag compound, CallbackInfoReturnable<CompoundTag> callbackInfo) {
compound.put("BalmData", balmData);
if (!balmData.isEmpty()) {
compound.put("BalmData", balmData);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ public CompoundTag getPersistentData(Entity entity) {
}

CompoundTag balmData = persistentData.getCompound("BalmData");
if (balmData.size() == 0) {
if (balmData.isEmpty()) {
// If we have no data, try to import from Fabric in case the world was migrated
balmData = ((BalmEntity) entity).getFabricBalmData();
}
persistentData.put("BalmData", balmData);
if (!balmData.isEmpty()) {
persistentData.put("BalmData", balmData);
}

return balmData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private void load(CompoundTag compound, CallbackInfo callbackInfo) {

@Inject(method = "saveWithoutId(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;", at = @At("HEAD"))
private void saveWithoutId(CompoundTag compound, CallbackInfoReturnable<CompoundTag> callbackInfo) {
compound.put("BalmData", fabricBalmData);
if (!fabricBalmData.isEmpty()) {
compound.put("BalmData", fabricBalmData);
}
}

@Override
Expand Down

0 comments on commit 818b578

Please sign in to comment.