Jump to content

Brickmotion

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Brickmotion

  1. So I found a solution, for anyone else wanting to do a similar thing: I coded a function to get three different color values from the ingot (you could just as well do more by just adding coordinates to the coordinate array) that is used for each ingot in an ingot list once in the preInit() section and fills an array with the values that can be used in the class implementing IItemColor: public int[] getColors(String name){ InputStream is; BufferedImage image; int[] res = {0,0,0}; int[] texture; try { String itemID; itemID = Reference.MOD_ID + ":textures/items/" + name + "_ingot.png"; is = Minecraft.getMinecraft().getResourceManager().getResource((new ResourceLocation(itemID))).getInputStream(); image = ImageIO.read(is); }catch(IOException e){e.printStackTrace();return res;} int[][] coords = {{4,5,0},{8,10,6}}; for (int j = 0; j < 3; j++) { texture = image.getRaster().getPixel(coords[0][j], coords[1][j], new int[4]); res[j] = new Color(texture[0],texture[1],texture[2]).getRGB(); } return res; } This code returns a three element integer array with the RGB values of the pixels [4,8], [5,10] and [0,6] from the texture defined as the name. As all my ingot names are saved in an array, I simply run through that array in a for loop and save the three result integers as array elements in a global array usable by all classes. Should the texture not exist, the function will return {0,0,0}, which results in the tools being colored black (though this could be changed to any color by simply changing the initial values of res to different numbers). I hope I could help anyone trying to do something similar to what I did.
  2. I put 1.13 in the title as Forge 1.13 could come out rather soon and I didn't know how fast someone would reply. I do know what pixel of the texture I want to take the color from, as I want to take it from an ingot texture, which in my case is always shaped the same. Keeping a list is really inpractical for me, as my mod has roughly 200 ingots that I want to get the colors from, and need colors from at least 2 different pixels so the tools can match the ingot (one color results in too many tools looking to similar). I think the GL11.glReadPixels method seems to be the most useful, I'll try to look into it.
  3. I'm trying to obtain the color value of an item's texture, more specifically from a specific pixel, to colorize tools in that color. I already know how to apply a color to an item (the way it's done on spawn eggs), yet I can't find anything on how to obtain the color value from another item for any version since the introduction of the JSON model system. As I want to apply the colors from the ingot that the tool is made of rather than keeping extensive lists of each color value, does anyone know how to achieve this? I know that it's possible somehow, as it is apparently used by Technomancy for refined ores, but I can't figure out how it is done there.
  4. That solution doesn't work, I can still use any potion in the recipe.
  5. I'm planning to implement an item wich, based on its NBT values, shows additional components on its texture (meaning that when an NBT variable is set to a certain value, another layer of the texture is loaded, if its set to another value, a different layer is loaded). However, as far as I understand it, to acomplish this I would have to create a model for every variation of this item possible, which the way I plan it would result in thousends, if not ten thousends of models I have to create (I want to have three seperate NBT variables that can be freely mixed, being able to take on at least 16 variants each, resulting in a minimum of 16³ = 4,096 variants). As making individual models is clearly not an option, I was wondering if there was a way to do this dynamically, meaning that I have one model that can somehow control this. I tried to figure out how banners implement a similar thing, but as those are tile entities, I don't know if this would work for items as well. Apparently Tinker's Construct is able to do something like this with freely combinable tools, but I don't know how this was achieved there.
  6. I checked my code again and realized that I already used "minecraft:potion" instead of "minecraft:potion_item" (potion_item used to be the name it went by in earlier versions, so I got the two mixed up), yet that is exactly where I run into the problem that NBT data is ignored and any potion can be used. I tried to figure this out by looking at the tipped arrow recipes in the vanilla code, which use specific lingering potions, yet they seem to be implemented in some other way than JSON that I don't know where to look for. ?
  7. While coding my new mod, I ran into a problem: I want to use the water bottle item from vanilla in my crafting recipe, yet when I use "minecraft:potion_item" as an ingredient, the recipe can use any potion from the game. I do, however, specifically want to use the water bottle, not any other potion. How can I set the NBT data in the recipe to only match that variation of the item, so it won't use any of the other potions? I'm currently working in 1.12, but I will switch to 1.13 as soon as it's released and a Forge version for it is published, so if this is only possible in 1.13, that would be okay (though if it works in 1.12 as well, that would be even better, as I wouldn't have to wait for 1.13). I hope for a quick reply.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.