fix sophisticated backpack integration for 1.20.4

This commit is contained in:
EoD 2025-05-04 16:42:44 +00:00
parent 9eb8bdc4a0
commit 22b628bdcb

View File

@ -99,10 +99,12 @@ public class ModsSupport {
// --- Begin Backpack Data Restore --- // --- Begin Backpack Data Restore ---
PlayerSync.LOGGER.info("Restoring backpack data for player " + player.getUUID()); PlayerSync.LOGGER.info("Restoring backpack data for player " + player.getUUID());
net.p3pp3rf1y.sophisticatedbackpacks.util.PlayerInventoryProvider.get().runOnBackpacks(player, (ItemStack backpackItem, String handler, String identifier, int slot) -> { net.p3pp3rf1y.sophisticatedbackpacks.util.PlayerInventoryProvider.get().runOnBackpacks(player, (ItemStack backpackItem, String handler, String identifier, int slot) -> {
backpackItem.getCapability(net.p3pp3rf1y.sophisticatedbackpacks.api.CapabilityBackpackWrapper.getCapabilityInstance()) net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.IBackpackWrapper backpackWrapper = net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackWrapper
.ifPresent(wrapper -> { .fromData(backpackItem);
// Retrieve the contents UUID from the backpack's NBT using NBTHelper // Retrieve the contents UUID from the backpack's NBT using NBTHelper
Optional<UUID> uuidOpt = net.p3pp3rf1y.sophisticatedcore.util.NBTHelper.getUniqueId(wrapper.getBackpack(), "contentsUuid"); Optional<UUID> uuidOpt = net.p3pp3rf1y.sophisticatedcore.util.NBTHelper
.getUniqueId(backpackWrapper.getBackpack(), "contentsUuid");
if (uuidOpt.isPresent()) { if (uuidOpt.isPresent()) {
UUID contentsUuid = uuidOpt.get(); UUID contentsUuid = uuidOpt.get();
try { try {
@ -126,7 +128,6 @@ public class ModsSupport {
} else { } else {
PlayerSync.LOGGER.warn("Backpack item in slot " + slot + " has no contentsUuid during restore"); PlayerSync.LOGGER.warn("Backpack item in slot " + slot + " has no contentsUuid during restore");
} }
});
return false; return false;
}); });
// --- End Backpack Data Restore --- // --- End Backpack Data Restore ---
@ -172,10 +173,12 @@ public class ModsSupport {
public static void storeSophisticatedBackpacks(Player player) { public static void storeSophisticatedBackpacks(Player player) {
PlayerSync.LOGGER.info("Storing backpack data for player " + player.getUUID()); PlayerSync.LOGGER.info("Storing backpack data for player " + player.getUUID());
net.p3pp3rf1y.sophisticatedbackpacks.util.PlayerInventoryProvider.get().runOnBackpacks(player, (ItemStack backpackItem, String handler, String identifier, int slot) -> { net.p3pp3rf1y.sophisticatedbackpacks.util.PlayerInventoryProvider.get().runOnBackpacks(player, (ItemStack backpackItem, String handler, String identifier, int slot) -> {
backpackItem.getCapability(net.p3pp3rf1y.sophisticatedbackpacks.api.CapabilityBackpackWrapper.getCapabilityInstance()) net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.IBackpackWrapper backpackWrapper = net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackWrapper
.ifPresent(wrapper -> { .fromData(backpackItem);
// Retrieve the contents UUID from the backpack's NBT using NBTHelper // Retrieve the contents UUID from the backpack's NBT using NBTHelper
Optional<UUID> uuidOpt = net.p3pp3rf1y.sophisticatedcore.util.NBTHelper.getUniqueId(wrapper.getBackpack(), "contentsUuid"); Optional<UUID> uuidOpt = net.p3pp3rf1y.sophisticatedcore.util.NBTHelper
.getUniqueId(backpackWrapper.getBackpack(), "contentsUuid");
if (uuidOpt.isPresent()) { if (uuidOpt.isPresent()) {
UUID contentsUuid = uuidOpt.get(); UUID contentsUuid = uuidOpt.get();
// Get internal backpack data from BackpackStorage (creates it if missing) // Get internal backpack data from BackpackStorage (creates it if missing)
@ -191,7 +194,6 @@ public class ModsSupport {
} else { } else {
PlayerSync.LOGGER.warn("Backpack item in slot " + slot + " has no contentsUuid"); PlayerSync.LOGGER.warn("Backpack item in slot " + slot + " has no contentsUuid");
} }
});
return false; // Continue processing all backpack items. return false; // Continue processing all backpack items.
}); });
} }