Blackhome

Storage_Exceptions

Jan 29th, 2026 (edited)
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.56 KB | Gaming | 0 0
  1.     -- pastebin get BKmw3WTx StorageExceptions
  2.     local SE = {}
  3.  
  4.     SE.DISPLAYNAMES = {
  5.         ["minecraft:quartz"] = "Nether Quartz",
  6.         ["minecraft:dragon_breath"] = "Dragon's Breath",
  7.         ["minecraft:porkchop"] = "Raw Porkchop",
  8.         ["minecraft:cod"] = "Raw Cod",
  9.         ["minecraft:chicken"] = "Raw Chicken",
  10.         ["minecraft:copper_block"] = "Block of Copper",
  11.         ["minecraft:raw_copper_block"] = "Block of Raw Copper",
  12.         ["minecraft:slime_ball"] = "Slimeball",
  13.         ["minecraft:amethyst_block"] = "Block of Amethyst",
  14.         ["minecraft:cooked_beef"] = "Steak",
  15.         ["minecraft:redstone"] = "Redstone Dust",
  16.         ["minecraft:redstone_block"] = "Block of Redstone",
  17.         ["minecraft:lapis_block"] = "Block of Lapis Lazuli",
  18.         ["minecraft:raw_iron_block"] = "Block of Raw Iron",
  19.         ["minecraft:diamond_block"] = "Block of Diamond",
  20.         ["minecraft:raw_gold_block"] = "Block of Raw Gold",
  21.         ["minecraft:gold_block"] = "Block of Gold",
  22.         ["minecraft:emerald_block"] = "Block of Emerald",
  23.         ["minecraft:iron_block"] = "Block of Iron",
  24.         ["minecraft:quartz_block"] = "Block of Quartz",
  25.         ["minecraft:tnt"] = "TNT",
  26.         ["minecraft:rabbit"] = "Raw Rabbit",
  27.         ["minecraft:deepslate_lapis_ore"] = "Deepslate Lapis Lazuli Ore",
  28.         ["minecraft:lapis_ore"] = "Lapis Lazuli Ore",
  29.         ["minecraft:waxed_copper_block"] = "Waxed Block of Copper",
  30.         ["minecraft:rib_armor_trim_smithing_template"] = "Rib Armor Trim",
  31.         ["minecraft:snout_armor_trim_smithing_template"] = "Snout Armor Trim",
  32.         ["minecraft:dune_armor_trim_smithing_template"] = "Dune Armor Trim",
  33.         ["minecraft:spire_armor_trim_smithing_template"] = "Spire Armor Trim",
  34.         ["minecraft:netherite_upgrade_smithing_template"] = "Netherite Upgrade",
  35.         ["minecraft:experience_bottle"] = "Bottle o' Enchanting",
  36.         ["minecraft:disc_fragment_5"] = "Disc Fragment",
  37.         ["minecraft:pale_oak_chest_boat"] = "Pale Oak Boat with Chest",
  38.         ["minecraft:mangrove_chest_boat"] = "Mangrove Boat with Chest",
  39.         ["minecraft:chest_minecart"] = "Minecart with Chest",
  40.         ["minecraft:cod_bucket"] = "Bucket of Cod",
  41.         ["minecraft:leather_helmet"] = "Leather Cap",
  42.         ["minecraft:leather_chestplate"] = "Leather Tunic",
  43.         ["minecraft:leather_leggings"] = "Leather Pants",
  44.         ["minecraft:flint_and_steel"] = "Flint and Steel",
  45.         ["minecraft:tropical_fish_bucket"] = "Bucket of Tropical Fish",
  46.  
  47.         -- Füge weitere Ausnahmen hier hinzu
  48.     }
  49.  
  50.     SE.SPECIAL_ITEMS = {
  51.         ["minecraft:white_banner"] = "Ominous Banner",
  52.         ["minecraft:tipped_arrow"] = {"Arrow of Splashing", "Arrow of Night Vision", "Arrow of Invisibility",
  53.                                 "Arrow of Leaping", "Arrow of Fire Resistance", "Arrow of Swiftness",
  54.                                 "Arrow of Slowness", "Arrow of the Turtle Master", "Arrow of Water Breathing",
  55.                                 "Arrow of Healing", "Arrow of Harming", "Arrow of Poison", "Arrow of Regeneration",
  56.                                 "Arrow of Strength", "Arrow of Weakness", "Arrow of Luck", "Arrow of Slow Falling",
  57.                                 "Arrow of Wind Charging", "Arrow of Weaving", "Arrow of Oozing", "Arrow of Infestation",
  58.                                 },
  59.         ["minecraft:potion"] = { "Water Bottle", "Mundane Potion", "Thick Potion", "Awkward Potion",
  60.                                 "Potion of Night Vision", "Potion of Invisibility", "Potion of Leaping",
  61.                                 "Potion of Fire Resistance", "Potion of Swiftness", "Potion of Slowness",
  62.                                 "Potion of the Turtle Master", "Potion of Water Breathing", "Potion of Healing",
  63.                                 "Potion of Harming", "Potion of Poison", "Potion of Regeneration", "Potion of Strength",
  64.                                 "Potion of Weakness", "Potion of Luck", "Potion of Slow Falling",
  65.                                 "Potion of Wind Charging", "Potion of Weaving", "Potion of Oozing",
  66.                                 "Potion of Infestation" },
  67.         ["minecraft:splash_potion"] = { "Splash Water Bottle", "Mundane Splash Potion", "Thick Splash Potion",
  68.                                 "Awkward Splash Potion", "Splash Potion of Night Vision", "Splash Potion of Invisibility",
  69.                                 "Splash Potion of Leaping", "Splash Potion of Fire Resistance", "Splash Potion of Swiftness",
  70.                                 "Splash Potion of Slowness", "Splash Potion of the Turtle Master", "Splash Potion of Water Breathing",
  71.                                 "Splash Potion of Healing", "Splash Potion of Harming", "Splash Potion of Poison",
  72.                                 "Splash Potion of Regeneration", "Splash Potion of Strength", "Splash Potion of Weakness",
  73.                                 "Splash Potion of Luck", "Splash Potion of Slow Falling", "Splash Potion of Wind Charging",
  74.                                 "Splash Potion of Weaving", "Splash Potion of Oozing", "Splash Potion of Infestation" },
  75.         ["minecraft:lingering_potion"] = { "Lingering Water Bottle", "Mundane Lingering Potion", "Thick Lingering Potion",
  76.                                 "Awkward Lingering Potion", "Lingering Potion of Night Vision", "Lingering Potion of Invisibility",
  77.                                 "Lingering Potion of Leaping", "Lingering Potion of Fire Resistance", "Lingering Potion of Swiftness",
  78.                                 "Lingering Potion of Slowness", "Lingering Potion of the Turtle Master", "Lingering Potion of Water Breathing",
  79.                                 "Lingering Potion of Healing", "Lingering Potion of Harming", "Lingering Potion of Poison",
  80.                                 "Lingering Potion of Regeneration", "Lingering Potion of Strength", "Lingering Potion of Weakness",
  81.                                 "Lingering Potion of Luck", "Lingering Potion of Slow Falling", "Lingering Potion of Wind Charging",
  82.                                 "Lingering Potion of Weaving", "Lingering Potion of Oozing", "Lingering Potion of Infestation" },
  83.     }
  84.  
  85.     SE.MULTIPLE_NAMES = {
  86.         ["Music Disc"] = { "minecraft:music_disc_5", "minecraft:music_disc_11", "minecraft:music_disc_13",
  87.                     "minecraft:music_disc_otherside", "minecraft:music_disc_lava_chicken", "minecraft:music_disc_tears",
  88.                     "minecraft:music_disc_pigstep", "minecraft:music_disc_relic", "minecraft:music_disc_precipice",
  89.                     "minecraft:music_disc_creator", "minecraft:music_disc_wait", "minecraft:music_disc_creator_music_box",
  90.                     "minecraft:music_disc_ward", "minecraft:music_disc_strad", "minecraft:music_disc_stal", "minecraft:music_disc_mellohi",
  91.                     "minecraft:music_disc_mall", "minecraft:music_disc_", "minecraft:music_disc_far", "minecraft:music_disc_chirp",
  92.                     "minecraft:music_disc_blocks", "minecraft:music_disc_cat", },
  93.     }
  94.  
  95.     SE.STACKSIZE = {
  96.         ["minecraft:written_book"] = 1,
  97.         ["computercraft:computer_advanced"] = 1,
  98.         ["minecraft:ominous_bottle"] = 16,
  99.     }
  100.  
  101.     SE.SPECIAL_PROPERTIES = {
  102.         ["minecraft:enchanted_book"] = true
  103.     }
  104.  
  105.     SE.MODS = {
  106.         ["computercraft:disk_drive"] = 15
  107.     }
  108.  
  109.     local function nameInList(name, list)
  110.         if not list then return nil, nil end
  111.         if type(list) == "string" then return name == list, list end
  112.  
  113.         for _, k in ipairs(list) do
  114.             if k == name then return true, k end
  115.         end
  116.         return false, nil
  117.     end
  118.  
  119.     local function isDefaultDisplayName(item)
  120.         if not item or not item.name or not item.displayName then
  121.             return false
  122.         end
  123.  
  124.         -- Prüfe auf Ausnahmeliste
  125.         local exception = SE.DISPLAYNAMES[item.name]
  126.         if exception then
  127.             return item.displayName == exception
  128.         end
  129.  
  130.         local id = item.name:match("^[^:]+:(.+)$") -- Teil nach dem Doppelpunkt
  131.         if not id then return false end
  132.  
  133.         -- Ersetze Unterstriche durch Leerzeichen und kapitalisiere Wörter
  134.         local function toDisplayFormat(str)
  135.             local words = {}
  136.             for word in string.gmatch(str, "[^_]+") do
  137.                 table.insert(words, word:sub(1,1):upper() .. word:sub(2))
  138.             end
  139.             return table.concat(words, " ")
  140.         end
  141.  
  142.         local expectedDisplay = toDisplayFormat(id)
  143.         return item.displayName == expectedDisplay
  144.     end
  145.     local function getDefaultDisplayName(itemName)
  146.         if not itemName then return nil end
  147.  
  148.         -- Extrahiere den Teil nach dem Doppelpunkt (z. B. "stone_axe")
  149.         local id = itemName:match("^[^:]+:(.+)$")
  150.         if not id then return nil end
  151.  
  152.         -- Ersetze Unterstriche durch Leerzeichen und kapitalisiere jedes Wort
  153.         local words = {}
  154.         for word in string.gmatch(id, "[^_]+") do
  155.             table.insert(words, word:sub(1,1):upper() .. word:sub(2))
  156.         end
  157.  
  158.         return table.concat(words, " ")
  159.     end
  160.  
  161.     local function isMinecraftItem(item)
  162.         return item and type(item.name) == "string" and item.name:sub(1, 10) == "minecraft:"
  163.     end
  164.  
  165.     function SE.getItemInfo(itemDetail)
  166.         if not itemDetail or not itemDetail.name or not itemDetail.count or not itemDetail.maxCount or not itemDetail.displayName then
  167.             return nil
  168.         end
  169.         local itemException, kName = nameInList(itemDetail.displayName, SE.SPECIAL_ITEMS[itemDetail.name])
  170.         if itemException then
  171.             local newName = "minecraft:" .. kName:lower():gsub(" ", "_")
  172.             local itemInfo = {
  173.                 name = newName, dName = kName,
  174.                 stackSize = itemDetail.maxCount, number = itemDetail.count
  175.             }
  176.             return itemInfo
  177.         end
  178.  
  179.         local itemException, mcName = nameInList(itemDetail.name, SE.MULTIPLE_NAMES[itemDetail.displayName])
  180.         if itemException then
  181.             local newDName = getDefaultDisplayName(mcName)
  182.             local itemInfo = {
  183.                 name = mcName, dName = newDName,
  184.                 stackSize = itemDetail.maxCount, number = itemDetail.count
  185.             }
  186.             return itemInfo
  187.         end
  188.  
  189.         local sizeException = SE.STACKSIZE[itemDetail.name]
  190.         if sizeException then
  191.             if sizeException == 1 or isDefaultDisplayName(itemDetail) then
  192.                 local itemInfo = {
  193.                     name = itemDetail.name, dName = itemDetail.displayName,
  194.                     stackSize = sizeException, number = itemDetail.count
  195.                 }
  196.                 if itemDetail.name == "minecraft:written_book" then
  197.                     itemInfo.dName = "Written Book"
  198.                 end
  199.                
  200.                 return itemInfo
  201.             end
  202.         end
  203.  
  204.         local propException = SE.SPECIAL_PROPERTIES[itemDetail.name]
  205.         if propException then
  206.             if itemDetail.name == "minecraft:enchanted_book" then
  207.                 local enchantments = itemDetail.enchantments
  208.                 local itemInfo = {
  209.                     name = itemDetail.name, dName = itemDetail.displayName,
  210.                     stackSize = itemDetail.maxCount, number = itemDetail.count
  211.                 }
  212.                 if #enchantments > 1 then
  213.                     return itemInfo
  214.                 end
  215.                 local enchantment1 = enchantments[1]
  216.                 if isDefaultDisplayName(enchantment1) then
  217.                     itemInfo.name = enchantment1.name
  218.                 else
  219.                     itemInfo.name = enchantment1.name .. "_" .. tostring(enchantment1.level)
  220.                 end
  221.                 itemInfo.dName = enchantment1.displayName
  222.                 return itemInfo
  223.             end
  224.         end
  225.  
  226.         local modException = SE.MODS[itemDetail.name]
  227.         if modException and isDefaultDisplayName(itemDetail) then
  228.             local itemInfo = {
  229.                 name = itemDetail.name, dName = itemDetail.displayName,
  230.                 stackSize = itemDetail.maxCount, number = itemDetail.count
  231.             }
  232.             return itemInfo
  233.         end
  234.  
  235.         if not isMinecraftItem(itemDetail) then
  236.             return nil
  237.         end
  238.  
  239.  
  240.         if isDefaultDisplayName(itemDetail) then
  241.             local itemInfo = {
  242.                 name = itemDetail.name, dName = itemDetail.displayName,
  243.                 stackSize = itemDetail.maxCount, number = itemDetail.count
  244.             }
  245.             return itemInfo
  246.         end
  247.         print("ELSE")
  248.         return nil
  249.     end
  250.  
  251.  
  252.     return SE
Advertisement
Add Comment
Please, Sign In to add comment