diff --git a/.github/build.yml b/.github/build.yml deleted file mode 100644 index 8f27e0b..0000000 --- a/.github/build.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Qodana -on: - workflow_dispatch: - push: - branches: [ "main" ] - -jobs: - gradle: - strategy: - matrix: - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Execute Gradle build - run: ./gradlew build - - name: 'MC Publish' - uses: Kir-Antipov/mc-publish@v3.3 - with: - modrinth-id: nl0Cdq9L - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - modrinth-featured: true - qodana: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2023.2 - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7252f9e..460f917 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.parallel=true loader_version=0.14.22 parchment_version=2023.06.26 # Mod Properties - mod_version = 0.1.5 + mod_version = 0.1.65 maven_group = com.theomenden archives_base_name = bismuth @@ -17,4 +17,4 @@ org.gradle.parallel=true sodium_version=mc1.19.4-0.4.10 cloth_version=10.1.105 modmenu_version=6.3.1 - indium_version=1.0.25+mc1.20.1 + indium_version=1.0.19+mc1.19.4 \ No newline at end of file diff --git a/src/main/java/com/theomenden/bismuth/adapters/BismuthColorAdapter.java b/src/main/java/com/theomenden/bismuth/adapters/BismuthColorAdapter.java index 69aa722..889a95b 100644 --- a/src/main/java/com/theomenden/bismuth/adapters/BismuthColorAdapter.java +++ b/src/main/java/com/theomenden/bismuth/adapters/BismuthColorAdapter.java @@ -13,11 +13,11 @@ public class BismuthColorAdapter extends TypeAdapter { @Override - public void write(JsonWriter jsonWriter, BismuthColor vanadiumColor) throws IOException { - if(vanadiumColor == null) { + public void write(JsonWriter jsonWriter, BismuthColor bismuthColor) throws IOException { + if(bismuthColor == null) { jsonWriter.nullValue(); } else { - String hexValue = ColorConverter.rgbToHex(vanadiumColor.rgb()); + String hexValue = ColorConverter.rgbToHex(bismuthColor.rgb()); jsonWriter.value(hexValue); } } diff --git a/src/main/java/com/theomenden/bismuth/colors/properties/GlobalColorProperties.java b/src/main/java/com/theomenden/bismuth/colors/properties/GlobalColorProperties.java index 29c5bd2..f2fa523 100644 --- a/src/main/java/com/theomenden/bismuth/colors/properties/GlobalColorProperties.java +++ b/src/main/java/com/theomenden/bismuth/colors/properties/GlobalColorProperties.java @@ -269,13 +269,13 @@ private static Map, int[]> collateSpawnEggColors(Settings settings }); } - settings.spawnEgg.forEach((key, vanadiumColors) -> { + settings.spawnEgg.forEach((key, bismuthColors) -> { EntityType type = entityTypeRegistry.get(ResourceLocation.tryParse(key)); int[] colors = result.computeIfAbsent(type, t -> new int[2]); IntStream - .range(0, Math.min(2, vanadiumColors.length)) - .forEach(i -> colors[i] = vanadiumColors[i] + .range(0, Math.min(2, bismuthColors.length)) + .forEach(i -> colors[i] = bismuthColors[i] .rgb()); }); diff --git a/src/main/java/com/theomenden/bismuth/mixin/client/ClickableWidgetMixin.java b/src/main/java/com/theomenden/bismuth/mixin/client/ClickableWidgetMixin.java new file mode 100644 index 0000000..36718da --- /dev/null +++ b/src/main/java/com/theomenden/bismuth/mixin/client/ClickableWidgetMixin.java @@ -0,0 +1,44 @@ +package com.theomenden.bismuth.mixin.client; + +import com.theomenden.bismuth.utils.BismuthColormaticResolution; +import net.minecraft.client.gui.components.AbstractButton; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.network.chat.Component; +import org.apache.commons.lang3.ObjectUtils; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(AbstractButton.class) +public abstract class ClickableWidgetMixin extends AbstractWidget{ + + public ClickableWidgetMixin(int x, int y, int width, int height, Component message) { + super(x, y, width, height, message); + } + + @ModifyConstant(method="renderWidget", constant = @Constant(intValue = 16777215)) + private int hoverColorProxy(int original) { + var hoverColors = ObjectUtils.firstNonNull( + BismuthColormaticResolution.COLORMATIC_COLOR_PROPERTIES, + BismuthColormaticResolution.COLOR_PROPERTIES + ); + + int hoverColor = hoverColors.getProperties().getHoveredButtonText(); + return hoverColor != 0 + && this.isActive() + ? hoverColor + : original; + } + + @ModifyConstant(method="renderWidget", constant = @Constant(intValue = 10526880)) + private int disabledColorProxy(int original) { + var hoverColors = ObjectUtils.firstNonNull( + BismuthColormaticResolution.COLORMATIC_COLOR_PROPERTIES, + BismuthColormaticResolution.COLOR_PROPERTIES + ); + + int disabledColor = hoverColors.getProperties().getDisabledButtonText(); + return disabledColor != 0 ? disabledColor : original; + } +} diff --git a/src/main/java/com/theomenden/bismuth/mixin/sodium/SodiumGameOptionsPageMixin.java b/src/main/java/com/theomenden/bismuth/mixin/sodium/SodiumGameOptionsPageMixin.java index b1f5516..9f9f6c6 100644 --- a/src/main/java/com/theomenden/bismuth/mixin/sodium/SodiumGameOptionsPageMixin.java +++ b/src/main/java/com/theomenden/bismuth/mixin/sodium/SodiumGameOptionsPageMixin.java @@ -12,6 +12,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -24,8 +25,14 @@ public abstract class SodiumGameOptionsPageMixin { private static MinecraftOptionsStorage vanillaOpts; @Inject(method = "quality", - at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup;createBuilder()Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 2, shift = At.Shift.AFTER), - locals = LocalCapture.CAPTURE_FAILSOFT, remap = false) + at = @At( + value = "INVOKE", + target = "Lme/jellysquid/mods/sodium/client/gui/options/OptionImpl;createBuilder(Ljava/lang/Class;Lme/jellysquid/mods/sodium/client/gui/options/storage/OptionStorage;)Lme/jellysquid/mods/sodium/client/gui/options/OptionImpl$Builder;", + ordinal = 2, + shift = At.Shift.AFTER + ), + locals = LocalCapture.CAPTURE_FAILSOFT, + remap = false) private static void quality(CallbackInfoReturnable cir, List groups) { groups.add(OptionGroup.createBuilder() .add(OptionImpl diff --git a/src/main/java/com/theomenden/bismuth/utils/SimpleBiomeRegistryUtils.java b/src/main/java/com/theomenden/bismuth/utils/SimpleBiomeRegistryUtils.java index 54d928a..da54541 100644 --- a/src/main/java/com/theomenden/bismuth/utils/SimpleBiomeRegistryUtils.java +++ b/src/main/java/com/theomenden/bismuth/utils/SimpleBiomeRegistryUtils.java @@ -3,7 +3,11 @@ import com.google.common.collect.Lists; import com.mojang.serialization.Lifecycle; import lombok.Getter; +import net.fabricmc.fabric.impl.biome.modification.BuiltInRegistryKeys; +import net.minecraft.core.Holder; import net.minecraft.core.MappedRegistry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.resources.ResourceKey; @@ -11,46 +15,85 @@ import net.minecraft.world.level.biome.Biomes; import java.util.List; +import java.util.Optional; @Getter public final class SimpleBiomeRegistryUtils { @Getter - private static final List> BIOME_KEYS; + private static final List> BIOME_KEYS = Lists.newArrayList( + Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.WINDSWEPT_HILLS, + Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, + Biomes.NETHER_WASTES, Biomes.THE_END, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, + Biomes.SNOWY_PLAINS, Biomes.MUSHROOM_FIELDS, Biomes.BEACH, Biomes.JUNGLE, + Biomes.SPARSE_JUNGLE, Biomes.DEEP_OCEAN, Biomes.STONY_SHORE, Biomes.SNOWY_BEACH, + Biomes.BIRCH_FOREST, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.OLD_GROWTH_PINE_TAIGA, + Biomes.WINDSWEPT_FOREST, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, + Biomes.WOODED_BADLANDS, Biomes.SMALL_END_ISLANDS, Biomes.END_MIDLANDS, Biomes.END_HIGHLANDS, + Biomes.END_BARRENS, Biomes.WARM_OCEAN, + Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, + Biomes.DEEP_FROZEN_OCEAN, Biomes.THE_VOID, Biomes.SUNFLOWER_PLAINS, Biomes.WINDSWEPT_GRAVELLY_HILLS, + Biomes.FLOWER_FOREST, Biomes.ICE_SPIKES, Biomes.OLD_GROWTH_BIRCH_FOREST, Biomes.OLD_GROWTH_SPRUCE_TAIGA, + Biomes.WINDSWEPT_SAVANNA, Biomes.ERODED_BADLANDS, Biomes.BAMBOO_JUNGLE, Biomes.SOUL_SAND_VALLEY, + Biomes.CRIMSON_FOREST, Biomes.WARPED_FOREST, Biomes.BASALT_DELTAS, Biomes.DRIPSTONE_CAVES, + Biomes.LUSH_CAVES, Biomes.MEADOW, Biomes.GROVE, Biomes.SNOWY_SLOPES, Biomes.FROZEN_PEAKS, + Biomes.JAGGED_PEAKS, Biomes.STONY_PEAKS, Biomes.MANGROVE_SWAMP, Biomes.DEEP_DARK); @Getter - private static final MappedRegistry BUILT_IN_BIOMES; + private static final MappedRegistry BUILT_IN_BIOMES = createBiomeMappedRegistry(); - static { - BIOME_KEYS = Lists.newArrayList( - Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.WINDSWEPT_HILLS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.NETHER_WASTES, Biomes.THE_END, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_PLAINS, Biomes.MUSHROOM_FIELDS, Biomes.BEACH, Biomes.JUNGLE, Biomes.SPARSE_JUNGLE, Biomes.DEEP_OCEAN, Biomes.STONY_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.OLD_GROWTH_PINE_TAIGA, Biomes.WINDSWEPT_FOREST, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS, Biomes.SMALL_END_ISLANDS, Biomes.END_MIDLANDS, Biomes.END_HIGHLANDS, Biomes.END_BARRENS, Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.THE_VOID, Biomes.SUNFLOWER_PLAINS, Biomes.WINDSWEPT_GRAVELLY_HILLS, Biomes.FLOWER_FOREST, Biomes.ICE_SPIKES, Biomes.OLD_GROWTH_BIRCH_FOREST, Biomes.OLD_GROWTH_SPRUCE_TAIGA, Biomes.WINDSWEPT_SAVANNA, Biomes.ERODED_BADLANDS, Biomes.BAMBOO_JUNGLE, Biomes.SOUL_SAND_VALLEY, Biomes.CRIMSON_FOREST, Biomes.WARPED_FOREST, Biomes.BASALT_DELTAS, Biomes.DRIPSTONE_CAVES, Biomes.LUSH_CAVES, Biomes.MEADOW, Biomes.GROVE, Biomes.SNOWY_SLOPES, Biomes.FROZEN_PEAKS, Biomes.JAGGED_PEAKS, Biomes.STONY_PEAKS, Biomes.MANGROVE_SWAMP, Biomes.DEEP_DARK); - } + private static MappedRegistry createBiomeMappedRegistry() { + var result = new MappedRegistry<>(Registries.BIOME, Lifecycle.stable()); - static { var builtIn = VanillaRegistries .createLookup() .asGetterLookup() .lookupOrThrow(Registries.BIOME); - var builtInBiomeRegistry = new MappedRegistry<>(Registries.BIOME, Lifecycle.stable()); + var external = RegistryAccess + .fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .lookup(Registries.BIOME); + + for (var biome: BIOME_KEYS) { + var biomeReference = builtIn.get(biome); + biomeReference.ifPresent(reference -> result.register(biome, reference + .value(), Lifecycle.stable())); + } - BIOME_KEYS - .forEach( - b -> builtInBiomeRegistry.register(b, builtIn.getOrThrow(b).value(), Lifecycle.stable()) - ); + if(external.isPresent()) { + for (var externalBiomeReference : + external.get().listElements().toList()) { + var externalBiome = externalBiomeReference.value(); - BUILT_IN_BIOMES = builtInBiomeRegistry; + if(!result.containsKey(externalBiomeReference.key())) { + result.register(externalBiomeReference.key(), externalBiome, Lifecycle.stable()); + } + } + } + return result; } private SimpleBiomeRegistryUtils(){} public static int getBiomeRawId(ResourceKey biomeRegistryKey) { - - Biome lookedUpBiome =BUILT_IN_BIOMES + var lookedUpBiome = BUILT_IN_BIOMES .createRegistrationLookup() - .getOrThrow(biomeRegistryKey) - .value(); + .get(biomeRegistryKey); + + if(lookedUpBiome.isEmpty()) { + lookedUpBiome = getBiome(biomeRegistryKey); + } + + return getBiomeRawId(lookedUpBiome.orElseThrow() + .value()); + } + + private static Optional> getBiome(ResourceKey biomeResourceKey) { - return getBiomeRawId(lookedUpBiome); + return RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .asGetterLookup() + .lookup(Registries.BIOME) + .orElseThrow() + .get(biomeResourceKey); } private static int getBiomeRawId(Biome biome) { diff --git a/src/main/resources/bismuth.mixins.json b/src/main/resources/bismuth.mixins.json index ce988c8..523a0a5 100644 --- a/src/main/resources/bismuth.mixins.json +++ b/src/main/resources/bismuth.mixins.json @@ -12,6 +12,7 @@ "client.ResourceLocationMixin", "client.ChatStyleMixin", "client.VideoSettingsScreenMixin", + "client.ClickableWidgetMixin", "coloring.dye.DyeColorMixin", "coloring.dye.SheepEntityMixin", "coloring.TextureManagerMixin",