From 6eebea089694e1518c3b09398365a5fb01258522 Mon Sep 17 00:00:00 2001 From: Silver_David Date: Fri, 14 Jul 2023 19:08:51 -0400 Subject: [PATCH] New hook in IClientBlockExtensions to handle enabling tinting on breaking particles. #9446 --- .../client/particle/TerrainParticle.java.patch | 9 +++++++++ .../extensions/common/IClientBlockExtensions.java | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index 86b9920080..4ab28232ef 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/client/particle/TerrainParticle.java +++ b/net/minecraft/client/particle/TerrainParticle.java +@@ -28,7 +_,7 @@ + this.f_107227_ = 0.6F; + this.f_107228_ = 0.6F; + this.f_107229_ = 0.6F; +- if (!p_172458_.m_60713_(Blocks.f_50440_)) { ++ if (net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_172458_).areBreakingParticlesTinted(p_172458_, p_172451_, p_172459_)) { + int i = Minecraft.m_91087_().m_91298_().m_92577_(p_172458_, p_172451_, p_172459_, 0); + this.f_107227_ *= (float)(i >> 16 & 255) / 255.0F; + this.f_107228_ *= (float)(i >> 8 & 255) / 255.0F; @@ -69,7 +_,13 @@ public static class Provider implements ParticleProvider { public Particle m_6966_(BlockParticleOption p_108304_, ClientLevel p_108305_, double p_108306_, double p_108307_, double p_108308_, double p_108309_, double p_108310_, double p_108311_) { diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java index ea72ce34e7..5020ea42cf 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java @@ -5,6 +5,7 @@ package net.minecraftforge.client.extensions.common; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.core.BlockPos; import net.minecraft.world.effect.MobEffects; @@ -14,6 +15,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.HitResult; @@ -111,4 +113,17 @@ public interface IClientBlockExtensions } return originalColor; } + + /** + * Returns true if the breaking particles created from the {@link BlockState} passed should be tinted with biome colors. + * + * @param state The state of this block + * @param level The level the particles are spawning in + * @param pos The position of the block + * @return {@code true} if the particles should be tinted. + */ + default boolean areBreakingParticlesTinted(BlockState state, ClientLevel level, BlockPos pos) + { + return !state.is(Blocks.GRASS_BLOCK); + } }