Jump to content

Recommended Posts

Posted (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 by Drachenbauer
Posted (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 by imacatlolol
I'm dumb

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Posted (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 by Drachenbauer
Posted

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;
        }
    }

 

Posted (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 by Drachenbauer
Posted

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?

Posted (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 by Drachenbauer
Posted

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.

Posted (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 by Drachenbauer
Posted (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 by Drachenbauer
Posted (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 by Drachenbauer
Posted (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 by Drachenbauer
Posted (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 by Drachenbauer
Posted

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.

Posted (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:

2020-04-13_18_20_22.png.df1ed41520fea61350e81624b9243e35.png

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)

2020-04-13_18_20_09.png.4a8025ec457fd6ba4e31a56d9ed3c401.png

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

2020-04-13_18_38_44.png.f8e35ebff50f5b384ba2b7a26a75185f.png

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 by Drachenbauer

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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