Added side sensitivity to standard EntityDiggingFX, added Block functions to override spawning of digging and breaking effects.

This commit is contained in:
LexManos 2012-09-18 19:23:36 -07:00
parent de24eea885
commit c2d53e7651
4 changed files with 95 additions and 3 deletions

View file

@ -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;
+ }
}

View file

@ -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)
{

View file

@ -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);
+ }
}
}

View file

@ -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;
}