diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt new file mode 100644 index 000000000..648c9a94d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt @@ -0,0 +1,33 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.client.renderer.BiomeColors +import net.minecraft.core.BlockPos +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.BlockAndTintGetter +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.client.event.RegisterColorHandlersEvent +import net.minecraftforge.eventbus.api.IEventBus + +object MBlockColors { + private const val DEFAULT_WATER_TINT: Int = 0x3F76E4; + + private fun registerBlockColors(event: RegisterColorHandlersEvent.Block) { + event.register({ state: BlockState?, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> + if (index == 0) { + if (light == null || pos == null) DEFAULT_WATER_TINT + BiomeColors.getAverageWaterColor(light!!, pos!!) + } else -1 + }, MBlocks.COBBLESTONE_GENERATOR) + } + + private fun registerItemColors(event: RegisterColorHandlersEvent.Item) { + event.register({ stack: ItemStack?, index: Int -> + if (index == 0) DEFAULT_WATER_TINT else -1 + }, MBlocks.COBBLESTONE_GENERATOR) + } + + internal fun register(bus: IEventBus) { + bus.addListener(this::registerBlockColors) + bus.addListener(this::registerItemColors) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index de5c7a32d..391200982 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -223,6 +223,7 @@ object MRegistry { LootModifiers.register(bus) MItemFunctionTypes.register(bus) MLootItemConditions.register(bus) + MBlockColors.register(bus) MRecipes.register(bus) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json index f296349d7..1e9f62a3c 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json @@ -4,9 +4,9 @@ "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/cobblestone_generator", - "1": "overdrive_that_matters:block/lava_still", - "2": "overdrive_that_matters:block/water_still", - "particle": "overdrive_that_matters:block/cobblestone_generator" + "particle": "overdrive_that_matters:block/cobblestone_generator", + "lava": "block/lava_still", + "water": "block/water_still" }, "elements": [ { @@ -42,19 +42,6 @@ "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} } }, - { - "name": "water", - "from": [12, 6, 1.1], - "to": [14.9, 14.9, 14.9], - "faces": { - "north": {"uv": [6.5, 7, 7.5, 9], "texture": "#2"}, - "east": {"uv": [0, 7, 6.5, 9], "texture": "#2"}, - "south": {"uv": [14, 7, 15, 9], "texture": "#2"}, - "west": {"uv": [7.5, 7, 14, 9], "texture": "#2"}, - "up": {"uv": [7.5, 7, 6.5, 3.75], "texture": "#2"}, - "down": {"uv": [8.5, 3.75, 7.5, 7], "texture": "#2"} - } - }, { "from": [15, 6, 1], "to": [12, 15, 15], @@ -75,20 +62,6 @@ "up": {"uv": [0, 6.25, 7, 7], "rotation": 270, "texture": "#0"} } }, - { - "name": "lava", - "from": [1.1, 6, 1.1], - "to": [4, 14.9, 14.9], - "faces": { - "north": {"uv": [6.5, 4, 7.5, 6], "texture": "#1"}, - "east": {"uv": [0, 4, 6.5, 6], "texture": "#1"}, - "south": {"uv": [14, 4, 15, 6], "texture": "#1"}, - "west": {"uv": [7.5, 4, 14, 6], "texture": "#1"}, - "up": {"uv": [7.5, 4, 6.5, 0.75], "texture": "#1"}, - "down": {"uv": [8.5, 0.75, 7.5, 4], "texture": "#1"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } - }, { "from": [4, 6, 1], "to": [1, 15, 15], @@ -98,6 +71,28 @@ "south": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} } + }, + { + "name": "lava", + "from": [1.1, 6, 1.1], + "to": [4, 14.9, 14.9], + "faces": { + "north": {"uv": [12, 1, 15, 10], "texture": "#lava"}, + "south": {"uv": [1, 1, 4, 10], "texture": "#lava"}, + "west": {"uv": [1, 1, 15, 10], "texture": "#lava"}, + "up": {"uv": [4, 15, 1, 1], "texture": "#lava"} + } + }, + { + "name": "water", + "from": [12, 6, 1.1], + "to": [14.9, 14.9, 14.9], + "faces": { + "north": {"uv": [1, 1, 4, 10], "texture": "#water", "tintindex": 0}, + "east": {"uv": [1, 1, 15, 10], "texture": "#water", "tintindex": 0}, + "south": {"uv": [12, 1, 15, 10], "texture": "#water", "tintindex": 0}, + "up": {"uv": [15, 15, 12, 1], "texture": "#water", "tintindex": 0} + } } ], "display": { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png b/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png deleted file mode 100644 index e62298cef..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png.mcmeta b/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png.mcmeta deleted file mode 100644 index 7ceb36394..000000000 --- a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png.mcmeta +++ /dev/null @@ -1,45 +0,0 @@ -{ - "animation": { - "frametime": 2, - "frames": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 18, - 17, - 16, - 15, - 14, - 13, - 12, - 11, - 10, - 9, - 8, - 7, - 6, - 5, - 4, - 3, - 2, - 1 - ] - } -} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png b/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png deleted file mode 100644 index 931d847fe..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png.mcmeta b/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png.mcmeta deleted file mode 100644 index 0645f48c6..000000000 --- a/src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png.mcmeta +++ /dev/null @@ -1,5 +0,0 @@ -{ - "animation": { - "frametime": 2 - } -}