Skip to content

Commit

Permalink
feat: colorblind mode for chalks (see occultism-client.toml) (#974)
Browse files Browse the repository at this point in the history
* feat: add color supplier to chalk block

* feat: add configurable color
  • Loading branch information
klikli-dev committed Sep 25, 2023
1 parent c5075b7 commit 3a58be2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,16 @@ public class ChalkGlyphBlock extends Block {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 15, 0.04, 15);

protected Supplier<Item> chalk;
protected int color;
protected Supplier<Integer> color;

public ChalkGlyphBlock(Properties properties, int color, Supplier<Item> chalk) {
public ChalkGlyphBlock(Properties properties, Supplier<Integer> color, Supplier<Item> chalk) {
super(properties);
this.color = color;
this.chalk = chalk;
}

public int getColor() {
return this.color;
}

public void setColor(int color) {
this.color = color;
return this.color.get();
}

public Item getChalk() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public static class VisualSettings {
public final BooleanValue disableHolidayTheming;
public final BooleanValue useAlternativeDivinationRodRenderer;

public final ForgeConfigSpec.ConfigValue<Integer> whiteChalkGlyphColor;
public final ForgeConfigSpec.ConfigValue<Integer> goldenChalkGlyphColor;
public final ForgeConfigSpec.ConfigValue<Integer> purpleChalkGlyphColor;
public final ForgeConfigSpec.ConfigValue<Integer> redChalkGlyphColor;


public VisualSettings(ForgeConfigSpec.Builder builder) {
builder.comment("Visual Settings").push("visual");
this.showItemTagsInTooltip = builder.comment("Shows all tags an item has in the tooltip on hover if advanced tooltips (F3+H) are enabled.")
Expand All @@ -57,6 +63,32 @@ public VisualSettings(ForgeConfigSpec.Builder builder) {
"When true the old divination rod selected block renderer will be used.",
"May work for some people that do not see selected block outlines when using the divination rod.")
.define("useAlternativeDivinationRodRenderer", false);

this.whiteChalkGlyphColor = builder.comment(
"The integer code of the color of the white chalk glyph in world.",
"This is intended to allow people with color blindness to change the color of the glyph.",
"For most types of color blindness it should not be necessary to change this."
).define("whiteChalkGlyphColor", 0xffffff);

this.goldenChalkGlyphColor = builder.comment(
"The integer code of the color of the golden chalk glyph in world.",
"This is intended to allow people with color blindness to change the color of the glyph.",
"For most types of color blindness it should not be necessary to change this."
).define("goldenChalkGlyphColor", 0xf0d700);


this.purpleChalkGlyphColor = builder.comment(
"The integer code of the color of the purple chalk glyph in world.",
"This is intended to allow people with color blindness to change the color of the glyph.",
"For most types of color blindness it should not be necessary to change this."
).define("purpleChalkGlyphColor", 0x9c0393);

this.redChalkGlyphColor = builder.comment(
"The integer code of the color of the red chalk glyph in world.",
"This is intended to allow people with color blindness to change the color of the glyph.",
"For most types of color blindness this value should be changed to a green color, we recommend 33289 (= Hex 0x008209)"
).define("redChalkGlyphColor", 0xcc0101);

builder.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.klikli_dev.occultism.common.entity.familiar.FamiliarEntity;
import com.klikli_dev.occultism.common.level.tree.OtherworldNaturalTreeGrower;
import com.klikli_dev.occultism.common.level.tree.OtherworldTreeGrower;
import com.klikli_dev.occultism.config.OccultismClientConfig;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -89,16 +90,16 @@ public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSou
.sound(SoundType.WOOL).noCollission()
.strength(5f, 30);
public static final RegistryObject<ChalkGlyphBlock> CHALK_GLYPH_WHITE = register("chalk_glyph_white",
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xffffff, () -> OccultismItems.CHALK_WHITE.get()),
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.whiteChalkGlyphColor, () -> OccultismItems.CHALK_WHITE.get()),
false, LootTableType.EMPTY);
public static final RegistryObject<ChalkGlyphBlock> CHALK_GLYPH_GOLD = register("chalk_glyph_gold",
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xf0d700, () -> OccultismItems.CHALK_GOLD.get()), false,
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.goldenChalkGlyphColor, () -> OccultismItems.CHALK_GOLD.get()), false,
LootTableType.EMPTY);
public static final RegistryObject<ChalkGlyphBlock> CHALK_GLYPH_PURPLE = register("chalk_glyph_purple",
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0x9c0393, () -> OccultismItems.CHALK_PURPLE.get()),
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.purpleChalkGlyphColor, () -> OccultismItems.CHALK_PURPLE.get()),
false, LootTableType.EMPTY);
public static final RegistryObject<ChalkGlyphBlock> CHALK_GLYPH_RED = register("chalk_glyph_red",
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xcc0101, () -> OccultismItems.CHALK_RED.get()), false,
() -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.redChalkGlyphColor, () -> OccultismItems.CHALK_RED.get()), false,
LootTableType.EMPTY);

//Resources
Expand Down

0 comments on commit 3a58be2

Please sign in to comment.