Search in sources :

Example 26 with EnumColor

use of mekanism.api.text.EnumColor in project Mekanism by mekanism.

the class SideDataButton method drawBackground.

@Override
public void drawBackground(@Nonnull MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
    DataType dataType = getDataType();
    EnumColor color = dataType == null ? null : getColor();
    boolean doColor = color != null && color != EnumColor.GRAY;
    if (doColor) {
        Color c = Color.rgbi(color.getRgbCode()[0], color.getRgbCode()[1], color.getRgbCode()[2]);
        double[] hsv = c.hsvArray();
        hsv[1] = Math.max(0, hsv[1] - 0.25F);
        hsv[2] = Math.min(1, hsv[2] + 0.4F);
        MekanismRenderer.color(Color.hsv(hsv[0], hsv[1], hsv[2]));
    } else {
        MekanismRenderer.resetColor();
    }
    super.drawBackground(matrix, mouseX, mouseY, partialTicks);
    if (doColor) {
        MekanismRenderer.resetColor();
    }
}
Also used : EnumColor(mekanism.api.text.EnumColor) EnumColor(mekanism.api.text.EnumColor) Color(mekanism.common.lib.Color) DataType(mekanism.common.tile.component.config.DataType)

Example 27 with EnumColor

use of mekanism.api.text.EnumColor in project Mekanism by mekanism.

the class ClientRegistration method registerItemColorHandlers.

@SubscribeEvent
public static void registerItemColorHandlers(ColorHandlerEvent.Item event) {
    // Create the texture atlas for the robit's textures here as there isn't a great spot to do it until 1.17
    createRobitTextureAtlas();
    BlockColors blockColors = event.getBlockColors();
    ItemColors itemColors = event.getItemColors();
    ClientRegistrationUtil.registerBlockColorHandler(blockColors, (state, world, pos, tintIndex) -> {
        if (pos != null) {
            TileEntity tile = WorldUtils.getTileEntity(world, pos);
            if (tile instanceof TileEntityQIOComponent) {
                EnumColor color = ((TileEntityQIOComponent) tile).getColor();
                return color != null ? MekanismRenderer.getColorARGB(color, 1) : -1;
            }
        }
        return -1;
    }, MekanismBlocks.QIO_DRIVE_ARRAY, MekanismBlocks.QIO_DASHBOARD, MekanismBlocks.QIO_IMPORTER, MekanismBlocks.QIO_EXPORTER, MekanismBlocks.QIO_REDSTONE_ADAPTER);
    ClientRegistrationUtil.registerIColoredBlockHandler(blockColors, itemColors, // Fluid Tank
    MekanismBlocks.BASIC_FLUID_TANK, MekanismBlocks.ADVANCED_FLUID_TANK, MekanismBlocks.ELITE_FLUID_TANK, MekanismBlocks.ULTIMATE_FLUID_TANK, MekanismBlocks.CREATIVE_FLUID_TANK);
    ClientRegistrationUtil.registerBlockColorHandler(blockColors, (state, world, pos, tintIndex) -> {
        if (tintIndex == 1 && pos != null) {
            TileEntityLogisticalTransporter transporter = WorldUtils.getTileEntity(TileEntityLogisticalTransporter.class, world, pos);
            if (transporter != null) {
                EnumColor renderColor = transporter.getTransmitter().getColor();
                if (renderColor != null) {
                    return MekanismRenderer.getColorARGB(renderColor, 1);
                }
            }
        }
        return -1;
    }, MekanismBlocks.BASIC_LOGISTICAL_TRANSPORTER, MekanismBlocks.ADVANCED_LOGISTICAL_TRANSPORTER, MekanismBlocks.ELITE_LOGISTICAL_TRANSPORTER, MekanismBlocks.ULTIMATE_LOGISTICAL_TRANSPORTER);
    for (Cell<ResourceType, PrimaryResource, ItemRegistryObject<Item>> item : MekanismItems.PROCESSED_RESOURCES.cellSet()) {
        int tint = item.getColumnKey().getTint();
        ClientRegistrationUtil.registerItemColorHandler(itemColors, (stack, index) -> index == 1 ? tint : -1, item.getValue());
    }
    for (Map.Entry<PrimaryResource, BlockRegistryObject<?, ?>> entry : MekanismBlocks.PROCESSED_RESOURCE_BLOCKS.entrySet()) {
        int tint = entry.getKey().getTint();
        ClientRegistrationUtil.registerBlockColorHandler(blockColors, itemColors, (state, world, pos, index) -> index == 1 ? tint : -1, (stack, index) -> index == 1 ? tint : -1, entry.getValue());
    }
    ClientRegistrationUtil.registerItemColorHandler(itemColors, (stack, index) -> {
        if (index == 1) {
            ItemPortableQIODashboard item = (ItemPortableQIODashboard) stack.getItem();
            EnumColor color = item.getColor(stack);
            return color == null ? 0xFF555555 : MekanismRenderer.getColorARGB(color, 1);
        }
        return -1;
    }, MekanismItems.PORTABLE_QIO_DASHBOARD);
}
Also used : PrimaryResource(mekanism.common.resource.PrimaryResource) ItemPortableQIODashboard(mekanism.common.item.ItemPortableQIODashboard) ItemRegistryObject(mekanism.common.registration.impl.ItemRegistryObject) ResourceType(mekanism.common.resource.ResourceType) TileEntityLogisticalTransporter(mekanism.common.tile.transmitter.TileEntityLogisticalTransporter) BlockColors(net.minecraft.client.renderer.color.BlockColors) TileEntity(net.minecraft.tileentity.TileEntity) EnumColor(mekanism.api.text.EnumColor) ItemColors(net.minecraft.client.renderer.color.ItemColors) BlockRegistryObject(mekanism.common.registration.impl.BlockRegistryObject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TileEntityQIOComponent(mekanism.common.tile.qio.TileEntityQIOComponent) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 28 with EnumColor

use of mekanism.api.text.EnumColor in project Mekanism by mekanism.

the class ColorButton method drawBackground.

@Override
public void drawBackground(@Nonnull MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
    // Ensure the color gets reset. The default GuiButtonImage doesn't so other GuiButton's can have the color leak out of them
    EnumColor color = colorSupplier.get();
    if (color != null) {
        fill(matrix, this.x, this.y, this.x + this.width, this.y + this.height, MekanismRenderer.getColorARGB(color, 1));
        MekanismRenderer.resetColor();
    }
}
Also used : EnumColor(mekanism.api.text.EnumColor)

Example 29 with EnumColor

use of mekanism.api.text.EnumColor in project Mekanism by mekanism.

the class AdditionsRecipeProvider method registerBalloon.

private void registerBalloon(Consumer<IFinishedRecipe> consumer, ItemRegistryObject<ItemBalloon> result, String basePath) {
    EnumColor color = result.getItem().getColor();
    String colorString = color.getRegistryPrefix();
    IngredientWithout recolorInput = IngredientWithout.create(Items.BALLOONS, result);
    DyeColor dye = color.getDyeColor();
    if (dye != null) {
        ExtendedShapelessRecipeBuilder.shapelessRecipe(result, 2).addIngredient(Tags.Items.LEATHER).addIngredient(Tags.Items.STRING).addIngredient(dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + colorString));
        ExtendedShapelessRecipeBuilder.shapelessRecipe(result).addIngredient(recolorInput).addIngredient(dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + "recolor/" + colorString));
    }
    ItemStackChemicalToItemStackRecipeBuilder.painting(ItemStackIngredient.from(recolorInput), PigmentStackIngredient.from(MekanismPigments.PIGMENT_COLOR_LOOKUP.get(color), PigmentExtractingRecipeProvider.DYE_RATE), new ItemStack(result)).build(consumer, Mekanism.rl(basePath + "recolor/painting/" + colorString));
}
Also used : EnumColor(mekanism.api.text.EnumColor) IngredientWithout(mekanism.common.recipe.ingredient.IngredientWithout) DyeColor(net.minecraft.item.DyeColor) ItemStack(net.minecraft.item.ItemStack)

