MrCrayfish / MrCrayfishGunMod

A Minecraft Mod focused on adding fun and simple weapons wtih lots of customisation including attachments and more!
Other
190 stars 131 forks source link

[Bug or Feature?] Color difference between workbench preview window and real model, and suggestion on color rendering #465

Open chemlzh opened 1 year ago

chemlzh commented 1 year ago

Descripe Your Problem:

I like crafting guns with different colors, since it looks cool. However, I found that there's color difference between workbench preview window and real model. I have read your code, and it seems that you modify the alpha value for the real model, but not for the preview window. This make a few of the color renderings excellent, but more color renderings dull. (See Evidence)

Could you please fix this bug to meet "what you see is what you get" demand?

Note: I have installed TFC: TNG and a curseforge datapack (modified by myself), so the recipe is different from original mod.

Evidence:

Black (With no difference)

color_black_preview color_black_real

Blue (So light that hurt eyes)

color_blue_preview color_blue_real

Brown

color_brown_preview color_brown_real

Cyan (Real-model rendering that I like best)

color_cyan_preview color_cyan_real

Gray

color_gray_preview color_gray_real

Green (Why does a dark-green gun in preview window become light green? I can't stand it)

color_green_preview color_green_real

Light Blue (The color of real model seems faded. Where is the color?)

color_light_blue_preview color_light_blue_real

Gray

color_light_gray_preview color_light_gray_real

Light Green (That's good)

color_light_green_preview color_light_green_real

Magenta

color_magenta_preview color_magenta_real

Orange

color_orange_preview color_orange_real

Pink (Also good)

color_pink_preview color_pink_real

Purple (So light that hurt eyes)

color_purple_preview color_purple_real

Red (I need a dart-red gun, not a light-red gun)

color_red_preview color_red_real

White (With no difference)

color_white_preview color_white_real

Yellow

color_yellow_preview color_yellow_real

Summary

color_summary

Nodysey commented 1 year ago

Probably something to do with lighting. If you have used MrCrayFish's Vehicle Mod, the car looks weird when put on the jack, due to lighting stuff. So the model and texture are still correct.

chemlzh commented 1 year ago

Probably something to do with lighting. If you have used MrCrayFish's Vehicle Mod, the car looks weird when put on the jack, due to lighting stuff. So the model and texture are still correct.

After checking the code concerning with rendering in CGM workbench and dyeing, I'm sure that this is not a feature, but a bug. In the "WorkbenchScreen.java", it wrote,

private void updateColor()
    {
        if(this.currentTab != null)
        {
            ItemStack item = this.displayStack;
            if(IColored.isDyeable(item))
            {
                IColored colored = (IColored) item.getItem();
                if(!this.workbench.getItem(0).isEmpty())
                {
                    ItemStack dyeStack = this.workbench.getItem(0);
                    if(dyeStack.getItem() instanceof DyeItem)
                    {
                        DyeColor color = ((DyeItem) dyeStack.getItem()).getDyeColor();
                        float[] components = color.getTextureDiffuseColors();
                        int red = (int) (components[0] * 255F);
                        int green = (int) (components[1] * 255F);
                        int blue = (int) (components[2] * 255F);
                        colored.setColor(item, ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | ((blue & 0xFF)));
                    }
                    else
                    {
                        colored.removeColor(item);
                    }
                }
                else
                {
                    colored.removeColor(item);
                }
            }
        }
    }

Therefore, in the CGM workbench, the initial color of guns and accessories are replaced with the dye color, consistant with my thought. However, when the guns (or accessories) are crafted, their colors are changed, meaning that in the crafting procedure, the color is not replaced, but fused with original color! (Or overflow result? Since fusion result of 0xF9FFFE and dye color doesn't match the final gun color.)

I doubt that there may be connection between this bug and IColored.java (or other dyeing function). @MrCrayfish, could you please help me check out the color before and after the guns crafted?