Events.OnInitGlobalModData.Add(function()
	if SandboxVars.PompsItems.ZombieLoot then
		--List of food items to spawn
		local PIzombiefood = {"PompsItems.Pomps", "PompsItems.Brawndo", "PompsItems.PIRootBeer", "PompsItems.POreo", "PompsItems.POreoVanilla", "PompsItems.TaterSticks", "PompsItems.Tartsies", "PompsItems.SourGummies", "PompsItems.GummyBearsPacket", "PompsItems.PIGummyWorms", "PompsItems.BittersBar", "PompsItems.BittersBrownie", "PompsItems.Tangsy", "PompsItems.GummySharks", "PompsItems.UtahWaferPack", "PompsItems.TwistysRed", "PompsItems.TwistysBlack", "PompsItems.PIJellyBeans", "PompsItems.CircusPeanuts", "PompsItems.TastyTarts", "PompsItems.Dabs", "PompsItems.Sunbooms", "PompsItems.SunboomsTropical", "PompsItems.CocoGlee", "PompsItems.GooberBar", "PompsItems.PIFigBar", "PompsItems.PISportsDrinkGrape", "PompsItems.PISportsDrinkBlue", "PompsItems.PISportsDrinkFruit", "PompsItems.PISportsDrinkLemonade", "PompsItems.PISportsDrinkLime", "PompsItems.PISportsDrinkOrange", "PompsItems.RMRootBeer", "PompsItems.LugRootBeer", "PompsItems.PICheeseBallsSmall", "PompsItems.PISpiffoSquish", "PompsItems.PIBRBarrel", "PompsItems.PIGreenBarrel", "PompsItems.PIPurpleBarrel", "PompsItems.PIRedBarrel", "PompsItems.PIFishSnackems", "PompsItems.PIGeeks", "PompsItems.PICandyCigarettes", "PompsItems.PICandyCigarettes2", "PompsItems.PIPushPopBlue", "PompsItems.PIPushPopRed", "PompsItems.PIRingPopBlue", "PompsItems.PIRingPopRed", "PompsItems.PIRingPopPurple", "PompsItems.PIRingPopGreen", "PompsItems.PIRingPopFancy", "PompsItems.PIPopRocksBlue", "PompsItems.PIPopRocksGreen", "PompsItems.PIPopRocksRed", "PompsItems.PIJavaCrunch", "PompsItems.PITix", "PompsItems.PIElChips", "PompsItems.PICannedRavioli", "PompsItems.PIABCSoup", "PompsItems.PIClamChowder", "PompsItems.PISpaghettiOs", "PompsItems.PIHoneyBun", "PompsItems.PIPopTartBS", "PompsItems.PIPopTartSW", "PompsItems.PIPopTartSM", "PompsItems.PIPopTartCC", "PompsItems.PIPopTartWB", "PompsItems.PIPopTartCH", "PompsItems.PIPopTartBB", "PompsItems.PIMilkMolars", "PompsItems.PIMacBeef", "PompsItems.PICannedMacCheese", "PompsItems.PIJawbreaker", "PompsItems.PIWormholes", "PompsItems.PIHotChachas", "PompsItems.PIIceCaps", "PompsItems.MoneyChoc", "PompsItems.PIPowderDonut", "PompsItems.PIChocDonut", "PompsItems.PISWDonut", "PompsItems.PIGlazeDonut", "PompsItems.PIPompsBig", "PompsItems.PIFruitSpillers", "PompsItems.PISkyDullards", "PompsItems.PIHeadHonchoChew", "PompsItems.PIDiamondCola", "PompsItems.PIBottledUnsweetTea", "PompsItems.PIBottledTeaSweet", "PompsItems.PIBottledTeaLemon", "PompsItems.PIBottledTeaRaspberry", "PompsItems.PIBottledTeaExtraSweet", "PompsItems.PIBottledTeaPeach", "PompsItems.PIBottledTeaGreenTea", "PompsItems.PISparklingWater", "PompsItems.PIIslandChips", "PompsItems.PIFizzyFazOrange", "PompsItems.PIFizzyFazPinkLemonade", "PompsItems.PIFizzyFazSourLime", "PompsItems.PIFizzyFazGrape", "PompsItems.PIWillysWonderlandPunch", "PompsItems.PIDrDoctor", "PompsItems.PIVeggieDrank", "PompsItems.PISchoolMilkChocolate", "PompsItems.PISchoolMilkStrawberry", "PompsItems.PISchoolMilkRegular", "PompsItems.PIFireball", "PompsItems.PIJaguarsPoofy", "PompsItems.PIJaguarsCrunchy", "PompsItems.PIJaguarsFlaming", "PompsItems.PICheeseStickDip", "PompsItems.PIBagOfDisappointment", "PompsItems.PIBonnieBites", "PompsItems.PIPiratePlunderbar", "PompsItems.PILemonChica", "PompsItems.PIFreddyFudgebar", "PompsItems.PIFazbar", "PompsItems.PIGummyFrogs"}


		---Replaces an item in a container with a random item from the item list.
		---@param container ItemContainer
		local function replacePImysteryFood(container)
 		   local dummies = container:getAllType("PompsItems.PIMysteryFoodIcon") -- dummy item type
 		   for i = 0, dummies:size()-1 do
    		    container:Remove(dummies:get(i))
    		    local itemChoice = ZombRand(#PIzombiefood)+1
    		    local item = container:AddItem(PIzombiefood[itemChoice])
    		    container:addItemOnServer(item)
			end
		end

		-- for items in containers
		local function onFillContainer(_roomName, _containerType, container)
			--for some reason, the container object passed is sometimes not actually a container object
			--this is a quick and simple way to check (even if tostring maybe isnt the most optimal to call so often)
			if tostring(container):sub(1, 13) ~= "ItemContainer" then return end;
		    replacePImysteryFood(container);
		end

		Events.OnFillContainer.Add(onFillContainer)


		-- for items found on zombies
		local function onRefreshInventoryWindowContainers(inventoryPage)
		    if not inventoryPage.inventory or not instanceof(inventoryPage.inventory:getParent(), "IsoDeadBody") then return end
			--print("WindowContainerUpdate: ", inventoryPage.inventory);
		    replacePImysteryFood(inventoryPage.inventory)
		end


		Events.OnRefreshInventoryWindowContainers.Add(onRefreshInventoryWindowContainers)


		function SetPompfoodDistributionData()
			print("-----------PIzombieFoodDistribution----------")
			-- Define a table to store the distribution data	
			local PIfoodZombieDistributionData = {
				{ location = "inventorymale", weight = 2.7 },
				{ location = "inventoryfemale", weight = 2.7 },
			}

			for _, data in ipairs(PIfoodZombieDistributionData) do
				if SuburbsDistributions["all"][data.location] then
					local list = SuburbsDistributions["all"][data.location].items
					table.insert(list, "PompsItems.PIMysteryFoodIcon")
					table.insert(list, data.weight * SandboxVars.PompsItems.ZombieLootSpawnRate)
				else
					print("Warning: No items list found for location " .. data.location)
				end
			end
	
			--idk what this is, i saw another mod do it.
			ItemPickerJava.Parse()
		end

		Events.OnInitGlobalModData.Add(function()
			SetPompfoodDistributionData();
		end)
	end
end)