Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patchItemSave clears all inventories on world save #57

Open
Ampflower opened this issue Dec 27, 2021 · 1 comment
Open

patchItemSave clears all inventories on world save #57

Ampflower opened this issue Dec 27, 2021 · 1 comment

Comments

@Ampflower
Copy link
Collaborator

Ampflower commented Dec 27, 2021

Description

The configuration, patchItemSave, clears all items from the world on either manual save (i.e. pausing the world on the client, or running /save-all on the server), or periodically by the auto-save timer.

Steps to reproduce.

  1. /save-all, pause the game (client only), or wait for the auto-save timer. This may also apply when you stop and start the world on the client due to the potential of two save rounds occurring, one for pause, and one for server shutdown.
  2. Notice how all items and inventories that stayed after the save round has disappeared, or has been emptied.

Cause

Line 26, this.setCount(0)

@Inject(method = "writeNbt(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtCompound;", at = @At("HEAD"), cancellable = true)
private void writeStack(NbtCompound nbt, CallbackInfoReturnable<NbtCompound> cir) {
if(golfConfig.duplication.patchItemSave) {
ItemStack copy = ((ItemStack) (Object) this).copy();
this.setCount(0);
Identifier identifier = Registry.ITEM.getId(copy.getItem());
nbt.putString("id", identifier.toString());
nbt.putByte("Count", (byte)copy.getCount());
if (copy.getNbt() != null) {
nbt.put("tag", copy.getNbt().copy());
}
cir.setReturnValue(nbt);
}
}

Current Workarounds

Disable patchItemSave by setting the value in the config to false.

Possible fixes

  • Call the alternative save function when the inventory is known to be destroyed right after. This would include going through a portal or going into unloaded chunks.
@samolego
Copy link
Owner

I'm pretty sure I meant to implement this as if inventory would be destroyed afterwards, as you've mentioned in Possible fixes. I'll release a version without this as it's clearly not the intended thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants