net.minecraft.client.particle.EntityDiggingFX Java Examples

The following examples show how to use net.minecraft.client.particle.EntityDiggingFX. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeneralChiselClient.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
public static void spawnChiselEffect(int x, int y, int z, String sound)
{
    World world = Minecraft.getMinecraft().theWorld;
    for(int side = 0; side < 6; side++)
    {
        for(int j = 0; j < 16; j++)
        {
            EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
            if(fx == null) return;

            fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
            fx.multiplyVelocity(0.3f * rand.nextFloat());
        }
    }

    GeneralClient.playChiselSound(world, x, y, z, sound);
}
 
Example #2
Source File: GeneralChiselClient.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public static void spawnChiselEffect(int x, int y, int z, String sound) {
	World world = Minecraft.getMinecraft().theWorld;
	for (int side = 0; side < 6; side++) {
		for (int j = 0; j < 16; j++) {
			EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
			if (fx == null)
				return;

			fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
			fx.multiplyVelocity(0.3f * rand.nextFloat());
		}
	}

	GeneralClient.playChiselSound(world, x, y, z, sound);
}
 
Example #3
Source File: GeneralChiselClient.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) {
	if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
		for (int i = 0; i < 10; i++) {
			EntityDiggingFX particle = new EntityDiggingFX(te.getWorldObj(), te.xCoord + 0.5, te.yCoord + 0.95, te.zCoord + 0.5, 0, 0, 0, Block.getBlockFromItem(base.getItem()),
					base.getItemDamage());
			particle.setVelocity((te.getWorldObj().rand.nextDouble() / 4) - 0.125, te.getWorldObj().rand.nextDouble() / 8, (te.getWorldObj().rand.nextDouble() / 4) - 0.125);
			Minecraft.getMinecraft().effectRenderer.addEffect(particle);
		}
		String sound = Carving.chisel.getVariationSound(base.getItem(), base.getItemDamage());
		GeneralClient.playChiselSound(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, sound);
	}
}
 
Example #4
Source File: BlockThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(world, x, y, z);
    BlockThinLog block = getBlock(world, x, y, z);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = world.getBlockMetadata(x, y, z);
    }

    try {
        byte count = 4;
        for (int ix = 0; ix < count; ++ix) {
            for (int iy = 0; iy < count; ++iy) {
                for (int iz = 0; iz < count; ++iz) {
                    double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                    double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                    double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                    EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                    fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

                    effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                }
            }
        }
    }
    catch (Exception e) { }

    return true;
}
 
Example #5
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(world, x, y, z);
    BlockThinLogFence block = getBlock(world, x, y, z);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = world.getBlockMetadata(x, y, z);
    }

    try {
        byte count = 4;
        for (int ix = 0; ix < count; ++ix) {
            for (int iy = 0; iy < count; ++iy) {
                for (int iz = 0; iz < count; ++iz) {
                    double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                    double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                    double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                    EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                    fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

                    effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                }
            }
        }
    }
    catch (Exception e) { }

    return true;
}
 
Example #6
Source File: GeneralChiselClient.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
	Block block = world.getBlock(x, y, z);
	if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
		return null;

	EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;

	float f = 0.1F;
	double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
	double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
	double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();

	switch (side) {
	case 0:
		d1 = y + block.getBlockBoundsMinY() - f;
		break;
	case 1:
		d1 = y + block.getBlockBoundsMaxY() + f;
		break;
	case 2:
		d2 = z + block.getBlockBoundsMinZ() - f;
		break;
	case 3:
		d2 = z + block.getBlockBoundsMaxZ() + f;
		break;
	case 4:
		d0 = x + block.getBlockBoundsMinX() - f;
		break;
	case 5:
		d0 = x + block.getBlockBoundsMaxX() + f;
		break;
	}

	EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
	res.motionX = d0 - (x + 0.5);
	res.motionY = d1 - (y + 0.5);
	res.motionZ = d2 - (z + 0.5);

	renderer.addEffect(res);

	return res;
}
 
