Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get BKmw3WTx StorageExceptions
- local SE = {}
- SE.DISPLAYNAMES = {
- ["minecraft:quartz"] = "Nether Quartz",
- ["minecraft:dragon_breath"] = "Dragon's Breath",
- ["minecraft:porkchop"] = "Raw Porkchop",
- ["minecraft:cod"] = "Raw Cod",
- ["minecraft:chicken"] = "Raw Chicken",
- ["minecraft:copper_block"] = "Block of Copper",
- ["minecraft:raw_copper_block"] = "Block of Raw Copper",
- ["minecraft:slime_ball"] = "Slimeball",
- ["minecraft:amethyst_block"] = "Block of Amethyst",
- ["minecraft:cooked_beef"] = "Steak",
- ["minecraft:redstone"] = "Redstone Dust",
- ["minecraft:redstone_block"] = "Block of Redstone",
- ["minecraft:lapis_block"] = "Block of Lapis Lazuli",
- ["minecraft:raw_iron_block"] = "Block of Raw Iron",
- ["minecraft:diamond_block"] = "Block of Diamond",
- ["minecraft:raw_gold_block"] = "Block of Raw Gold",
- ["minecraft:gold_block"] = "Block of Gold",
- ["minecraft:emerald_block"] = "Block of Emerald",
- ["minecraft:iron_block"] = "Block of Iron",
- ["minecraft:quartz_block"] = "Block of Quartz",
- ["minecraft:tnt"] = "TNT",
- ["minecraft:rabbit"] = "Raw Rabbit",
- ["minecraft:deepslate_lapis_ore"] = "Deepslate Lapis Lazuli Ore",
- ["minecraft:lapis_ore"] = "Lapis Lazuli Ore",
- ["minecraft:waxed_copper_block"] = "Waxed Block of Copper",
- ["minecraft:rib_armor_trim_smithing_template"] = "Rib Armor Trim",
- ["minecraft:snout_armor_trim_smithing_template"] = "Snout Armor Trim",
- ["minecraft:dune_armor_trim_smithing_template"] = "Dune Armor Trim",
- ["minecraft:spire_armor_trim_smithing_template"] = "Spire Armor Trim",
- ["minecraft:netherite_upgrade_smithing_template"] = "Netherite Upgrade",
- ["minecraft:experience_bottle"] = "Bottle o' Enchanting",
- ["minecraft:disc_fragment_5"] = "Disc Fragment",
- ["minecraft:pale_oak_chest_boat"] = "Pale Oak Boat with Chest",
- ["minecraft:mangrove_chest_boat"] = "Mangrove Boat with Chest",
- ["minecraft:chest_minecart"] = "Minecart with Chest",
- ["minecraft:cod_bucket"] = "Bucket of Cod",
- ["minecraft:leather_helmet"] = "Leather Cap",
- ["minecraft:leather_chestplate"] = "Leather Tunic",
- ["minecraft:leather_leggings"] = "Leather Pants",
- ["minecraft:flint_and_steel"] = "Flint and Steel",
- ["minecraft:tropical_fish_bucket"] = "Bucket of Tropical Fish",
- -- Füge weitere Ausnahmen hier hinzu
- }
- SE.SPECIAL_ITEMS = {
- ["minecraft:white_banner"] = "Ominous Banner",
- ["minecraft:tipped_arrow"] = {"Arrow of Splashing", "Arrow of Night Vision", "Arrow of Invisibility",
- "Arrow of Leaping", "Arrow of Fire Resistance", "Arrow of Swiftness",
- "Arrow of Slowness", "Arrow of the Turtle Master", "Arrow of Water Breathing",
- "Arrow of Healing", "Arrow of Harming", "Arrow of Poison", "Arrow of Regeneration",
- "Arrow of Strength", "Arrow of Weakness", "Arrow of Luck", "Arrow of Slow Falling",
- "Arrow of Wind Charging", "Arrow of Weaving", "Arrow of Oozing", "Arrow of Infestation",
- },
- ["minecraft:potion"] = { "Water Bottle", "Mundane Potion", "Thick Potion", "Awkward Potion",
- "Potion of Night Vision", "Potion of Invisibility", "Potion of Leaping",
- "Potion of Fire Resistance", "Potion of Swiftness", "Potion of Slowness",
- "Potion of the Turtle Master", "Potion of Water Breathing", "Potion of Healing",
- "Potion of Harming", "Potion of Poison", "Potion of Regeneration", "Potion of Strength",
- "Potion of Weakness", "Potion of Luck", "Potion of Slow Falling",
- "Potion of Wind Charging", "Potion of Weaving", "Potion of Oozing",
- "Potion of Infestation" },
- ["minecraft:splash_potion"] = { "Splash Water Bottle", "Mundane Splash Potion", "Thick Splash Potion",
- "Awkward Splash Potion", "Splash Potion of Night Vision", "Splash Potion of Invisibility",
- "Splash Potion of Leaping", "Splash Potion of Fire Resistance", "Splash Potion of Swiftness",
- "Splash Potion of Slowness", "Splash Potion of the Turtle Master", "Splash Potion of Water Breathing",
- "Splash Potion of Healing", "Splash Potion of Harming", "Splash Potion of Poison",
- "Splash Potion of Regeneration", "Splash Potion of Strength", "Splash Potion of Weakness",
- "Splash Potion of Luck", "Splash Potion of Slow Falling", "Splash Potion of Wind Charging",
- "Splash Potion of Weaving", "Splash Potion of Oozing", "Splash Potion of Infestation" },
- ["minecraft:lingering_potion"] = { "Lingering Water Bottle", "Mundane Lingering Potion", "Thick Lingering Potion",
- "Awkward Lingering Potion", "Lingering Potion of Night Vision", "Lingering Potion of Invisibility",
- "Lingering Potion of Leaping", "Lingering Potion of Fire Resistance", "Lingering Potion of Swiftness",
- "Lingering Potion of Slowness", "Lingering Potion of the Turtle Master", "Lingering Potion of Water Breathing",
- "Lingering Potion of Healing", "Lingering Potion of Harming", "Lingering Potion of Poison",
- "Lingering Potion of Regeneration", "Lingering Potion of Strength", "Lingering Potion of Weakness",
- "Lingering Potion of Luck", "Lingering Potion of Slow Falling", "Lingering Potion of Wind Charging",
- "Lingering Potion of Weaving", "Lingering Potion of Oozing", "Lingering Potion of Infestation" },
- }
- SE.MULTIPLE_NAMES = {
- ["Music Disc"] = { "minecraft:music_disc_5", "minecraft:music_disc_11", "minecraft:music_disc_13",
- "minecraft:music_disc_otherside", "minecraft:music_disc_lava_chicken", "minecraft:music_disc_tears",
- "minecraft:music_disc_pigstep", "minecraft:music_disc_relic", "minecraft:music_disc_precipice",
- "minecraft:music_disc_creator", "minecraft:music_disc_wait", "minecraft:music_disc_creator_music_box",
- "minecraft:music_disc_ward", "minecraft:music_disc_strad", "minecraft:music_disc_stal", "minecraft:music_disc_mellohi",
- "minecraft:music_disc_mall", "minecraft:music_disc_", "minecraft:music_disc_far", "minecraft:music_disc_chirp",
- "minecraft:music_disc_blocks", "minecraft:music_disc_cat", },
- }
- SE.STACKSIZE = {
- ["minecraft:written_book"] = 1,
- ["computercraft:computer_advanced"] = 1,
- ["minecraft:ominous_bottle"] = 16,
- }
- SE.SPECIAL_PROPERTIES = {
- ["minecraft:enchanted_book"] = true
- }
- SE.MODS = {
- ["computercraft:disk_drive"] = 15
- }
- local function nameInList(name, list)
- if not list then return nil, nil end
- if type(list) == "string" then return name == list, list end
- for _, k in ipairs(list) do
- if k == name then return true, k end
- end
- return false, nil
- end
- local function isDefaultDisplayName(item)
- if not item or not item.name or not item.displayName then
- return false
- end
- -- Prüfe auf Ausnahmeliste
- local exception = SE.DISPLAYNAMES[item.name]
- if exception then
- return item.displayName == exception
- end
- local id = item.name:match("^[^:]+:(.+)$") -- Teil nach dem Doppelpunkt
- if not id then return false end
- -- Ersetze Unterstriche durch Leerzeichen und kapitalisiere Wörter
- local function toDisplayFormat(str)
- local words = {}
- for word in string.gmatch(str, "[^_]+") do
- table.insert(words, word:sub(1,1):upper() .. word:sub(2))
- end
- return table.concat(words, " ")
- end
- local expectedDisplay = toDisplayFormat(id)
- return item.displayName == expectedDisplay
- end
- local function getDefaultDisplayName(itemName)
- if not itemName then return nil end
- -- Extrahiere den Teil nach dem Doppelpunkt (z. B. "stone_axe")
- local id = itemName:match("^[^:]+:(.+)$")
- if not id then return nil end
- -- Ersetze Unterstriche durch Leerzeichen und kapitalisiere jedes Wort
- local words = {}
- for word in string.gmatch(id, "[^_]+") do
- table.insert(words, word:sub(1,1):upper() .. word:sub(2))
- end
- return table.concat(words, " ")
- end
- local function isMinecraftItem(item)
- return item and type(item.name) == "string" and item.name:sub(1, 10) == "minecraft:"
- end
- function SE.getItemInfo(itemDetail)
- if not itemDetail or not itemDetail.name or not itemDetail.count or not itemDetail.maxCount or not itemDetail.displayName then
- return nil
- end
- local itemException, kName = nameInList(itemDetail.displayName, SE.SPECIAL_ITEMS[itemDetail.name])
- if itemException then
- local newName = "minecraft:" .. kName:lower():gsub(" ", "_")
- local itemInfo = {
- name = newName, dName = kName,
- stackSize = itemDetail.maxCount, number = itemDetail.count
- }
- return itemInfo
- end
- local itemException, mcName = nameInList(itemDetail.name, SE.MULTIPLE_NAMES[itemDetail.displayName])
- if itemException then
- local newDName = getDefaultDisplayName(mcName)
- local itemInfo = {
- name = mcName, dName = newDName,
- stackSize = itemDetail.maxCount, number = itemDetail.count
- }
- return itemInfo
- end
- local sizeException = SE.STACKSIZE[itemDetail.name]
- if sizeException then
- if sizeException == 1 or isDefaultDisplayName(itemDetail) then
- local itemInfo = {
- name = itemDetail.name, dName = itemDetail.displayName,
- stackSize = sizeException, number = itemDetail.count
- }
- if itemDetail.name == "minecraft:written_book" then
- itemInfo.dName = "Written Book"
- end
- return itemInfo
- end
- end
- local propException = SE.SPECIAL_PROPERTIES[itemDetail.name]
- if propException then
- if itemDetail.name == "minecraft:enchanted_book" then
- local enchantments = itemDetail.enchantments
- local itemInfo = {
- name = itemDetail.name, dName = itemDetail.displayName,
- stackSize = itemDetail.maxCount, number = itemDetail.count
- }
- if #enchantments > 1 then
- return itemInfo
- end
- local enchantment1 = enchantments[1]
- if isDefaultDisplayName(enchantment1) then
- itemInfo.name = enchantment1.name
- else
- itemInfo.name = enchantment1.name .. "_" .. tostring(enchantment1.level)
- end
- itemInfo.dName = enchantment1.displayName
- return itemInfo
- end
- end
- local modException = SE.MODS[itemDetail.name]
- if modException and isDefaultDisplayName(itemDetail) then
- local itemInfo = {
- name = itemDetail.name, dName = itemDetail.displayName,
- stackSize = itemDetail.maxCount, number = itemDetail.count
- }
- return itemInfo
- end
- if not isMinecraftItem(itemDetail) then
- return nil
- end
- if isDefaultDisplayName(itemDetail) then
- local itemInfo = {
- name = itemDetail.name, dName = itemDetail.displayName,
- stackSize = itemDetail.maxCount, number = itemDetail.count
- }
- return itemInfo
- end
- print("ELSE")
- return nil
- end
- return SE
Advertisement
Add Comment
Please, Sign In to add comment