Skip to content

Commit 06e4304

Browse files
committed
Don't add the inventory id to the stack on the client side for recipe output as it will be a different id than actually gets added from the server
1 parent 609b030 commit 06e4304

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

gradle/wrapper/gradle-wrapper.jar

346 Bytes
Binary file not shown.

src/main/java/mekanism/common/lib/inventory/personalstorage/PersonalStorageManager.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,27 @@
2424
import net.minecraft.nbt.Tag;
2525
import net.minecraft.world.item.ItemStack;
2626
import net.minecraftforge.fml.util.thread.EffectiveSide;
27-
import net.minecraftforge.server.ServerLifecycleHooks;
2827
import org.jetbrains.annotations.NotNull;
2928
import org.jetbrains.annotations.Nullable;
3029

3130
@MethodsReturnNonnullByDefault
3231
@ParametersAreNotNullByDefault
3332
public class PersonalStorageManager {
33+
3434
private static final Map<UUID, PersonalStorageData> STORAGE_BY_PLAYER_UUID = new HashMap<>();
3535

3636
private static Optional<PersonalStorageData> forOwner(UUID playerUUID) {
3737
if (EffectiveSide.get().isClient()) {
3838
return Optional.empty();
3939
}
40-
return Optional.of(STORAGE_BY_PLAYER_UUID.computeIfAbsent(playerUUID, uuid->MekanismSavedData.createSavedData(PersonalStorageData::new, "personal_storage" + File.separator + uuid)));
40+
return Optional.of(STORAGE_BY_PLAYER_UUID.computeIfAbsent(playerUUID, uuid -> MekanismSavedData.createSavedData(PersonalStorageData::new, "personal_storage" + File.separator + uuid)));
4141
}
4242

4343
/**
4444
* Only call on the server. Gets or creates an inventory for the supplied stack
4545
*
4646
* @param stack Personal storage ItemStack (type not checked) - will be modified if it didn't have an inventory id
47+
*
4748
* @return the existing or new inventory
4849
*/
4950
public static Optional<AbstractPersonalStorageItemInventory> getInventoryFor(ItemStack stack) {
@@ -53,7 +54,7 @@ public static Optional<AbstractPersonalStorageItemInventory> getInventoryFor(Ite
5354
return Optional.empty();
5455
}
5556
UUID invId = getInventoryId(stack);
56-
return forOwner(owner).map(data->{
57+
return forOwner(owner).map(data -> {
5758
AbstractPersonalStorageItemInventory storageItemInventory = data.getOrAddInventory(invId);
5859
//TODO - After 1.20: Remove legacy loading
5960
ListTag legacyData = ItemDataUtils.getList(stack, NBTConstants.ITEMS);
@@ -73,18 +74,18 @@ public static boolean createInventoryFor(ItemStack stack, List<IInventorySlot> c
7374
return false;
7475
}
7576
//Get a new inventory id
76-
UUID invId = getInventoryId(stack);
77-
forOwner(owner).ifPresent(inv->inv.addInventory(invId, contents));
77+
forOwner(owner).ifPresent(inv -> inv.addInventory(getInventoryId(stack), contents));
7878
return true;
7979
}
8080

8181
/**
8282
* Only call on the server
8383
* <p>
84-
* Version of {@link #getInventoryFor(ItemStack)} which will NOT create an inventory if none exists already.
85-
* The stack will only be modified if it contained a legacy inventory
84+
* Version of {@link #getInventoryFor(ItemStack)} which will NOT create an inventory if none exists already. The stack will only be modified if it contained a legacy
85+
* inventory
8686
*
8787
* @param stack Personal storage ItemStack
88+
*
8889
* @return the existing or converted inventory, or an empty optional if none exists in saved data nor legacy data
8990
*/
9091
public static Optional<AbstractPersonalStorageItemInventory> getInventoryIfPresent(ItemStack stack) {
@@ -99,7 +100,7 @@ public static void deleteInventory(ItemStack stack) {
99100
UUID owner = SecurityUtils.get().getOwnerUUID(stack);
100101
UUID invId = getInventoryIdNullable(stack);
101102
if (owner != null && invId != null) {
102-
forOwner(owner).ifPresent(handler->handler.removeInventory(invId));
103+
forOwner(owner).ifPresent(handler -> handler.removeInventory(invId));
103104
}
104105
}
105106

0 commit comments

Comments
 (0)