Example #7
Source File: BlockThinLog.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(worldObj, target.blockX, target.blockY, target.blockZ);
    BlockThinLog block = getBlock(worldObj, target.blockX, target.blockY, target.blockZ);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
    }

    float f = 0.1F;
    double xPos = target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (f * 2.0F)) + f + block.getBlockBoundsMinX();
    double yPos = target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (f * 2.0F)) + f + block.getBlockBoundsMinY();
    double zPos = target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (f * 2.0F)) + f + block.getBlockBoundsMinZ();

    if (target.sideHit == 0)
        yPos = target.blockY + block.getBlockBoundsMinY() - f;
    if (target.sideHit == 1)
        yPos = target.blockY + block.getBlockBoundsMaxY() + f;
    if (target.sideHit == 2)
        zPos = target.blockZ + block.getBlockBoundsMinZ() - f;
    if (target.sideHit == 3)
        zPos = target.blockZ + block.getBlockBoundsMaxZ() + f;
    if (target.sideHit == 4)
        xPos = target.blockX + block.getBlockBoundsMinX() - f;
    if (target.sideHit == 5)
        xPos = target.blockX + block.getBlockBoundsMaxX() + f;

    EntityDiggingFX fx = new EntityDiggingFX(worldObj, xPos, yPos, zPos, 0.0D, 0.0D, 0.0D, block, worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ));
    fx.applyColourMultiplier(target.blockX, target.blockY, target.blockZ);
    fx.multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    fx.setParticleIcon(block.getIcon(worldObj.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

    effectRenderer.addEffect(fx);

    return true;
}
 
Example #8
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(worldObj, target.blockX, target.blockY, target.blockZ);
    BlockThinLogFence block = getBlock(worldObj, target.blockX, target.blockY, target.blockZ);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
    }

    float f = 0.1F;
    double xPos = target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (f * 2.0F)) + f + block.getBlockBoundsMinX();
    double yPos = target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (f * 2.0F)) + f + block.getBlockBoundsMinY();
    double zPos = target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (f * 2.0F)) + f + block.getBlockBoundsMinZ();

    if (target.sideHit == 0)
        yPos = target.blockY + block.getBlockBoundsMinY() - f;
    if (target.sideHit == 1)
        yPos = target.blockY + block.getBlockBoundsMaxY() + f;
    if (target.sideHit == 2)
        zPos = target.blockZ + block.getBlockBoundsMinZ() - f;
    if (target.sideHit == 3)
        zPos = target.blockZ + block.getBlockBoundsMaxZ() + f;
    if (target.sideHit == 4)
        xPos = target.blockX + block.getBlockBoundsMinX() - f;
    if (target.sideHit == 5)
        xPos = target.blockX + block.getBlockBoundsMaxX() + f;

    EntityDiggingFX fx = new EntityDiggingFX(worldObj, xPos, yPos, zPos, 0.0D, 0.0D, 0.0D, block, worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ));
    fx.applyColourMultiplier(target.blockX, target.blockY, target.blockZ);
    fx.multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    fx.setParticleIcon(block.getIcon(worldObj.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

    effectRenderer.addEffect(fx);

    return true;
}
 
Example #9
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityGarden te = getGardenEntity(world, x, y, z);
    BlockGarden garden = getGardenBlock(world, x, y, z);
    if (te == null || garden == null)
        return true;

    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block block = getPlantBlock(te, slot);
        int blockData = getPlantData(te, slot);
        if (block == null)
            continue;

        bindSlot(world, x, y, z, te, slot);
        try {
            byte count = 4;
            for (int ix = 0; ix < count; ++ix) {
                for (int iy = 0; iy < count; ++iy) {
                    for (int iz = 0; iz < count; ++iz) {
                        double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                        double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                        double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                        EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                        fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), blockData));

                        effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                    }
                }
            }
        }
        catch (Exception e) {
            continue;
        }
        finally {
            unbindSlot(world, x, y, z, te);
        }
    }

    return true;
}
 
Example #10
Source File: GeneralChiselClient.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side)
    {
        Block block = world.getBlock(x, y, z);
        if(block.isAir(world, x, y, z))
            return null;

        EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;

        float f = 0.1F;
        double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
        double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
        double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();

        switch(side)
        {
            case 0:
                d1 = y + block.getBlockBoundsMinY() - f;
                break;
            case 1:
                d1 = y + block.getBlockBoundsMaxY() + f;
                break;
            case 2:
                d2 = z + block.getBlockBoundsMinZ() - f;
                break;
            case 3:
                d2 = z + block.getBlockBoundsMaxZ() + f;
                break;
            case 4:
                d0 = x + block.getBlockBoundsMinX() - f;
                break;
            case 5:
                d0 = x + block.getBlockBoundsMaxX() + f;
                break;
        }

        EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
//		res.func_70596_a(x, y, z);
        res.motionX = d0 - (x + 0.5);
        res.motionY = d1 - (y + 0.5);
        res.motionZ = d2 - (z + 0.5);

        renderer.addEffect(res);

        return res;
    }