Textures and id-related problems

Discussion in 'Plugin Development' started by TheZhyle, Nov 24, 2015.

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

    TheZhyle

    So.
    I'm trying to make a plugin for my server, you know, the basic stuff. I've added a few crafts, they work just fine, but soon I found out I'd need more complexe crafting recipes using more than 9 squares.
    So I've tried a basic recipe. Basically, it's 3 iron ingots that combined together create a "reinforced iron ingot", with durability enchantment to show the user that they're pretty though and all, and the basic sword craft with those creates a "reinforced sword", with durability.

    It looks just like that :

    [​IMG]
    [​IMG]
    (EDIT : have these links in case the image breaks. Never too carefull.
    http://www.noelshack.com/2015-48-1448353657-2015-11-24-09-26-05.png
    http://www.noelshack.com/2015-48-1448353668-2015-11-24-09-26-23.png
    )

    Yay, it works. But i had to use a variant of iron ingot, namely iron_ingot:1, for the intermediate iron ingot.
    Even though i get the sword, there's NO WAY that I can leave a purple and black texture for this iron_ingot:1, so I went and tried to make a texture pack, assuming that i just had to create a texture for iron_1.png or something like that.

    Doesnt work. Or rather, I didnt even bothered trying, since the same type of item, like for example colorants, are all named :
    dye_powder_blue.png
    dye_powder_cyan.png
    dye_powder_gray.png
    ink_sack.png (yay, consistency)

    wheras since their id is a variant of the ink sack's id, i had thought they would have looked like :
    ink_sack_0.png
    ink_sack_1.png
    ink_sack_2.png

    So there is obviously, somewhere, a file that tells MC what texture to fetch for each type of block, with for example something like
    id : 351:0 -> ink_sack.png
    id : 351:1 -> dye_powder_blue.png
    id : 351:2 -> dye_powder_cyan.png

    If i had such a file, i could tell him what the texture of my iron_ingot:1 is, and everything would be perfect.

    Cant find it. I dont even know if what I'm trying to do is actually possible.

    Here is the code for the crafts.

    Code:
    ItemStack reinforcedIronIngot = new ItemStack(Material.IRON_INGOT, 1, (byte)1);
    List<String> lore29 = new ArrayList<String>();
    ItemMeta meta29 = reinforcedIronIngot.getItemMeta();
    meta29 = reinforcedIronIngot.getItemMeta();
    meta29.setDisplayName("Reinforced iron");
    meta29.addEnchant(Enchantment.DURABILITY, 2, false);
    lore29.add("A solid iron ingot");
    meta29.setLore(lore29);
    reinforcedIronIngot.setItemMeta(meta29);
    ShapedRecipe g29 = new ShapedRecipe(reinforcedIronIngot);
    g29.shape("ABC");
    g29.setIngredient('A', Material.IRON_INGOT);
    g29.setIngredient('B', Material.IRON_INGOT);
    g29.setIngredient('C', Material.IRON_INGOT);
    getServer().addRecipe(g29);
    getLogger().info("Reinforced iron ingot recipe added!");
      
    ItemStack reinforcedIronSword = new ItemStack(Material.IRON_SWORD, 1);
    List<String> lore30 = new ArrayList<String>();
    ItemMeta meta30 = reinforcedIronSword.getItemMeta();
    meta30 = reinforcedIronSword.getItemMeta();
    meta30.setDisplayName("Reinforced iron sword");
    meta30.addEnchant(Enchantment.DURABILITY, 2, false);
    lore30.add("It's just a solid sword");
    meta30.setLore(lore30);
    reinforcedIronSword.setItemMeta(meta30);
    ShapedRecipe g30 = new ShapedRecipe(reinforcedIronSword);
    g30.shape("A", "B", "C");
    g30.setIngredient('A',Material.IRON_INGOT, (byte)1);
    g30.setIngredient('B',Material.IRON_INGOT, (byte)1);
    g30.setIngredient('C', Material.STICK);
    getServer().addRecipe(g30);
    getLogger().info("Reinforced sword recipe added!");
    So! Questions!

    1) Is this possible to do WITHOUT A MOD? I must use only plugins.
    2) If this is possible, how do I do it?
    3) If it's not possible, I've been told I would need to create something like

    replacing ItemStack reinforcedIronIngot = new ItemStack(Material.IRON_INGOT, 1, (byte)1);
    by ItemStack reinforcedIronIngot = new ItemStack(Material.IRON_INGOT, 1);

    replacing g30.setIngredient('A',Material.IRON_INGOT, (byte)1);
    by g30.setIngredient('A', new MaterialData(Material.IRON_INGOT, reinforcedIronIngot.getData().getData()));

    and replacing g30.setIngredient('B',Material.IRON_INGOT, (byte)1);
    by g30.setIngredient('B', new MaterialData(Material.IRON_INGOT, reinforcedIronIngot.getData().getData()));

    This way, the first craft just creates a normal iron ingot with enchantements and NBT tags and all, and then the second craft should accept only iron ingots with these precise NBT tags, but it doesnt seem to work. Help. :/

    I'd like to do this IN LAST RESORT. Having alternative items would be really great for what I'm trying to do, but if thats not possible, well, at least i'll have a way to work this out.

    Thanks for taking the time to read this!
     
    Last edited: Nov 24, 2015
  2. @TheZhyle God so much text -_- can you explain in a maximum of 3 sentences what exaclty you want to achive and then in 3 other sentences why you are failing? As far as i understood you want to create an enchanted ironingot out of 3 normal ones and if you build a sword out of those 3 enchanted ingots you get an enchanted sword. is that right?
     
  3. Offline

    TheZhyle

    Lel, much text cause I love beeing precise. <3

    Basic idea : I want to have a way to create recipes with intermediary steps, since 3x3 crafting isnt enough for complex recipes.
    First answer to said idea : I could use item variants (like iron_ingot:1) to craft this.
    Problem : It works but I cant find how to put textures on item variants, so i have awful intermediary steps.

    Second answer to said idea : I could use regular crafting with NBT tags.
    Problem : I dont know how to specify NBT craft necessary for a craft.

    I'd prefer to have the first answer than the second since cause adding textures is cool. Second answer is kinda like a last ressort in case first answer is not applicable.
     
    Last edited: Nov 24, 2015
  4. @TheZhyle why so complicated? just make multiple recipes like i mentioned above and mark them somehow. for example:

    1. put 3 ingots in a row to get a superingot. this superingot you mark by adding "superingot" to its lure or by adding an enchant
    2. put 2 of those superingots and a stick together to get a supersword. its the same recipe like for a normal sword but you define a listener, which check onCraft(...) which items has been used. if they were superingots you add data to the lure of the sword or enchant it, whatever, otherwise not.

    thats all i can tell so far from what i understand. im sorry but you ll have to stay with simple english with me since im not a native speaker and i also dont get what you mean with "iron_ingo:1"

    btw thag me or smth when you answer, otherwise i wont respond
     
  5. Offline

    TheZhyle

    @Shmobi : Sorry, new here, will add a tag. x)
    So.

    I understand your solution, but that wont work for my problem. I dont want to add enchant when crafted, I want to make the craft accessible only when you put these tagged stuff in your crafting table.

    What does iron_ingot:1 means?
    If you look at items like dye for example, they have all the same ID, which is 351. They have after the id a :0, :1, :2... etc to chose from the different types of dyes. IE, ink is 351:0, rose dye is 351:1... so on so on.
    You can do the same with any item. iron_ingot:0 is the basic iron ingot, and iron_ingot:1 is an alternative iron ingot. You can then create recipies using this iron like that :
    g30.setIngredient('A',Material.IRON_INGOT, (byte)1);
    you added "(byte)1" so the material needed is an iron_ingot:1

    As for why i want complicated stuff, it's because I'm playing on a roleplay minecraft server, and having realistic crafting steps is very good for us. So with your method i cant have custom textures for the intermediary steps, so it's not really what I'm looking for.
    + if someone explains me how to set the texture of this alternative iron, i can create an infinite number of items with different textures, which is cool.
     
Thread Status:
Not open for further replies.

Share This Page