Example 30 with EnumColor

use of mekanism.api.text.EnumColor in project Mekanism by mekanism.

the class PlasticBlockRecipeProvider method registerPlasticBlock.

private void registerPlasticBlock(Consumer<IFinishedRecipe> consumer, BlockRegistryObject<? extends IColoredBlock, ?> result, String basePath) {
    EnumColor color = result.getBlock().getColor();
    DyeColor dye = color.getDyeColor();
    if (dye != null) {
        ExtendedShapedRecipeBuilder.shapedRecipe(result, 4).pattern(PLASTIC).key(Pattern.CONSTANT, MekanismItems.HDPE_SHEET).key(Pattern.DYE, dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + color.getRegistryPrefix()));
    }
    registerRecolor(consumer, result, AdditionsTags.Items.PLASTIC_BLOCKS_PLASTIC, color, basePath);
}
Also used : EnumColor(mekanism.api.text.EnumColor) DyeColor(net.minecraft.item.DyeColor)

Aggregations

EnumColor (mekanism.api.text.EnumColor)33 Map (java.util.Map)6 DyeColor (net.minecraft.item.DyeColor)6 ItemStack (net.minecraft.item.ItemStack)5 ISideConfiguration (mekanism.common.tile.interfaces.ISideConfiguration)4 DataType (mekanism.common.tile.component.config.DataType)3 ArrayList (java.util.ArrayList)2 IPigmentProvider (mekanism.api.providers.IPigmentProvider)2 ItemConfigurator (mekanism.common.item.ItemConfigurator)2 PigmentRegistryObject (mekanism.common.registration.impl.PigmentRegistryObject)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Consumer (java.util.function.Consumer)1