If anybody needs it

Discussion in 'Bukkit Discussion' started by Lamp, Jan 13, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Lamp

    I took the time to write a script that grabs the current data value list from minewiki and creates a mysql table from those values.

    Here's the current table:

    Code:
    --
    CREATE TABLE IF NOT EXISTS `data_values` (
      `id` int(11) NOT NULL,
      `name` varchar(46) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    INSERT INTO `data_values` (`id`, `name`) VALUES
    (0, 'Air'),
    (1, 'Stone'),
    (2, 'Grass'),
    (3, 'Dirt'),
    (4, 'Cobblestone'),
    (5, 'Wooden Plank'),
    (6, 'Sapling'),
    (7, 'Bedrock'),
    (8, 'Water'),
    (9, 'Stationary water'),
    (10, 'Lava'),
    (11, 'Stationary lava'),
    (12, 'Sand'),
    (13, 'Gravel'),
    (14, 'Gold ore'),
    (15, 'Iron ore'),
    (16, 'Coal ore'),
    (17, 'Wood'),
    (18, 'Leaves'),
    (19, 'Sponge'),
    (20, 'Glass'),
    (21, 'Lapis Lazuli Ore'),
    (22, 'Lapis Lazuli Block'),
    (23, 'Dispenser'),
    (24, 'Sandstone'),
    (25, 'Note Block'),
    (26, 'No item'),
    (27, 'No item'),
    (28, 'No item'),
    (29, 'No item'),
    (30, 'No item'),
    (31, 'No item'),
    (32, 'No item'),
    (33, 'No item'),
    (34, 'No item'),
    (35, 'Gray Cloth / Wool'),
    (36, 'No item'),
    (37, 'Yellow flower'),
    (38, 'Red rose'),
    (39, 'Brown Mushroom'),
    (40, 'Red Mushroom'),
    (41, 'Gold Block'),
    (42, 'Iron Block'),
    (43, 'Double Stone Slab'),
    (44, 'Stone Slab'),
    (45, 'Brick'),
    (46, 'TNT'),
    (47, 'Bookshelf'),
    (48, 'Moss Stone'),
    (49, 'Obsidian'),
    (50, 'Torch'),
    (51, 'Fire'),
    (52, 'Monster Spawner'),
    (53, 'Wooden Stairs'),
    (54, 'Chest'),
    (55, 'Redstone Wire'),
    (56, 'Diamond Ore'),
    (57, 'Diamond Block'),
    (58, 'Workbench'),
    (59, 'Crops'),
    (60, 'Soil'),
    (61, 'Furnace'),
    (62, 'Burning Furnace'),
    (63, 'Sign Post'),
    (64, 'Wooden Door'),
    (67, 'Cobblestone Stairs'),
    (68, 'Wall Sign'),
    (69, 'Lever'),
    (70, 'Stone Pressure Plate'),
    (71, 'Iron Door'),
    (72, 'Wooden Pressure Plate'),
    (73, 'Redstone Ore'),
    (74, 'Glowing Redstone Ore'),
    (75, 'Redstone torch ("off" state)'),
    (77, 'Stone Button'),
    (78, 'Snow'),
    (79, 'Ice'),
    (80, 'Snow Block'),
    (81, 'Cactus'),
    (82, 'Clay'),
    (83, 'Reed'),
    (84, 'Jukebox'),
    (85, 'Fence'),
    (86, 'Pumpkin'),
    (87, 'Netherrack'),
    (88, 'Soul Sand'),
    (89, 'Glowstone'),
    (90, 'Portal'),
    (91, 'Jack-O-Lantern'),
    (256, 'Iron Shovel'),
    (257, 'Iron Pickaxe'),
    (258, 'Iron Axe'),
    (259, 'Flint and Steel'),
    (260, 'Apple'),
    (261, 'Bow'),
    (262, 'Arrow'),
    (263, 'Coal'),
    (264, 'Diamond'),
    (265, 'Iron Ingot'),
    (266, 'Gold Ingot'),
    (267, 'Iron Sword'),
    (268, 'Wooden Sword'),
    (269, 'Wooden Shovel'),
    (270, 'Wooden Pickaxe'),
    (271, 'Wooden Axe'),
    (272, 'Stone Sword'),
    (273, 'Stone Shovel'),
    (274, 'Stone Pickaxe'),
    (275, 'Stone Axe'),
    (276, 'Diamond Sword'),
    (277, 'Diamond Shovel'),
    (278, 'Diamond Pickaxe'),
    (279, 'Diamond Axe'),
    (282, 'Mushroom Soup'),
    (283, 'Gold Sword'),
    (284, 'Gold Shovel'),
    (285, 'Gold Pickaxe'),
    (286, 'Gold Axe'),
    (290, 'Wooden Hoe'),
    (291, 'Stone Hoe'),
    (292, 'Iron Hoe'),
    (293, 'Diamond Hoe'),
    (294, 'Gold Hoe'),
    (295, 'Seeds'),
    (296, 'Wheat'),
    (297, 'Bread'),
    (298, 'Leather Helmet'),
    (299, 'Leather Chestplate'),
    (300, 'Leather Leggings'),
    (301, 'Leather Boots'),
    (302, 'Chainmail Helmet'),
    (303, 'Chainmail Chestplate'),
    (304, 'Chainmail Leggings'),
    (305, 'Chainmail Boots'),
    (306, 'Iron Helmet'),
    (307, 'Iron Chestplate'),
    (308, 'Iron Leggings'),
    (309, 'Iron Boots'),
    (310, 'Diamond Helmet'),
    (311, 'Diamond Chestplate'),
    (312, 'Diamond Leggings'),
    (313, 'Diamond Boots'),
    (314, 'Gold Helmet'),
    (315, 'Gold Chestplate'),
    (316, 'Gold Leggings'),
    (317, 'Gold Boots'),
    (319, 'Raw Porkchop'),
    (320, 'Cooked Porkchop'),
    (321, 'Paintings'),
    (322, 'Golden apple'),
    (323, 'Sign'),
    (324, 'Wooden door'),
    (325, 'Bucket'),
    (326, 'Water bucket'),
    (327, 'Lava bucket'),
    (328, 'Mine cart'),
    (329, 'Saddle'),
    (330, 'Iron door'),
    (331, 'Redstone'),
    (332, 'Snowball'),
    (333, 'Boat'),
    (334, 'Leather'),
    (335, 'Milk'),
    (336, 'Clay Brick'),
    (337, 'Clay Balls'),
    (338, 'Sugar Cane'),
    (339, 'Paper'),
    (340, 'Book'),
    (344, 'Egg'),
    (345, 'Compass'),
    (347, 'Clock'),
    (348, 'Glowstone Dust'),
    (349, 'Raw Fish'),
    (350, 'Cooked Fish'),
    (352, 'Bone'),
    (353, 'Sugar'),
    (354, 'Cake'),
    (2256, 'Gold Music Disc'),
    (2257, 'Green Music Disc');
     
    legendblade likes this.
  2. Offline

    ScottieD

    would this fix the server?
     
  3. Offline

    legendblade

    Cool. Would you mind posting the script? I'm always okay with doing less work myself. :)
     
  4. Offline

    Raphfrk

    Wow new blocks?

    What are the differences?

    So, far I spotted

    Note -> plays notes
    Lapis Lazuli ore -> for dyes
    Lapis Lazuli block -> for dyes
    Dispenser -> releases items on click
    Note -> plays music
    Cake -> for healing

    ink sack
    bone
    sugar
     
  5. Offline

    Lamp

    I would, but i wrote it in a rush so it's terribly messy so it'd be embarrassing.:(
     
  6. Offline

    legendblade

    Aww.

    I've learned not to be embarrassed about my code; working with some of my coworkers has proven there's always somebody out there that writes worse code than I do. ;)
     
  7. Offline

    ScottieD

    If you post i will give you a huge hug, and maybe clean the code up for you.
     
  8. Offline

    feverdream

    Good job, but shouldnt your schema definition include an additional UNIQUE constraint to better index your tables since the name fields are all different anyway?

    So shouldn't it be more like:

    Code:
    CREATE TABLE IF NOT EXISTS `data_values` (
      `id` int(11) NOT NULL,
      `name` varchar(46) UNIQUE NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    .. if not let me know. I envision this as being faster to read, but more expensive to write.. but that write shouldn't matter since its read optimized use anyway.
     
  9. Offline

    Lamp

    Alright, I'll clean it up sometime tonight and post the source on this thread.

    It won't make much of a difference, but yeah this'll be a whole lot faster reading, but it'll also be extremely easy to write and update as long as you're using a local MySQL server; and besides it's better than flatfile ;).
     
  10. Offline

    feverdream

    Despite allegations to the contrary I love databases.. as long as they are optimized ;)
     
  11. Offline

    Lamp

    This is optimized, just make sure you select the key (id).
     
  12. Offline

    feverdream

    Yes but sometimes you wan to know the ID of a given thing.. so you select by name. If the name is not indexed with that UNIQUE constraint it takes more cpu to do the search.
     
Thread Status:
Not open for further replies.

Share This Page