diff --git a/gradle.properties b/gradle.properties index 0e524bfb..34c7c9ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.22.2 +mod_version=3.22.3 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java index 2ff6c86f..f5ab3409 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java @@ -12,12 +12,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.ItemContainerContents; import net.minecraft.world.level.Level; -import net.neoforged.fml.util.thread.SidedThreadGroups; import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem; -import net.neoforged.neoforge.server.ServerLifecycleHooks; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedbackpacks.api.IEnergyStorageUpgradeWrapper; import net.p3pp3rf1y.sophisticatedbackpacks.api.IFluidHandlerWrapperUpgrade; @@ -174,9 +172,6 @@ private void markBackpackContentsDirty() { public ITrackedContentsItemHandler getInventoryForInputOutput() { if (inventoryIOHandler == null) { inventoryIOHandler = new InventoryIOHandler(this); - if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER && ServerLifecycleHooks.getCurrentServer() != null) { - fillWithLoot(ServerLifecycleHooks.getCurrentServer().overworld(), BlockPos.ZERO); - } } return inventoryIOHandler.getFilteredItemHandler(); } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java index 6d4a4a4d..723997f4 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java @@ -35,6 +35,7 @@ import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import net.neoforged.neoforge.common.extensions.IMenuTypeExtension; import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.items.wrapper.EmptyItemHandler; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; @@ -378,7 +379,10 @@ public static void registerCauldronInteractions() { } private static void registerCapabilities(RegisterCapabilitiesEvent event) { - event.registerItem(Capabilities.ItemHandler.ITEM, (stack, v) -> BackpackWrapper.fromStack(stack).getInventoryForInputOutput(), + event.registerItem(Capabilities.ItemHandler.ITEM, (stack, v) -> { + IBackpackWrapper backpackWrapper = BackpackWrapper.fromStack(stack); + return backpackWrapper.getContentsUuid().isEmpty() ? EmptyItemHandler.INSTANCE : backpackWrapper.getInventoryForInputOutput(); + }, BACKPACK.get(), COPPER_BACKPACK.get(), IRON_BACKPACK.get(), GOLD_BACKPACK.get(), DIAMOND_BACKPACK.get(), NETHERITE_BACKPACK.get()); event.registerItem(Capabilities.FluidHandler.ITEM, (stack, v) -> { if (Boolean.FALSE.equals(Config.SERVER.itemFluidHandlerEnabled.get())) {