From c2d53e76514d04ca1649f751ea20b5def9397725 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 18 Sep 2012 19:23:36 -0700 Subject: [PATCH] Added side sensitivity to standard EntityDiggingFX, added Block functions to override spawning of digging and breaking effects. --- .../common/net/minecraft/src/Block.java.patch | 39 ++++++++++++++++++- .../net/minecraft/client/Minecraft.java.patch | 9 +++++ .../minecraft/src/EffectRenderer.java.patch | 23 ++++++++++- .../minecraft/src/EntityDiggingFX.java.patch | 27 +++++++++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 patches/minecraft/net/minecraft/src/EntityDiggingFX.java.patch diff --git a/patches/common/net/minecraft/src/Block.java.patch b/patches/common/net/minecraft/src/Block.java.patch index 66bc502f5..50df30c15 100644 --- a/patches/common/net/minecraft/src/Block.java.patch +++ b/patches/common/net/minecraft/src/Block.java.patch @@ -104,7 +104,7 @@ { ItemStack var8 = this.createStackedBlock(par6); -@@ -1249,4 +1257,680 @@ +@@ -1249,4 +1257,717 @@ canBlockGrass[0] = true; StatList.initBreakableStats(); } @@ -783,5 +783,42 @@ + public boolean isBlockFoliage(World world, int x, int y, int z) + { + return false; ++ } ++ ++ /** ++ * Spawn a digging particle effect in the world, this is a wrapper ++ * around EffectRenderer.addBlockHitEffects to allow the block more ++ * control over the particles. Useful when you have entirely different ++ * texture sheets for different sides/locations in the world. ++ * ++ * @param world The current world ++ * @param target The target the player is looking at {x/y/z/side/sub} ++ * @param effectRenderer A reference to the current effect renderer. ++ * @return True to prevent vanilla digging particles form spawning. ++ */ ++ @SideOnly(Side.CLIENT) ++ public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) ++ { ++ return false; ++ } ++ ++ /** ++ * Spawn particles for when the block is destroyed. Due to the nature ++ * of how this is invoked, the x/y/z locations are not always guaranteed ++ * to host your block. So be sure to do proper sanity checks before assuming ++ * that the location is this block. ++ * ++ * @param world The current world ++ * @param x X position to spawn the particle ++ * @param y Y position to spawn the particle ++ * @param z Z position to spawn the particle ++ * @param meta The metadata for the block before it was destroyed. ++ * @param effectRenderer A reference to the current effect renderer. ++ * @return True to prevent vanilla break particles from spawning. ++ */ ++ @SideOnly(Side.CLIENT) ++ public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) ++ { ++ return false; + } } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 3717a24b4..608bd2d20 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -8,6 +8,15 @@ import org.lwjgl.LWJGLException; import org.lwjgl.Sys; +@@ -1245,7 +1246,7 @@ + + if (this.thePlayer.canPlayerEdit(var3, var4, var5)) + { +- this.effectRenderer.addBlockHitEffects(var3, var4, var5, this.objectMouseOver.sideHit); ++ this.effectRenderer.addBlockHitEffects(var3, var4, var5, this.objectMouseOver); + this.thePlayer.swingItem(); + } + } @@ -2221,80 +2222,12 @@ if (this.objectMouseOver != null) { diff --git a/patches/minecraft/net/minecraft/src/EffectRenderer.java.patch b/patches/minecraft/net/minecraft/src/EffectRenderer.java.patch index 7be35765d..bd3fd348c 100644 --- a/patches/minecraft/net/minecraft/src/EffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/src/EffectRenderer.java.patch @@ -74,7 +74,7 @@ } public void renderLitParticles(Entity par1Entity, float par2) -@@ -144,6 +187,8 @@ +@@ -144,13 +187,15 @@ { this.fxLayers[var2].clear(); } @@ -83,6 +83,16 @@ } public void addBlockDestroyEffects(int par1, int par2, int par3, int par4, int par5) + { +- if (par4 != 0) +- { +- Block var6 = Block.blocksList[par4]; ++ Block var6 = Block.blocksList[par4]; ++ if (var6 != null && !var6.addBlockDestroyEffects(worldObj, par1, par2, par3, par5, this)) ++ { + byte var7 = 4; + + for (int var8 = 0; var8 < var7; ++var8) @@ -163,7 +208,7 @@ double var13 = (double)par2 + ((double)var9 + 0.5D) / (double)var7; double var15 = (double)par3 + ((double)var10 + 0.5D) / (double)var7; @@ -92,7 +102,7 @@ } } } -@@ -215,12 +260,51 @@ +@@ -215,12 +260,60 @@ var8 = (double)par1 + var6.maxX + (double)var7; } @@ -144,5 +154,14 @@ + } + texture = ForgeHooks.getTexture(texture, obj); + effectList.put(texture, effect); ++ } ++ ++ public void addBlockHitEffects(int x, int y, int z, MovingObjectPosition target) ++ { ++ Block block = Block.blocksList[worldObj.getBlockId(x, y, z)]; ++ if (block != null && !block.addBlockHitEffects(worldObj, target, this)) ++ { ++ addBlockHitEffects(x, y, z, target.sideHit); ++ } } } diff --git a/patches/minecraft/net/minecraft/src/EntityDiggingFX.java.patch b/patches/minecraft/net/minecraft/src/EntityDiggingFX.java.patch new file mode 100644 index 000000000..9fb089bcf --- /dev/null +++ b/patches/minecraft/net/minecraft/src/EntityDiggingFX.java.patch @@ -0,0 +1,27 @@ +--- ../src_base/minecraft/net/minecraft/src/EntityDiggingFX.java ++++ ../src_work/minecraft/net/minecraft/src/EntityDiggingFX.java +@@ -7,20 +7,22 @@ + public class EntityDiggingFX extends EntityFX + { + private Block blockInstance; ++ private int side; + + public EntityDiggingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Block par14Block, int par15, int par16) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.blockInstance = par14Block; +- this.setParticleTextureIndex(par14Block.getBlockTextureFromSideAndMetadata(0, par16)); ++ this.setParticleTextureIndex(par14Block.getBlockTextureFromSideAndMetadata(par15, par16)); + this.particleGravity = par14Block.blockParticleGravity; + this.particleRed = this.particleGreen = this.particleBlue = 0.6F; + this.particleScale /= 2.0F; ++ this.side = par15; + } + + public EntityDiggingFX func_70596_a(int par1, int par2, int par3) + { +- if (this.blockInstance == Block.grass) ++ if (this.blockInstance == Block.grass && this.side != 1) + { + return this; + }