Jump to content

Where are the basic color values coded?


Drachenbauer

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

        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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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