Drachenbauer Posted April 10, 2020 Posted April 10, 2020 Hello Is there any way to change the 16 basic color values (for banners, shields, sheep-wool, wolf-collars, ...) with a mod? Where in minecraft´s code are they stored? Quote
Drachenbauer Posted April 10, 2020 Author Posted April 10, 2020 (edited) theese are textcolors, not the colors, i mean. I found out, that, what i mean, is in DyeColor. What is the best way to get my own colorvalues in there? Edited April 10, 2020 by Drachenbauer Quote
imacatlolol Posted April 11, 2020 Posted April 11, 2020 (edited) Most things that use the colors (excluding leather armor and such) don't use them dynamically; you'd have to actually change the textures, names, etc. to have any effect. In any case, no. There's no reasonable way to change anything to do with DyeColor. Oh right, reflection duh. Edited April 11, 2020 by imacatlolol I'm dumb Quote I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) I really want to change the colorvalues for the things, i listed in the startpost. The other stuff, with textures, is already done. There must be a solution. Optifine did it, too. Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) I´m not sure, how. if i any where create own DyeColor-values, how can i apply them to the things in the game, wich use this enum? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) Must i extend and override all classes, that uses Dyecolor to do this? I saw some of them diectly using the prepared Colors on top of the enum Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 The sheep has this: public static DyeColor getRandomSheepColor(Random random) { int i = random.nextInt(100); if (i < 5) { return DyeColor.BLACK; } else if (i < 10) { return DyeColor.GRAY; } else if (i < 15) { return DyeColor.LIGHT_GRAY; } else if (i < 18) { return DyeColor.BROWN; } else if (random.nextInt(500) == 0) { return DyeColor.PINK; } else { return DyeColor.WHITE; } } Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 how can i make it use custom values? Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) Yes. I know about theese fields. Must i extend and override the sheep to replace the stuff, shown above, with such custom colorvalues? I don´t know, how to put stuff with custom values in theese fields, behind the "return" in this mthod there? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 This method want´s to return an object of the type Dyecolor. And i noticed, that i cannot make a custom instance of it, because this is not possible with an enum. Why don´t you just tell me, how to use the int field colorValue, where it wants to return DyeColor? Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) At searching for "change fields with reflection" i found this: Class<?> clazz = Class.forName("Child"); Object cc = clazz.newInstance(); Field f1 = cc.getClass().getField("a_field"); f1.set(cc, "reflecting on life"); But if i try to use DyeColors in there, it says things about IllegalAcessExeption. i hat to put theese exeptionhandlings to the header of the function, i placed this in. another question: A color-field holds alot of content; WHITE(0, "white", 16777215, MaterialColor.SNOW, 16777215, 16777215), how do i put all this into the setter of this reflection-stuff? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 I cannot find codesamples, where someone uses ObfuscationReflectionHelper to override fields in an enum. I really must see working code for this, to find out, how exactly it must look like. i never ured reflection before. Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "colorvalue"); ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "fireworkColor"); ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "textColor"); Is this the way to do it? To repeat for all 16 colors. Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) how do i find the SRG-names? And do you mean only for the variabls, or for class and instance, too? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) In my lines there i use the clear names DyeColor and WHITE. I taught, maybe i have to use the SRG-Names for theese things, too, in the positions for class and instance in the code-line... But maybe not, because it don´t want theese names as a string, like the fieldname. Another thing, yout discord-link stucks on connecting (a black page with a rotating discord-logo)... Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) Now i have theese lines for all 15 colors. Is this all i need to show all this stuff in the new colors? Now i found the class MaterialColors, where i als want to change fields now. What must i put there as the class-instance? Edit: The colors of banners and stuff are not changed now. What else must i do, to make it work? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) I made a test, but the banners, sheeps and other stuff still appear in old colors. I tried the code in common-setup and client-registries in my main-class, both the same. Now my lines look like this: ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_193351_w"); //colorvalue ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_196067_y"); //fireworkColor ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_218390_z"); //textColor Such a stack for each color. And for the material-color, i found out, that the colors there are such class-instances, zoo. So i was able to make this: ObfuscationReflectionHelper.setPrivateValue(MaterialColor.class, MaterialColor.RED, 0xff0000, "field_76291_p");//colorvalue also for all theese 16 colors and terracotta-colors. (there are some more values, but i don´t want to change them.) What do i miss, to get this stuff to work? Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 I see no exeptions in the console. Quote
Drachenbauer Posted April 11, 2020 Author Posted April 11, 2020 (edited) i decided to watch a video, how to use the debugger, than try this, and than tell more here. Like the guy in the video, i made a breakpoint at the first one of theese lines and clicked the debug-button, but it does not stop there. in other mods, other code, located in common-setup and client-registries is executed. So i´m wondering about this. Edited April 11, 2020 by Drachenbauer Quote
Drachenbauer Posted April 13, 2020 Author Posted April 13, 2020 Now i finally found the solution: i remembered, that there is a calculation for colorComponentValues. i placed it in a function in my main-class and passed the result of this function into another reflection-line for each color, that uses the field colorComponentValues. now the game-stuff appears in the new colors. Quote
Drachenbauer Posted April 13, 2020 Author Posted April 13, 2020 (edited) Now i noticed, there seems to be a slightly different shader, if the color comes from a texture pnr or from a colorvalue-number in the code: The leather-armour is dyed with the new shade of pink, i gave with my mod-code. And in my skin png (Stella from Angry Birds) i used the same color value for the pink color. So i wonder, why it looks different on almost horizontal surfaces (like the character´s face, if looking upward, like in the upper picture or the top of the body-ModelBox) in this more vertical orientation, you can see, that the lighter pink in the middie of th helmet-front is exctly the same as at the face of the character. And directly below the head, you can see the different shading between body and armour again another sample: bed and banner In this bed-texture png i also used the same shade of pink and the banner get´s it´s color from my mod-code. both models are TileEntity models The same difference at the horizontal surfaces (the narrow top of the banner looks closer to white, than the top of the bed). Why it makes a difference there, if the color comes from the texture or from a value in the code? Edited April 13, 2020 by Drachenbauer Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.