Skip to content

Commit

Permalink
fix: update the player inventory after attempting to clean nbt leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
CamperSamu committed Dec 22, 2023
1 parent 75ce5ca commit 7dd2b59
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/campersamu/shoutout/mixin/CleanNbtFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@
import static net.minecraft.text.Text.literal;

@Mixin(ServerPlayerInteractionManager.class)
public class CleanNbtFix {
public abstract class CleanNbtFix {
@Shadow
@Final
protected ServerPlayerEntity player;

@Inject(method = "setGameMode", at = @At("RETURN"))
protected void setGameMode(GameMode gameMode, GameMode previousGameMode, CallbackInfo ci) {
for (ItemStack itemStack : player.getInventory().main) {
final var inventory = player.getInventory();
for (ItemStack itemStack : inventory.main) {
cleanNbt(itemStack);
}
cleanNbt(player.getInventory().offHand.get(0));
for (ItemStack itemStack : player.getInventory().armor) {
cleanNbt(inventory.offHand.get(0));
for (ItemStack itemStack : inventory.armor) {
cleanNbt(itemStack);
}
player.getInventory().markDirty();
}

@Unique
Expand Down

0 comments on commit 7dd2b59

Please sign in to comment.